import { formatISO9075, fromUnixTime, getUnixTime } from "date-fns"; import { Component, Show, mergeProps, splitProps, FlowComponent, createSignal, createEffect, For, } from "solid-js"; import { validateInput } from "~/hooks/validation"; import AsteriskIcon from "~icons/ph/asterisk-bold"; import MaximizeIcon from "~icons/carbon/maximize"; import MinimizeIcon from "~icons/carbon/minimize"; import autosize from "autosize"; import type { JSX } from "solid-js"; import { createNativeInputValue, createOptionalNumberInputHandler, } from "~/util"; export const TextInput: Component< { label: string; placeholder?: string; labelMinWidth?: string; suffix?: string | JSX.Element; size?: string; vertical?: boolean; invalidate?: (v: any) => string | boolean; } & JSX.InputHTMLAttributes > = (p) => { p = mergeProps( { placeholder: p.label, labelMinWidth: "95px", size: "sm", vertical: false, }, p ); const [props, rest] = splitProps(p, [ "name", "size", "class", "label", "placeholder", "suffix", "vertical", "labelMinWidth", "invalidate", ]); const sizes: Record = { xs: "input-xs", sm: "input-sm", lg: "input-lg", }; const [validate, vState] = validateInput({ invalidate: props.invalidate, value: () => rest.value, }); return (
); }; export const Checkbox: FlowComponent< JSX.InputHTMLAttributes > = (p) => { const [props, rest] = splitProps(p, ["children"]); return (
); }; export const TextArea: Component< { label: string; labelSuffixJsx?: JSX.Element; value?: string; placeholder?: string; } & JSX.TextareaHTMLAttributes > = (p) => { p = mergeProps({ rows: 3, placeholder: p.label }, p); const [props, rest] = splitProps(p, ["label", "labelSuffixJsx", "value"]); const [autosizeEnabled, setAutosize] = createSignal(false); let textareaEl: HTMLTextAreaElement = undefined!; createEffect(function () { if (autosizeEnabled()) { autosize(textareaEl); } else { autosize.destroy(textareaEl); } }); return (