@k2b/ui 0.63.0 → 0.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/base.css +6 -3
- package/dist/browser/actions/ContextMenu.js +3 -1
- package/dist/browser/actions/ContextMenu.js.map +1 -1
- package/dist/browser/actions/DragAndDrop.js +26 -5
- package/dist/browser/actions/DragAndDrop.js.map +1 -1
- package/dist/browser/actions/DropOverlay.js +76 -0
- package/dist/browser/actions/DropOverlay.js.map +1 -0
- package/dist/browser/actions/Dropdown.js +69 -15
- package/dist/browser/actions/Dropdown.js.map +1 -1
- package/dist/browser/actions/SortableList.js +338 -85
- package/dist/browser/actions/SortableList.js.map +1 -1
- package/dist/browser/actions/ViewTabs.js +9 -5
- package/dist/browser/actions/ViewTabs.js.map +1 -1
- package/dist/browser/actions/drag-and-drop-keyboard.js +211 -0
- package/dist/browser/actions/drag-and-drop-keyboard.js.map +1 -0
- package/dist/browser/actions/drag-and-drop-messages.js +21 -25
- package/dist/browser/actions/drag-and-drop-messages.js.map +1 -1
- package/dist/browser/actions/drag-and-drop.js +206 -184
- package/dist/browser/actions/drag-and-drop.js.map +1 -1
- package/dist/browser/actions/drop-overlay-pages.js +54 -0
- package/dist/browser/actions/drop-overlay-pages.js.map +1 -0
- package/dist/browser/actions/drop-overlay-view.js +318 -0
- package/dist/browser/actions/drop-overlay-view.js.map +1 -0
- package/dist/browser/actions/index.js +4 -2
- package/dist/browser/actions/index.js.map +1 -1
- package/dist/browser/actions/menu-sheet-messages.js +26 -0
- package/dist/browser/actions/menu-sheet-messages.js.map +1 -0
- package/dist/browser/actions/menu-sheet.js +80 -18
- package/dist/browser/actions/menu-sheet.js.map +1 -1
- package/dist/browser/actions/menu-submenu-panel.js +392 -0
- package/dist/browser/actions/menu-submenu-panel.js.map +1 -0
- package/dist/browser/actions/preload-when-idle.js +15 -0
- package/dist/browser/actions/preload-when-idle.js.map +1 -0
- package/dist/browser/actions/sortable-board.js +107 -0
- package/dist/browser/actions/sortable-board.js.map +1 -0
- package/dist/browser/actions/sortable-keyboard.js +202 -0
- package/dist/browser/actions/sortable-keyboard.js.map +1 -0
- package/dist/browser/actions/sortable-list-messages.js +23 -11
- package/dist/browser/actions/sortable-list-messages.js.map +1 -1
- package/dist/browser/actions/sortable-place.js +26 -0
- package/dist/browser/actions/sortable-place.js.map +1 -0
- package/dist/browser/chat/ChatDecision.js +499 -463
- package/dist/browser/chat/ChatDecision.js.map +1 -1
- package/dist/browser/chat/ChatDecisionField.js +311 -0
- package/dist/browser/chat/ChatDecisionField.js.map +1 -0
- package/dist/browser/chat/index.js +2 -0
- package/dist/browser/chat/index.js.map +1 -1
- package/dist/browser/chat/types.js.map +1 -1
- package/dist/browser/chat-decision-field.js +6 -0
- package/dist/browser/chat-decision-field.js.map +1 -0
- package/dist/browser/content/DataTable.js +326 -205
- package/dist/browser/content/DataTable.js.map +1 -1
- package/dist/browser/content/FileName.js +68 -0
- package/dist/browser/content/FileName.js.map +1 -0
- package/dist/browser/content/ProgressPath.js +30 -25
- package/dist/browser/content/ProgressPath.js.map +1 -1
- package/dist/browser/content/TaskRow.js +129 -0
- package/dist/browser/content/TaskRow.js.map +1 -0
- package/dist/browser/content/index.js +2 -0
- package/dist/browser/content/index.js.map +1 -1
- package/dist/browser/content/progress-path-messages.js +22 -0
- package/dist/browser/content/progress-path-messages.js.map +1 -0
- package/dist/browser/feedback/dialog-core.js +68 -11
- package/dist/browser/feedback/dialog-core.js.map +1 -1
- package/dist/browser/feedback/dialog-foot.js +45 -0
- package/dist/browser/feedback/dialog-foot.js.map +1 -0
- package/dist/browser/inputs/DatePicker.js +369 -716
- package/dist/browser/inputs/DatePicker.js.map +1 -1
- package/dist/browser/inputs/FileInputs.js +1 -1
- package/dist/browser/inputs/FileInputs.js.map +1 -1
- package/dist/browser/inputs/NumberInput.js +125 -46
- package/dist/browser/inputs/NumberInput.js.map +1 -1
- package/dist/browser/inputs/PeriodPicker.js +9 -4
- package/dist/browser/inputs/PeriodPicker.js.map +1 -1
- package/dist/browser/inputs/TextInput.js +3 -3
- package/dist/browser/inputs/TextInput.js.map +1 -1
- package/dist/browser/inputs/date-picker-panel.js +420 -0
- package/dist/browser/inputs/date-picker-panel.js.map +1 -0
- package/dist/browser/inputs/image-crop.js +1 -1
- package/dist/browser/inputs/image-crop.js.map +1 -1
- package/dist/browser/inputs/image-tools.js +4 -0
- package/dist/browser/inputs/image-tools.js.map +1 -0
- package/dist/browser/inputs/input-messages.js +8 -2
- package/dist/browser/inputs/input-messages.js.map +1 -1
- package/dist/browser/internal/field.js +2 -2
- package/dist/browser/internal/field.js.map +1 -1
- package/dist/browser/internal/renders-something.js +3 -0
- package/dist/browser/internal/renders-something.js.map +1 -0
- package/dist/browser/intl/messages.js +1 -1
- package/dist/browser/intl/messages.js.map +1 -1
- package/dist/browser/layout/AppWorkspace.js +16 -8
- package/dist/browser/layout/AppWorkspace.js.map +1 -1
- package/dist/browser/layout/Breadcrumbs.js +188 -42
- package/dist/browser/layout/Breadcrumbs.js.map +1 -1
- package/dist/browser/layout/DetailPanel.js +209 -205
- package/dist/browser/layout/DetailPanel.js.map +1 -1
- package/dist/browser/layout/FloatingPill.js +33 -0
- package/dist/browser/layout/FloatingPill.js.map +1 -0
- package/dist/browser/layout/PanelDialog.js +176 -88
- package/dist/browser/layout/PanelDialog.js.map +1 -1
- package/dist/browser/layout/StatusRow.js +174 -0
- package/dist/browser/layout/StatusRow.js.map +1 -0
- package/dist/browser/layout/app-workspace-controller.js +12 -5
- package/dist/browser/layout/app-workspace-controller.js.map +1 -1
- package/dist/browser/layout/app-workspace-state.js +2 -2
- package/dist/browser/layout/app-workspace-state.js.map +1 -1
- package/dist/browser/layout/index.js +2 -0
- package/dist/browser/layout/index.js.map +1 -1
- package/dist/browser/layout/panel-dialog-error.js +44 -0
- package/dist/browser/layout/panel-dialog-error.js.map +1 -0
- package/dist/browser/layout/panel-sheet-handle.js +86 -0
- package/dist/browser/layout/panel-sheet-handle.js.map +1 -0
- package/dist/browser/layout/workspace-messages.js +12 -2
- package/dist/browser/layout/workspace-messages.js.map +1 -1
- package/dist/browser/layout-check.js +232 -0
- package/dist/browser/layout-check.js.map +1 -0
- package/dist/browser/surfaces/Area.js +205 -0
- package/dist/browser/surfaces/Area.js.map +1 -0
- package/dist/browser/surfaces/FactGroup.js +148 -0
- package/dist/browser/surfaces/FactGroup.js.map +1 -0
- package/dist/browser/surfaces/FieldGrid.js +34 -0
- package/dist/browser/surfaces/FieldGrid.js.map +1 -0
- package/dist/browser/surfaces/NoticeCard.js +69 -57
- package/dist/browser/surfaces/NoticeCard.js.map +1 -1
- package/dist/browser/surfaces/Placeholder.js +17 -5
- package/dist/browser/surfaces/Placeholder.js.map +1 -1
- package/dist/browser/surfaces/RowGroup.js +82 -0
- package/dist/browser/surfaces/RowGroup.js.map +1 -0
- package/dist/browser/surfaces/Section.js +22 -7
- package/dist/browser/surfaces/Section.js.map +1 -1
- package/dist/browser/surfaces/StatusBadge.js +5 -1
- package/dist/browser/surfaces/StatusBadge.js.map +1 -1
- package/dist/browser/surfaces/flat-block-messages.js +37 -0
- package/dist/browser/surfaces/flat-block-messages.js.map +1 -0
- package/dist/browser/surfaces/index.js +4 -0
- package/dist/browser/surfaces/index.js.map +1 -1
- package/dist/ssr/actions/ContextMenu.js +3 -1
- package/dist/ssr/actions/ContextMenu.js.map +1 -1
- package/dist/ssr/actions/DragAndDrop.js +26 -5
- package/dist/ssr/actions/DragAndDrop.js.map +1 -1
- package/dist/ssr/actions/DropOverlay.js +69 -0
- package/dist/ssr/actions/DropOverlay.js.map +1 -0
- package/dist/ssr/actions/Dropdown.js +69 -15
- package/dist/ssr/actions/Dropdown.js.map +1 -1
- package/dist/ssr/actions/SortableList.js +293 -71
- package/dist/ssr/actions/SortableList.js.map +1 -1
- package/dist/ssr/actions/ViewTabs.js +9 -5
- package/dist/ssr/actions/ViewTabs.js.map +1 -1
- package/dist/ssr/actions/drag-and-drop-keyboard.js +211 -0
- package/dist/ssr/actions/drag-and-drop-keyboard.js.map +1 -0
- package/dist/ssr/actions/drag-and-drop-messages.js +21 -25
- package/dist/ssr/actions/drag-and-drop-messages.js.map +1 -1
- package/dist/ssr/actions/drag-and-drop.js +206 -184
- package/dist/ssr/actions/drag-and-drop.js.map +1 -1
- package/dist/ssr/actions/drop-overlay-pages.js +54 -0
- package/dist/ssr/actions/drop-overlay-pages.js.map +1 -0
- package/dist/ssr/actions/drop-overlay-view.js +225 -0
- package/dist/ssr/actions/drop-overlay-view.js.map +1 -0
- package/dist/ssr/actions/index.js +4 -2
- package/dist/ssr/actions/index.js.map +1 -1
- package/dist/ssr/actions/menu-sheet-messages.js +26 -0
- package/dist/ssr/actions/menu-sheet-messages.js.map +1 -0
- package/dist/ssr/actions/menu-sheet.js +62 -10
- package/dist/ssr/actions/menu-sheet.js.map +1 -1
- package/dist/ssr/actions/menu-submenu-panel.js +295 -0
- package/dist/ssr/actions/menu-submenu-panel.js.map +1 -0
- package/dist/ssr/actions/preload-when-idle.js +15 -0
- package/dist/ssr/actions/preload-when-idle.js.map +1 -0
- package/dist/ssr/actions/sortable-board.js +107 -0
- package/dist/ssr/actions/sortable-board.js.map +1 -0
- package/dist/ssr/actions/sortable-keyboard.js +202 -0
- package/dist/ssr/actions/sortable-keyboard.js.map +1 -0
- package/dist/ssr/actions/sortable-list-messages.js +23 -11
- package/dist/ssr/actions/sortable-list-messages.js.map +1 -1
- package/dist/ssr/actions/sortable-place.js +26 -0
- package/dist/ssr/actions/sortable-place.js.map +1 -0
- package/dist/ssr/chat/ChatDecision.js +256 -228
- package/dist/ssr/chat/ChatDecision.js.map +1 -1
- package/dist/ssr/chat/ChatDecisionField.js +206 -0
- package/dist/ssr/chat/ChatDecisionField.js.map +1 -0
- package/dist/ssr/chat/index.js +2 -0
- package/dist/ssr/chat/index.js.map +1 -1
- package/dist/ssr/chat/types.js.map +1 -1
- package/dist/ssr/chat-decision-field.js +6 -0
- package/dist/ssr/chat-decision-field.js.map +1 -0
- package/dist/ssr/content/DataTable.js +93 -50
- package/dist/ssr/content/DataTable.js.map +1 -1
- package/dist/ssr/content/FileName.js +46 -0
- package/dist/ssr/content/FileName.js.map +1 -0
- package/dist/ssr/content/ProgressPath.js +14 -8
- package/dist/ssr/content/ProgressPath.js.map +1 -1
- package/dist/ssr/content/TaskRow.js +95 -0
- package/dist/ssr/content/TaskRow.js.map +1 -0
- package/dist/ssr/content/index.js +2 -0
- package/dist/ssr/content/index.js.map +1 -1
- package/dist/ssr/content/progress-path-messages.js +22 -0
- package/dist/ssr/content/progress-path-messages.js.map +1 -0
- package/dist/ssr/feedback/dialog-core.js +68 -11
- package/dist/ssr/feedback/dialog-core.js.map +1 -1
- package/dist/ssr/feedback/dialog-foot.js +45 -0
- package/dist/ssr/feedback/dialog-foot.js.map +1 -0
- package/dist/ssr/inputs/DatePicker.js +94 -263
- package/dist/ssr/inputs/DatePicker.js.map +1 -1
- package/dist/ssr/inputs/FileInputs.js +1 -1
- package/dist/ssr/inputs/FileInputs.js.map +1 -1
- package/dist/ssr/inputs/NumberInput.js +114 -44
- package/dist/ssr/inputs/NumberInput.js.map +1 -1
- package/dist/ssr/inputs/PeriodPicker.js +9 -4
- package/dist/ssr/inputs/PeriodPicker.js.map +1 -1
- package/dist/ssr/inputs/TextInput.js +3 -3
- package/dist/ssr/inputs/TextInput.js.map +1 -1
- package/dist/ssr/inputs/date-picker-panel.js +233 -0
- package/dist/ssr/inputs/date-picker-panel.js.map +1 -0
- package/dist/ssr/inputs/image-crop.js +1 -1
- package/dist/ssr/inputs/image-crop.js.map +1 -1
- package/dist/ssr/inputs/image-tools.js +4 -0
- package/dist/ssr/inputs/image-tools.js.map +1 -0
- package/dist/ssr/inputs/input-messages.js +8 -2
- package/dist/ssr/inputs/input-messages.js.map +1 -1
- package/dist/ssr/internal/field.js +2 -2
- package/dist/ssr/internal/field.js.map +1 -1
- package/dist/ssr/internal/renders-something.js +3 -0
- package/dist/ssr/internal/renders-something.js.map +1 -0
- package/dist/ssr/intl/messages.js +1 -1
- package/dist/ssr/intl/messages.js.map +1 -1
- package/dist/ssr/layout/AppWorkspace.js +16 -8
- package/dist/ssr/layout/AppWorkspace.js.map +1 -1
- package/dist/ssr/layout/Breadcrumbs.js +140 -26
- package/dist/ssr/layout/Breadcrumbs.js.map +1 -1
- package/dist/ssr/layout/DetailPanel.js +70 -68
- package/dist/ssr/layout/DetailPanel.js.map +1 -1
- package/dist/ssr/layout/FloatingPill.js +16 -0
- package/dist/ssr/layout/FloatingPill.js.map +1 -0
- package/dist/ssr/layout/PanelDialog.js +82 -8
- package/dist/ssr/layout/PanelDialog.js.map +1 -1
- package/dist/ssr/layout/StatusRow.js +93 -0
- package/dist/ssr/layout/StatusRow.js.map +1 -0
- package/dist/ssr/layout/app-workspace-controller.js +12 -5
- package/dist/ssr/layout/app-workspace-controller.js.map +1 -1
- package/dist/ssr/layout/app-workspace-state.js +2 -2
- package/dist/ssr/layout/app-workspace-state.js.map +1 -1
- package/dist/ssr/layout/index.js +2 -0
- package/dist/ssr/layout/index.js.map +1 -1
- package/dist/ssr/layout/panel-dialog-error.js +28 -0
- package/dist/ssr/layout/panel-dialog-error.js.map +1 -0
- package/dist/ssr/layout/panel-sheet-handle.js +66 -0
- package/dist/ssr/layout/panel-sheet-handle.js.map +1 -0
- package/dist/ssr/layout/workspace-messages.js +12 -2
- package/dist/ssr/layout/workspace-messages.js.map +1 -1
- package/dist/ssr/layout-check.js +232 -0
- package/dist/ssr/layout-check.js.map +1 -0
- package/dist/ssr/surfaces/Area.js +147 -0
- package/dist/ssr/surfaces/Area.js.map +1 -0
- package/dist/ssr/surfaces/FactGroup.js +106 -0
- package/dist/ssr/surfaces/FactGroup.js.map +1 -0
- package/dist/ssr/surfaces/FieldGrid.js +22 -0
- package/dist/ssr/surfaces/FieldGrid.js.map +1 -0
- package/dist/ssr/surfaces/NoticeCard.js +7 -5
- package/dist/ssr/surfaces/NoticeCard.js.map +1 -1
- package/dist/ssr/surfaces/Placeholder.js +15 -4
- package/dist/ssr/surfaces/Placeholder.js.map +1 -1
- package/dist/ssr/surfaces/RowGroup.js +60 -0
- package/dist/ssr/surfaces/RowGroup.js.map +1 -0
- package/dist/ssr/surfaces/Section.js +7 -4
- package/dist/ssr/surfaces/Section.js.map +1 -1
- package/dist/ssr/surfaces/StatusBadge.js +5 -1
- package/dist/ssr/surfaces/StatusBadge.js.map +1 -1
- package/dist/ssr/surfaces/flat-block-messages.js +37 -0
- package/dist/ssr/surfaces/flat-block-messages.js.map +1 -0
- package/dist/ssr/surfaces/index.js +4 -0
- package/dist/ssr/surfaces/index.js.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/actions/DragAndDrop.d.ts +17 -2
- package/dist/types/actions/DropOverlay.d.ts +46 -0
- package/dist/types/actions/Dropdown.d.ts +35 -1
- package/dist/types/actions/SortableList.d.ts +36 -6
- package/dist/types/actions/ViewTabs.d.ts +3 -2
- package/dist/types/actions/drag-and-drop-keyboard.d.ts +4 -0
- package/dist/types/actions/drag-and-drop-messages.d.ts +8 -10
- package/dist/types/actions/drag-and-drop.d.ts +62 -4
- package/dist/types/actions/drop-overlay-pages.d.ts +22 -0
- package/dist/types/actions/drop-overlay-view.d.ts +12 -0
- package/dist/types/actions/index.d.ts +9 -5
- package/dist/types/actions/menu-sheet-messages.d.ts +11 -0
- package/dist/types/actions/menu-sheet.d.ts +3 -1
- package/dist/types/actions/menu-submenu-panel.d.ts +27 -0
- package/dist/types/actions/preload-when-idle.d.ts +5 -0
- package/dist/types/actions/sortable-board.d.ts +69 -0
- package/dist/types/actions/sortable-keyboard.d.ts +7 -0
- package/dist/types/actions/sortable-list-messages.d.ts +10 -3
- package/dist/types/actions/sortable-place.d.ts +16 -0
- package/dist/types/chat/ChatDecision.d.ts +28 -4
- package/dist/types/chat/ChatDecisionField.d.ts +45 -0
- package/dist/types/chat/index.d.ts +1 -0
- package/dist/types/chat/types.d.ts +9 -0
- package/dist/types/chat-decision-field.d.ts +5 -0
- package/dist/types/content/DataTable.d.ts +19 -0
- package/dist/types/content/FileName.d.ts +23 -0
- package/dist/types/content/ProgressPath.d.ts +12 -6
- package/dist/types/content/TaskRow.d.ts +33 -0
- package/dist/types/content/index.d.ts +2 -0
- package/dist/types/content/progress-path-messages.d.ts +8 -0
- package/dist/types/feedback/dialog-core.d.ts +5 -0
- package/dist/types/feedback/dialog-foot.d.ts +9 -0
- package/dist/types/inputs/DatePicker.d.ts +3 -21
- package/dist/types/inputs/TextInput.d.ts +2 -0
- package/dist/types/inputs/date-picker-panel.d.ts +29 -0
- package/dist/types/inputs/image-tools.d.ts +1 -0
- package/dist/types/inputs/input-messages.d.ts +4 -1
- package/dist/types/internal/renders-something.d.ts +2 -0
- package/dist/types/layout/AppWorkspace.d.ts +10 -2
- package/dist/types/layout/Breadcrumbs.d.ts +10 -5
- package/dist/types/layout/FloatingPill.d.ts +20 -0
- package/dist/types/layout/PanelDialog.d.ts +19 -0
- package/dist/types/layout/StatusRow.d.ts +54 -0
- package/dist/types/layout/app-workspace-state.d.ts +2 -2
- package/dist/types/layout/index.d.ts +5 -1
- package/dist/types/layout/panel-dialog-error.d.ts +9 -0
- package/dist/types/layout/panel-sheet-handle.d.ts +8 -0
- package/dist/types/layout/workspace-messages.d.ts +5 -0
- package/dist/types/layout-check.d.ts +52 -0
- package/dist/types/surfaces/Area.d.ts +38 -0
- package/dist/types/surfaces/FactGroup.d.ts +33 -0
- package/dist/types/surfaces/FieldGrid.d.ts +14 -0
- package/dist/types/surfaces/NoticeCard.d.ts +6 -4
- package/dist/types/surfaces/Placeholder.d.ts +7 -0
- package/dist/types/surfaces/RowGroup.d.ts +20 -0
- package/dist/types/surfaces/Section.d.ts +8 -2
- package/dist/types/surfaces/StatusBadge.d.ts +2 -1
- package/dist/types/surfaces/flat-block-messages.d.ts +16 -0
- package/dist/types/surfaces/index.d.ts +9 -1
- package/package.json +13 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["inputs/TextInput.tsx"],"sourcesContent":["import { createSignal, type JSX, Show, splitProps } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { createFieldMeta, Field, fieldControlAria, fieldDescribedBy } from \"../internal/field\";\nimport { useUiMessages } from \"../intl/messages\";\nimport type { Completion } from \"./completion\";\nimport type { FieldSuggestionProps, ValueFieldProps } from \"./field-contract\";\nimport { commitFieldValue, resolveMaybeAccessor } from \"./field-contract\";\nimport { useFieldSuggestion } from \"./field-suggestion-slot\";\nimport { useInputMessages } from \"./input-messages\";\nimport { MarkdownEditor } from \"./markdown/MarkdownEditor\";\n\nexport type TextInputProps = Omit<\n JSX.InputHTMLAttributes<HTMLInputElement>,\n \"onChange\" | \"onInput\" | \"onKeyDown\" | \"prefix\" | \"suffix\" | \"type\" | \"value\" | keyof ValueFieldProps<string>\n> &\n ValueFieldProps<string> &\n /** Suggestions apply to text and multiline fields, not to `markdown`. */\n FieldSuggestionProps<string> & {\n minLength?: number;\n maxLength?: number;\n type?: \"text\" | \"search\" | \"email\" | \"url\" | \"tel\";\n variant?: \"default\" | \"ai\" | \"compact\";\n /** A leading icon such as a search magnifier. Plain text fields have none. */\n icon?: string | false;\n activeIcon?: string;\n /** ID of a consumer-owned visible error; caller owns its announcement. Native controls only. */\n externalErrorId?: string;\n prefix?: JSX.Element;\n suffix?: JSX.Element;\n clearable?: boolean;\n onClear?: () => void;\n clearLabel?: string;\n multiline?: boolean;\n monospace?: boolean;\n password?: boolean;\n markdown?: boolean;\n onSubmit?: () => void;\n onKeyDown?: JSX.EventHandlerUnion<HTMLInputElement | HTMLTextAreaElement, KeyboardEvent>;\n lines?: number;\n abbreviations?: Record<string, string>;\n completions?: readonly Completion[];\n };\n\nexport function TextInput(props: TextInputProps): JSX.Element {\n const messages = useUiMessages();\n const inputMessages = useInputMessages();\n const [local, rest] = splitProps(props, [\n \"activeIcon\",\n \"aria-describedby\",\n \"aria-label\",\n \"class\",\n \"clearLabel\",\n \"clearable\",\n \"completions\",\n \"description\",\n \"error\",\n \"externalErrorId\",\n \"icon\",\n \"id\",\n \"label\",\n \"lines\",\n \"markdown\",\n \"minLength\",\n \"maxLength\",\n \"onKeyDown\",\n \"monospace\",\n \"multiline\",\n \"onClear\",\n \"onValueCommit\",\n \"onSubmit\",\n \"onSuggestionAccept\",\n \"onValueChange\",\n \"password\",\n \"prefix\",\n \"required\",\n \"suffix\",\n \"suggestion\",\n \"type\",\n \"value\",\n \"variant\",\n \"abbreviations\",\n ]);\n const meta = createFieldMeta(local.id);\n const value = () => resolveMaybeAccessor(local.value) ?? \"\";\n const error = () => resolveMaybeAccessor(local.error);\n const suggestion = useFieldSuggestion({ props, enabled: !props.markdown, meta, value });\n // HTML IDs are single nonempty tokens; numeric starts and punctuation are valid.\n const externalErrorId = () => {\n const id = local.externalErrorId;\n return id && !/[\\t\\n\\f\\r ]/.test(id) ? id : undefined;\n };\n const controlMeta = {\n ...meta,\n get errorId() {\n return externalErrorId() ?? meta.errorId;\n },\n };\n const [passwordVisible, setPasswordVisible] = createSignal(false);\n const multiline = () => Boolean(local.multiline || local.markdown);\n const compact = () => local.variant === \"compact\";\n // The field's edge already shows where to type; only a meaningful icon (a search magnifier, the AI mark) leads.\n const icon = () => (local.icon === false ? \"\" : (local.icon ?? (local.variant === \"ai\" ? \"ti ti-sparkles\" : \"\")));\n // An icon stays while typing unless `activeIcon` names a different one.\n const activeIcon = () => local.activeIcon ?? icon();\n // Names, addresses and passwords are typed exactly: phone keyboards must not capitalize or \"correct\" them.\n const verbatim = () =>\n local.password || local.type === \"email\" || local.type === \"url\" || /\\b(username|email|url)\\b/.test(String(rest.autocomplete ?? \"\"));\n const input = (next: string) => local.onValueChange?.(next);\n const commit = (next: string) => local.onValueCommit?.(next);\n const submitOnEnter = (event: KeyboardEvent) => {\n if (local.onSubmit && event.key === \"Enter\" && !event.shiftKey && !event.metaKey) {\n event.preventDefault();\n local.onSubmit();\n }\n };\n /** The caller's key handler runs first; Enter submits unless it handled the key. */\n const keyDown: JSX.EventHandler<HTMLInputElement | HTMLTextAreaElement, KeyboardEvent> = (event) => {\n const handler = local.onKeyDown;\n if (typeof handler === \"function\") handler(event);\n else if (Array.isArray(handler)) handler[0](handler[1], event);\n if (!event.defaultPrevented) submitOnEnter(event);\n };\n const clear: JSX.EventHandler<HTMLButtonElement, MouseEvent> = (event) => {\n // Clearing removes the button. Return to the field before notifying the caller, whose handler\n // may deliberately navigate or move focus somewhere else.\n event.currentTarget.ownerDocument.getElementById(meta.controlId)?.focus();\n if (local.onClear) {\n local.onClear();\n return;\n }\n commitFieldValue(local, \"\");\n };\n\n return (\n <Show\n when={local.markdown}\n fallback={\n <Field\n class={suggestion.field(local.class)}\n label={local.label}\n description={local.description}\n error={externalErrorId() ? undefined : error()}\n meta={meta}\n required={local.required}\n disabled={rest.disabled}\n labelEnd={suggestion.status}\n >\n {suggestion.under(\n <div\n class=\"k2b-input-shell k2b-text-input\"\n data-variant={compact() ? \"compact\" : undefined}\n data-invalid={error() ? \"true\" : undefined}\n data-ai={local.variant === \"ai\" ? \"true\" : undefined}\n data-multiline={multiline() ? \"true\" : undefined}\n data-monospace={local.monospace ? \"true\" : undefined}\n style={multiline() ? { \"--k2b-editor-lines\": String(local.lines ?? 3) } : undefined}\n >\n <Show when={!compact() && icon()}>\n <span class=\"k2b-input-shell__icon k2b-text-input__icon\" aria-hidden=\"true\">\n <i class={icon()} />\n <i class={activeIcon()} />\n </span>\n </Show>\n <Show when={local.prefix}>\n <span class=\"k2b-input-shell__affix\">{local.prefix}</span>\n </Show>\n <Show\n when={multiline()}\n fallback={\n <input\n autocapitalize={verbatim() ? \"none\" : undefined}\n autocorrect={verbatim() ? \"off\" : undefined}\n spellcheck={verbatim() ? false : undefined}\n {...rest}\n id={meta.controlId}\n class=\"k2b-input\"\n size={rest.size ?? (compact() ? 9 : undefined)}\n type={local.password && !passwordVisible() ? \"password\" : (local.type ?? \"text\")}\n value={value()}\n placeholder={suggestion.placeholder() ?? rest.placeholder}\n minlength={local.minLength}\n maxlength={local.maxLength}\n required={local.required}\n {...fieldControlAria(controlMeta, local)}\n aria-describedby={suggestion.describe(fieldDescribedBy(controlMeta, local))}\n onInput={(event) => {\n input(event.currentTarget.value);\n }}\n onChange={(event) => commit(event.currentTarget.value)}\n onKeyDown={keyDown}\n />\n }\n >\n <textarea\n {...(rest as unknown as JSX.TextareaHTMLAttributes<HTMLTextAreaElement>)}\n id={meta.controlId}\n class=\"k2b-input k2b-text-input__textarea\"\n value={value()}\n placeholder={suggestion.placeholder() ?? rest.placeholder}\n rows={local.lines ?? 3}\n required={local.required}\n minlength={local.minLength}\n maxlength={local.maxLength}\n {...fieldControlAria(controlMeta, local)}\n aria-describedby={suggestion.describe(fieldDescribedBy(controlMeta, local))}\n onInput={(event) => {\n input(event.currentTarget.value);\n }}\n onChange={(event) => commit(event.currentTarget.value)}\n onKeyDown={keyDown}\n >\n {/* HTML consumes one leading newline in textarea content. */}\n {isServer ? `\\n${value()}` : undefined}\n </textarea>\n </Show>\n <Show when={local.suffix}>\n <span class=\"k2b-input-shell__affix\">{local.suffix}</span>\n </Show>\n <Show when={local.clearable && value() && !multiline() && !local.password && !rest.disabled && !rest.readOnly}>\n <button\n type=\"button\"\n class=\"k2b-input-shell__clear k2b-input-clear-action\"\n aria-label={local.clearLabel ?? messages().clear}\n onClick={clear}\n >\n <i class=\"ti ti-x\" aria-hidden=\"true\" />\n </button>\n </Show>\n <Show when={local.password && !multiline()}>\n <button\n type=\"button\"\n class=\"k2b-input-shell__clear\"\n aria-label={passwordVisible() ? inputMessages().hidePassword : inputMessages().showPassword}\n aria-pressed={passwordVisible()}\n disabled={rest.disabled}\n onClick={() => setPasswordVisible((visible) => !visible)}\n >\n <i class={passwordVisible() ? \"ti ti-eye-off\" : \"ti ti-eye\"} aria-hidden=\"true\" />\n </button>\n </Show>\n </div>,\n )}\n </Field>\n }\n >\n <MarkdownEditor\n class={local.class}\n label={local.label}\n description={local.description}\n error={error()}\n id={meta.controlId}\n name={rest.name}\n value={value()}\n onValueChange={input}\n onValueCommit={local.onValueCommit}\n onSubmit={local.onSubmit}\n placeholder={rest.placeholder}\n disabled={rest.disabled}\n required={local.required}\n lines={local.lines}\n maxLength={local.maxLength}\n spellcheck={rest.spellcheck === undefined ? undefined : rest.spellcheck === true || rest.spellcheck === \"true\"}\n abbreviations={local.abbreviations}\n completions={local.completions}\n aria-label={local[\"aria-label\"]}\n aria-describedby={local[\"aria-describedby\"]}\n />\n </Show>\n );\n}\n\nexport default TextInput;\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,YAAY,EAAY,IAAI,EAAE,UAAU,QAAQ,UAAU;AACnE,SAAS,QAAQ,QAAQ,cAAc;AACvC,SAAS,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,QAAQ,mBAAmB;AAC9F,SAAS,aAAa,QAAQ,kBAAkB;AAGhD,SAAS,gBAAgB,EAAE,oBAAoB,QAAQ,kBAAkB;AACzE,SAAS,kBAAkB,QAAQ,yBAAyB;AAC5D,SAAS,gBAAgB,QAAQ,kBAAkB;AACnD,SAAS,cAAc,QAAQ,2BAA2B;AAkC1D,OAAO,SAAS,SAAS,CAAC,KAAqB,EAAe;EAC5D,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC;EAChC,MAAM,aAAa,GAAG,gBAAgB,CAAC,CAAC;EACxC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,UAAU,CAAC,KAAK,EAAE,CACtC,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,WAAW,EACX,aAAa,EACb,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,MAAM,EACN,IAAI,EACJ,OAAO,EACP,OAAO,EACP,UAAU,EACV,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACX,WAAW,EACX,SAAS,EACT,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,YAAY,E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G,aAAa;UAAA,OAAE,KAAK,CAAC,aAAa;QAAA;QAAA,IAClC,WAAW;UAAA,OAAE,KAAK,CAAC,WAAW;QAAA;QAAA;UAAA,OAClB,KAAK,CAAC,YAAY,CAAC;QAAA;QAAA;UAAA,OACb,KAAK,CAAC,kBAAkB,CAAC;QAAA;MAAA;IAAA;EAAA;AAInD;AAEA,eAAe,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["inputs/TextInput.tsx"],"sourcesContent":["import { createSignal, type JSX, Show, splitProps } from \"solid-js\";\nimport { isServer } from \"solid-js/web\";\nimport { createFieldMeta, Field, fieldControlAria, fieldDescribedBy } from \"../internal/field\";\nimport { useUiMessages } from \"../intl/messages\";\nimport type { Completion } from \"./completion\";\nimport type { FieldSuggestionProps, ValueFieldProps } from \"./field-contract\";\nimport { commitFieldValue, resolveMaybeAccessor } from \"./field-contract\";\nimport { useFieldSuggestion } from \"./field-suggestion-slot\";\nimport { useInputMessages } from \"./input-messages\";\nimport { MarkdownEditor } from \"./markdown/MarkdownEditor\";\n\nexport type TextInputProps = Omit<\n JSX.InputHTMLAttributes<HTMLInputElement>,\n \"onChange\" | \"onInput\" | \"onKeyDown\" | \"prefix\" | \"suffix\" | \"type\" | \"value\" | keyof ValueFieldProps<string>\n> &\n ValueFieldProps<string> &\n /** Suggestions apply to text and multiline fields, not to `markdown`. */\n FieldSuggestionProps<string> & {\n minLength?: number;\n maxLength?: number;\n type?: \"text\" | \"search\" | \"email\" | \"url\" | \"tel\";\n variant?: \"default\" | \"ai\" | \"compact\";\n /** A leading icon such as a search magnifier. Plain text fields have none. */\n icon?: string | false;\n activeIcon?: string;\n /** ID of a consumer-owned visible error; caller owns its announcement. Native controls only. */\n externalErrorId?: string;\n prefix?: JSX.Element;\n suffix?: JSX.Element;\n clearable?: boolean;\n onClear?: () => void;\n clearLabel?: string;\n multiline?: boolean;\n monospace?: boolean;\n password?: boolean;\n /** The eye's fixed name in a `password` field, such as \"Show key\"; `aria-pressed` tells whether the value shows. */\n revealLabel?: string;\n markdown?: boolean;\n onSubmit?: () => void;\n onKeyDown?: JSX.EventHandlerUnion<HTMLInputElement | HTMLTextAreaElement, KeyboardEvent>;\n lines?: number;\n abbreviations?: Record<string, string>;\n completions?: readonly Completion[];\n };\n\nexport function TextInput(props: TextInputProps): JSX.Element {\n const messages = useUiMessages();\n const inputMessages = useInputMessages();\n const [local, rest] = splitProps(props, [\n \"activeIcon\",\n \"aria-describedby\",\n \"aria-label\",\n \"class\",\n \"clearLabel\",\n \"clearable\",\n \"completions\",\n \"description\",\n \"error\",\n \"externalErrorId\",\n \"icon\",\n \"id\",\n \"label\",\n \"lines\",\n \"markdown\",\n \"minLength\",\n \"maxLength\",\n \"onKeyDown\",\n \"monospace\",\n \"multiline\",\n \"onClear\",\n \"onValueCommit\",\n \"onSubmit\",\n \"onSuggestionAccept\",\n \"onValueChange\",\n \"password\",\n \"prefix\",\n \"required\",\n \"revealLabel\",\n \"suffix\",\n \"suggestion\",\n \"type\",\n \"value\",\n \"variant\",\n \"abbreviations\",\n ]);\n const meta = createFieldMeta(local.id);\n const value = () => resolveMaybeAccessor(local.value) ?? \"\";\n const error = () => resolveMaybeAccessor(local.error);\n const suggestion = useFieldSuggestion({ props, enabled: !props.markdown, meta, value });\n // HTML IDs are single nonempty tokens; numeric starts and punctuation are valid.\n const externalErrorId = () => {\n const id = local.externalErrorId;\n return id && !/[\\t\\n\\f\\r ]/.test(id) ? id : undefined;\n };\n const controlMeta = {\n ...meta,\n get errorId() {\n return externalErrorId() ?? meta.errorId;\n },\n };\n const [passwordVisible, setPasswordVisible] = createSignal(false);\n const multiline = () => Boolean(local.multiline || local.markdown);\n const compact = () => local.variant === \"compact\";\n // The field's edge already shows where to type; only a meaningful icon (a search magnifier, the AI mark) leads.\n const icon = () => (local.icon === false ? \"\" : (local.icon ?? (local.variant === \"ai\" ? \"ti ti-sparkles\" : \"\")));\n // An icon stays while typing unless `activeIcon` names a different one.\n const activeIcon = () => local.activeIcon ?? icon();\n // Names, addresses and passwords are typed exactly: phone keyboards must not capitalize or \"correct\" them.\n const verbatim = () =>\n local.password || local.type === \"email\" || local.type === \"url\" || /\\b(username|email|url)\\b/.test(String(rest.autocomplete ?? \"\"));\n const input = (next: string) => local.onValueChange?.(next);\n const commit = (next: string) => local.onValueCommit?.(next);\n const submitOnEnter = (event: KeyboardEvent) => {\n if (local.onSubmit && event.key === \"Enter\" && !event.shiftKey && !event.metaKey) {\n event.preventDefault();\n local.onSubmit();\n }\n };\n /** The caller's key handler runs first; Enter submits unless it handled the key. */\n const keyDown: JSX.EventHandler<HTMLInputElement | HTMLTextAreaElement, KeyboardEvent> = (event) => {\n const handler = local.onKeyDown;\n if (typeof handler === \"function\") handler(event);\n else if (Array.isArray(handler)) handler[0](handler[1], event);\n if (!event.defaultPrevented) submitOnEnter(event);\n };\n const clear: JSX.EventHandler<HTMLButtonElement, MouseEvent> = (event) => {\n // Clearing removes the button. Return to the field before notifying the caller, whose handler\n // may deliberately navigate or move focus somewhere else.\n event.currentTarget.ownerDocument.getElementById(meta.controlId)?.focus();\n if (local.onClear) {\n local.onClear();\n return;\n }\n commitFieldValue(local, \"\");\n };\n\n return (\n <Show\n when={local.markdown}\n fallback={\n <Field\n class={suggestion.field(local.class)}\n label={local.label}\n description={local.description}\n error={externalErrorId() ? undefined : error()}\n meta={meta}\n required={local.required}\n disabled={rest.disabled}\n labelEnd={suggestion.status}\n >\n {suggestion.under(\n <div\n class=\"k2b-input-shell k2b-text-input\"\n data-variant={compact() ? \"compact\" : undefined}\n data-invalid={error() ? \"true\" : undefined}\n data-ai={local.variant === \"ai\" ? \"true\" : undefined}\n data-multiline={multiline() ? \"true\" : undefined}\n data-monospace={local.monospace ? \"true\" : undefined}\n style={multiline() ? { \"--k2b-editor-lines\": String(local.lines ?? 3) } : undefined}\n >\n <Show when={!compact() && icon()}>\n <span class=\"k2b-input-shell__icon k2b-text-input__icon\" aria-hidden=\"true\">\n <i class={icon()} />\n <i class={activeIcon()} />\n </span>\n </Show>\n <Show when={local.prefix}>\n <span class=\"k2b-input-shell__affix\">{local.prefix}</span>\n </Show>\n <Show\n when={multiline()}\n fallback={\n <input\n autocapitalize={verbatim() ? \"none\" : undefined}\n autocorrect={verbatim() ? \"off\" : undefined}\n spellcheck={verbatim() ? false : undefined}\n {...rest}\n id={meta.controlId}\n class=\"k2b-input\"\n size={rest.size ?? (compact() ? 9 : undefined)}\n type={local.password && !passwordVisible() ? \"password\" : (local.type ?? \"text\")}\n value={value()}\n placeholder={suggestion.placeholder() ?? rest.placeholder}\n minlength={local.minLength}\n maxlength={local.maxLength}\n required={local.required}\n {...fieldControlAria(controlMeta, local)}\n aria-describedby={suggestion.describe(fieldDescribedBy(controlMeta, local))}\n onInput={(event) => {\n input(event.currentTarget.value);\n }}\n onChange={(event) => commit(event.currentTarget.value)}\n onKeyDown={keyDown}\n />\n }\n >\n <textarea\n {...(rest as unknown as JSX.TextareaHTMLAttributes<HTMLTextAreaElement>)}\n id={meta.controlId}\n class=\"k2b-input k2b-text-input__textarea\"\n value={value()}\n placeholder={suggestion.placeholder() ?? rest.placeholder}\n rows={local.lines ?? 3}\n required={local.required}\n minlength={local.minLength}\n maxlength={local.maxLength}\n {...fieldControlAria(controlMeta, local)}\n aria-describedby={suggestion.describe(fieldDescribedBy(controlMeta, local))}\n onInput={(event) => {\n input(event.currentTarget.value);\n }}\n onChange={(event) => commit(event.currentTarget.value)}\n onKeyDown={keyDown}\n >\n {/* HTML consumes one leading newline in textarea content. */}\n {isServer ? `\\n${value()}` : undefined}\n </textarea>\n </Show>\n <Show when={local.suffix}>\n <span class=\"k2b-input-shell__affix\">{local.suffix}</span>\n </Show>\n <Show when={local.clearable && value() && !multiline() && !local.password && !rest.disabled && !rest.readOnly}>\n <button\n type=\"button\"\n class=\"k2b-input-shell__clear k2b-input-clear-action\"\n aria-label={local.clearLabel ?? messages().clear}\n onClick={clear}\n >\n <i class=\"ti ti-x\" aria-hidden=\"true\" />\n </button>\n </Show>\n <Show when={local.password && !multiline()}>\n {/* A toggle keeps one name; `aria-pressed` says whether the value shows. */}\n <button\n type=\"button\"\n class=\"k2b-input-shell__clear k2b-input-shell__reveal\"\n aria-label={local.revealLabel ?? inputMessages().showPassword}\n aria-pressed={passwordVisible()}\n disabled={rest.disabled}\n onClick={() => setPasswordVisible((visible) => !visible)}\n >\n <i class={passwordVisible() ? \"ti ti-eye-off\" : \"ti ti-eye\"} aria-hidden=\"true\" />\n </button>\n </Show>\n </div>,\n )}\n </Field>\n }\n >\n <MarkdownEditor\n class={local.class}\n label={local.label}\n description={local.description}\n error={error()}\n id={meta.controlId}\n name={rest.name}\n value={value()}\n onValueChange={input}\n onValueCommit={local.onValueCommit}\n onSubmit={local.onSubmit}\n placeholder={rest.placeholder}\n disabled={rest.disabled}\n required={local.required}\n lines={local.lines}\n maxLength={local.maxLength}\n spellcheck={rest.spellcheck === undefined ? undefined : rest.spellcheck === true || rest.spellcheck === \"true\"}\n abbreviations={local.abbreviations}\n completions={local.completions}\n aria-label={local[\"aria-label\"]}\n aria-describedby={local[\"aria-describedby\"]}\n />\n </Show>\n );\n}\n\nexport default TextInput;\n"],"mappings":";;;;;;;;;;;;;AAAA,SAAS,YAAY,EAAY,IAAI,EAAE,UAAU,QAAQ,UAAU;AACnE,SAAS,QAAQ,QAAQ,cAAc;AACvC,SAAS,eAAe,EAAE,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,QAAQ,mBAAmB;AAC9F,SAAS,aAAa,QAAQ,kBAAkB;AAGhD,SAAS,gBAAgB,EAAE,oBAAoB,QAAQ,kBAAkB;AACzE,SAAS,kBAAkB,QAAQ,yBAAyB;AAC5D,SAAS,gBAAgB,QAAQ,kBAAkB;AACnD,SAAS,cAAc,QAAQ,2BAA2B;AAoC1D,OAAO,SAAS,SAAS,CAAC,KAAqB,EAAe;EAC5D,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC;EAChC,MAAM,aAAa,GAAG,gBAAgB,CAAC,CAAC;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AAA;QAAA,IAC7B,QAAQ;UAAA,OAAE,IAAI,CAAC,QAAQ;QAAA;QAAA,IACvB,QAAQ;UAAA,OAAE,KAAK,CAAC,QAAQ;QAAA;QAAA,IACxB,KAAK;UAAA,OAAE,KAAK,CAAC,KAAK;QAAA;QAAA,IAClB,SAAS;UAAA,OAAE,KAAK,CAAC,SAAS;QAAA;QAAA,IAC1B,UAAU;UAAA,OAAE,iBAAI,CAAC,UAAU,KAAK,SAAS,MAAG,SAAS,GAAG,IAAI,CAAC,UAAU,KAAK,IAAI,IAAI,IAAI,CAAC,UAAU,KAAK,MAAM;QAAA;QAAA,IAC9G,aAAa;UAAA,OAAE,KAAK,CAAC,aAAa;QAAA;QAAA,IAClC,WAAW;UAAA,OAAE,KAAK,CAAC,WAAW;QAAA;QAAA;UAAA,OAClB,KAAK,CAAC,YAAY,CAAC;QAAA;QAAA;UAAA,OACb,KAAK,CAAC,kBAAkB,CAAC;QAAA;MAAA;IAAA;EAAA;AAInD;AAEA,eAAe,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
import { ssrStyleProperty as _$ssrStyleProperty } from "solid-js/web";
|
|
2
|
+
import { memo as _$memo } from "solid-js/web";
|
|
3
|
+
import { ssr as _$ssr } from "solid-js/web";
|
|
4
|
+
import { createComponent as _$createComponent } from "solid-js/web";
|
|
5
|
+
import { ssrAttribute as _$ssrAttribute } from "solid-js/web";
|
|
6
|
+
import { escape as _$escape } from "solid-js/web";
|
|
7
|
+
var _tmpl$ = ["<div class=\"k2b-date-weekdays\" aria-hidden=\"true\">", "", "</div>"],
|
|
8
|
+
_tmpl$2 = ["<div class=\"k2b-date-grid\" role=\"grid\">", "", "</div>"],
|
|
9
|
+
_tmpl$3 = ["<footer class=\"k2b-date-calendar__limits\"><span>", "</span><span>", "</span></footer>"],
|
|
10
|
+
_tmpl$4 = ["<section class=\"k2b-date-calendar\"", "><header class=\"k2b-date-calendar__header\"><button type=\"button\" class=\"k2b-date-calendar__nav\"", "", "><i class=\"ti ti-chevron-left\" aria-hidden=\"true\"></i></button><button type=\"button\" class=\"k2b-date-calendar__title\">", "</button><button type=\"button\" class=\"k2b-date-calendar__nav\"", "", "><i class=\"ti ti-chevron-right\" aria-hidden=\"true\"></i></button></header>", "", "</section>"],
|
|
11
|
+
_tmpl$5 = ["<div class=\"k2b-date-months\" role=\"group\" aria-label=\"", "\">", "</div>"],
|
|
12
|
+
_tmpl$6 = ["<button type=\"button\"", ">", "</button>"],
|
|
13
|
+
_tmpl$7 = ["<span class=\"k2b-date-weekend\" style=\"", "\"></span>"],
|
|
14
|
+
_tmpl$8 = ["<span", ">", "</span>"],
|
|
15
|
+
_tmpl$9 = ["<span class=\"k2b-date-weekend\" aria-hidden=\"true\" style=\"", "\"></span>"],
|
|
16
|
+
_tmpl$0 = ["<div class=\"k2b-date-week\" role=\"row\"", ">", "</div>"],
|
|
17
|
+
_tmpl$1 = ["<button type=\"button\" role=\"gridcell\"", "", ">", "</button>"];
|
|
18
|
+
import { dates } from "@k2b/stdlib";
|
|
19
|
+
import { createEffect, createMemo, createSignal, For, onCleanup, onMount, Show } from "solid-js";
|
|
20
|
+
import { resolveUiMessages, useUiMessages } from "../intl/messages";
|
|
21
|
+
import { isWeekendKey } from "../intl/weekend";
|
|
22
|
+
import { formatDateInput } from "./date-input";
|
|
23
|
+
import { resolveDateInputMessages } from "./date-input-messages";
|
|
24
|
+
import { dateKey, inRange, isRangeEdge, monthDate, monthNames, msUntilNextDay, pickerContext, resolveFocusDay, weekendBands, yearMonth } from "./date-picker";
|
|
25
|
+
/**
|
|
26
|
+
* One month of days, with the year and month views. It loads when a date field first shows in the browser, so a page
|
|
27
|
+
* that renders a date field carries only the field up front (the packed consumer budget); the period picker and the
|
|
28
|
+
* phone sheet use it too.
|
|
29
|
+
*/
|
|
30
|
+
export function DatePickerPanel(props) {
|
|
31
|
+
const messages = useUiMessages();
|
|
32
|
+
const [view, setView] = createSignal("days");
|
|
33
|
+
const context = createMemo(() => pickerContext(props.dateConfig));
|
|
34
|
+
const month = createMemo(() => yearMonth(props.visibleMonth(), context()));
|
|
35
|
+
// Always six weeks: typing moves an open calendar between months, and a month with fewer weeks would resize it.
|
|
36
|
+
const weeks = createMemo(() => {
|
|
37
|
+
const grid = [...dates.getMonthGrid(month().year, month().month, context())];
|
|
38
|
+
while (grid.length < 6) {
|
|
39
|
+
const last = grid[grid.length - 1].at(-1);
|
|
40
|
+
grid.push(Array.from({
|
|
41
|
+
length: 7
|
|
42
|
+
}, (_, index) => dates.addDays(last, index + 1, context())));
|
|
43
|
+
}
|
|
44
|
+
return grid;
|
|
45
|
+
});
|
|
46
|
+
const blocked = key => Boolean(props.min && key < props.min || props.max && key > props.max);
|
|
47
|
+
const inputMessages = createMemo(() => resolveDateInputMessages(context().locale));
|
|
48
|
+
const weekdays = createMemo(() => dates.weekdays(context()));
|
|
49
|
+
const months = createMemo(() => monthNames(context()));
|
|
50
|
+
const dayNameFormatter = createMemo(() => new Intl.DateTimeFormat(context().locale, {
|
|
51
|
+
weekday: "long",
|
|
52
|
+
year: "numeric",
|
|
53
|
+
month: "long",
|
|
54
|
+
day: "numeric",
|
|
55
|
+
timeZone: context().timeZone
|
|
56
|
+
}));
|
|
57
|
+
const dayRows = createMemo(() => {
|
|
58
|
+
const visibleMonth = props.visibleMonth();
|
|
59
|
+
const dateContext = context();
|
|
60
|
+
const formatter = dayNameFormatter();
|
|
61
|
+
return weeks().map(week => week.map(day => ({
|
|
62
|
+
day,
|
|
63
|
+
key: dates.formatDateKey(day, dateContext),
|
|
64
|
+
outside: !dates.isSameMonth(day, visibleMonth, dateContext),
|
|
65
|
+
label: formatter.format(day),
|
|
66
|
+
number: dates.formatDayNumber(day, dateContext)
|
|
67
|
+
})));
|
|
68
|
+
});
|
|
69
|
+
// Today in the picker's time zone, the zone its values use. The browser reads
|
|
70
|
+
// the clock again at the next midnight there, when a hidden tab becomes visible
|
|
71
|
+
// again (timers may not fire on time while the device sleeps), and when the
|
|
72
|
+
// date config changes. The mark and its timer share each reading, so neither
|
|
73
|
+
// starts from an old one.
|
|
74
|
+
const [clockCheck, checkClock] = createSignal(undefined, {
|
|
75
|
+
equals: false
|
|
76
|
+
});
|
|
77
|
+
const now = createMemo(() => {
|
|
78
|
+
clockCheck();
|
|
79
|
+
context();
|
|
80
|
+
return new Date();
|
|
81
|
+
});
|
|
82
|
+
const todayKey = createMemo(() => dateKey(now(), context()));
|
|
83
|
+
// The day's name is formatted in the date locale, so "today" joins it in the same language.
|
|
84
|
+
const todayLabel = date => resolveUiMessages(context().locale).todayDate({
|
|
85
|
+
date
|
|
86
|
+
});
|
|
87
|
+
createEffect(() => {
|
|
88
|
+
const timer = window.setTimeout(() => checkClock(), msUntilNextDay(now(), context()));
|
|
89
|
+
onCleanup(() => window.clearTimeout(timer));
|
|
90
|
+
});
|
|
91
|
+
onMount(() => {
|
|
92
|
+
const refresh = () => {
|
|
93
|
+
if (document.visibilityState === "visible") checkClock();
|
|
94
|
+
};
|
|
95
|
+
document.addEventListener("visibilitychange", refresh);
|
|
96
|
+
onCleanup(() => document.removeEventListener("visibilitychange", refresh));
|
|
97
|
+
});
|
|
98
|
+
// The weekend columns of the locale, read from the first week so they follow the grid's first day of the week.
|
|
99
|
+
const weekendColumns = createMemo(() => (dayRows()[0] ?? []).map(cell => isWeekendKey(cell.key, context().locale)));
|
|
100
|
+
const bands = createMemo(() => weekendBands(weekendColumns()));
|
|
101
|
+
let calendar;
|
|
102
|
+
// Days that belong to the visible month; the roving tabindex must land on one
|
|
103
|
+
// of them or the grid becomes unreachable by keyboard after month navigation.
|
|
104
|
+
const monthDayKeys = createMemo(() => dayRows().flat().filter(day => !day.outside && !blocked(day.key)).map(day => day.key));
|
|
105
|
+
// Remembers where arrow-key navigation left off so Tab returns to that day.
|
|
106
|
+
const [focusedKey, setFocusedKey] = createSignal();
|
|
107
|
+
const defaultFocus = createMemo(() => resolveFocusDay(monthDayKeys(), focusedKey() || props.focusDate?.() || props.selected?.() || todayKey()));
|
|
108
|
+
const moveMonth = delta => props.setVisibleMonth(dates.addMonths(props.visibleMonth(), delta, context()));
|
|
109
|
+
const moveYear = delta => props.setVisibleMonth(monthDate(month().year + delta, month().month, context()));
|
|
110
|
+
const previousLabel = () => view() === "days" ? messages().previousMonth : messages().previousYear;
|
|
111
|
+
const nextLabel = () => view() === "days" ? messages().nextMonth : messages().nextYear;
|
|
112
|
+
// A step whose whole month (or year) lies outside min/max is not offered.
|
|
113
|
+
const stepBlocked = delta => {
|
|
114
|
+
if (view() === "days") {
|
|
115
|
+
const target = dateKey(dates.addMonths(props.visibleMonth(), delta, context()), context()).slice(0, 7);
|
|
116
|
+
return Boolean(props.min && target < props.min.slice(0, 7) || props.max && target > props.max.slice(0, 7));
|
|
117
|
+
}
|
|
118
|
+
const year = String(month().year + delta);
|
|
119
|
+
return Boolean(props.min && year < props.min.slice(0, 4) || props.max && year > props.max.slice(0, 4));
|
|
120
|
+
};
|
|
121
|
+
const focusDate = date => {
|
|
122
|
+
const targetKey = dateKey(date, context());
|
|
123
|
+
if (blocked(targetKey)) return;
|
|
124
|
+
const shown = props.isShown ? props.isShown(date) : dates.isSameMonth(date, props.visibleMonth(), context());
|
|
125
|
+
if (!shown) props.setVisibleMonth(date);
|
|
126
|
+
queueMicrotask(() => (props.focusRoot?.() ?? calendar)?.querySelector(`[data-date-day="${targetKey}"]:not([data-hidden="true"])`)?.focus());
|
|
127
|
+
};
|
|
128
|
+
const handleDayKeyDown = (event, day) => {
|
|
129
|
+
const deltas = {
|
|
130
|
+
ArrowLeft: -1,
|
|
131
|
+
ArrowRight: 1,
|
|
132
|
+
ArrowUp: -7,
|
|
133
|
+
ArrowDown: 7
|
|
134
|
+
};
|
|
135
|
+
const delta = deltas[event.key];
|
|
136
|
+
if (delta !== undefined) {
|
|
137
|
+
event.preventDefault();
|
|
138
|
+
focusDate(dates.addDays(day, delta, context()));
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (event.key === "PageUp" || event.key === "PageDown") {
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
focusDate(dates.addMonths(day, event.key === "PageUp" ? -1 : 1, context()));
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
if (event.key === "Home" || event.key === "End") {
|
|
147
|
+
event.preventDefault();
|
|
148
|
+
const buttons = Array.from(event.currentTarget.closest(".k2b-date-grid").querySelectorAll("[data-date-day]"));
|
|
149
|
+
const index = buttons.indexOf(event.currentTarget);
|
|
150
|
+
const offset = event.key === "Home" ? -(index % 7) : 6 - index % 7;
|
|
151
|
+
focusDate(dates.addDays(day, offset, context()));
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
return _$ssr(_tmpl$4, _$ssrAttribute("aria-label", _$escape(messages().calendar, true), false), _$ssrAttribute("data-hidden", props.nav === "next" ? "true" : _$escape(undefined, true), false), _$ssrAttribute("disabled", stepBlocked(-1), true) + _$ssrAttribute("aria-label", _$escape(previousLabel(), true), false), _$escape(_$createComponent(Show, {
|
|
155
|
+
get when() {
|
|
156
|
+
return view() === "days";
|
|
157
|
+
},
|
|
158
|
+
get fallback() {
|
|
159
|
+
return month().year;
|
|
160
|
+
},
|
|
161
|
+
get children() {
|
|
162
|
+
return dates.formatMonthYear(props.visibleMonth(), context());
|
|
163
|
+
}
|
|
164
|
+
})), _$ssrAttribute("data-hidden", props.nav === "previous" ? "true" : _$escape(undefined, true), false), _$ssrAttribute("disabled", stepBlocked(1), true) + _$ssrAttribute("aria-label", _$escape(nextLabel(), true), false), _$escape(_$createComponent(Show, {
|
|
165
|
+
get when() {
|
|
166
|
+
return view() === "days";
|
|
167
|
+
},
|
|
168
|
+
get fallback() {
|
|
169
|
+
return _$ssr(_tmpl$5, `Months in ${_$escape(month().year, true)}`, _$escape(_$createComponent(For, {
|
|
170
|
+
get each() {
|
|
171
|
+
return months();
|
|
172
|
+
},
|
|
173
|
+
children: (name, index) => _$ssr(_tmpl$6, _$ssrAttribute("aria-pressed", _$escape(index(), true) === _$escape(month().month, true), false) + _$ssrAttribute("data-selected", index() === month().month ? "true" : _$escape(undefined, true), false), _$escape(name))
|
|
174
|
+
})));
|
|
175
|
+
},
|
|
176
|
+
get children() {
|
|
177
|
+
return [_$ssr(_tmpl$, _$escape(_$createComponent(For, {
|
|
178
|
+
get each() {
|
|
179
|
+
return bands();
|
|
180
|
+
},
|
|
181
|
+
children: band => _$ssr(_tmpl$7, _$ssrStyleProperty("grid-column:", `${_$escape(band.start, true) + 1} / span ${_$escape(band.span, true)}`))
|
|
182
|
+
})), _$escape(_$createComponent(For, {
|
|
183
|
+
get each() {
|
|
184
|
+
return weekdays();
|
|
185
|
+
},
|
|
186
|
+
children: (day, index) => _$ssr(_tmpl$8, _$ssrAttribute("data-weekend", weekendColumns()[index()] ? "true" : _$escape(undefined, true), false), _$escape(day))
|
|
187
|
+
}))), _$ssr(_tmpl$2, _$escape(_$createComponent(For, {
|
|
188
|
+
get each() {
|
|
189
|
+
return bands();
|
|
190
|
+
},
|
|
191
|
+
children: band => _$ssr(_tmpl$9, _$ssrStyleProperty("grid-column:", `${_$escape(band.start, true) + 1} / span ${_$escape(band.span, true)}`) + _$ssrStyleProperty(";grid-row:", `1 / span ${_$escape(dayRows().length, true)}`))
|
|
192
|
+
})), _$escape(_$createComponent(For, {
|
|
193
|
+
get each() {
|
|
194
|
+
return dayRows();
|
|
195
|
+
},
|
|
196
|
+
children: week => // A week of a neighbouring month only, left empty beside a second month, is hidden as a whole.
|
|
197
|
+
_$ssr(_tmpl$0, _$ssrAttribute("aria-hidden", props.hideOutside && week.every(cell => cell.outside) ? "true" : _$escape(undefined, true), false), _$escape(_$createComponent(For, {
|
|
198
|
+
each: week,
|
|
199
|
+
children: (cell, cellIndex) => {
|
|
200
|
+
const selected = () => props.selected?.() === cell.key;
|
|
201
|
+
const range = () => props.range?.() ?? {
|
|
202
|
+
start: null,
|
|
203
|
+
end: null
|
|
204
|
+
};
|
|
205
|
+
const active = () => selected() || isRangeEdge(cell.key, range());
|
|
206
|
+
const focusable = () => cell.key === defaultFocus();
|
|
207
|
+
const today = () => cell.key === todayKey();
|
|
208
|
+
const hidden = () => Boolean(props.hideOutside && cell.outside);
|
|
209
|
+
const label = () => {
|
|
210
|
+
const name = today() ? todayLabel(cell.label) : cell.label;
|
|
211
|
+
return blocked(cell.key) ? inputMessages().notSelectable({
|
|
212
|
+
date: name
|
|
213
|
+
}) : name;
|
|
214
|
+
};
|
|
215
|
+
return _$ssr(_tmpl$1, _$ssrAttribute("data-date-day", _$escape(cell.key, true), false) + _$ssrAttribute("data-date-focus", focusable() ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-outside", cell.outside ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-hidden", hidden() ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-weekend", weekendColumns()[cellIndex()] ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-in-range", inRange(cell.key, range()) && !active() ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("data-today", today() ? "true" : _$escape(undefined, true), false) + _$ssrAttribute("aria-current", today() ? "date" : _$escape(undefined, true), false) + _$ssrAttribute("aria-label", _$escape(label(), true), false) + _$ssrAttribute("aria-selected", _$escape(active(), true), false), _$ssrAttribute("disabled", blocked(cell.key), true) + _$ssrAttribute("tabindex", focusable() ? 0 : -1, false), _$escape(cell.number));
|
|
216
|
+
}
|
|
217
|
+
})))
|
|
218
|
+
})))];
|
|
219
|
+
}
|
|
220
|
+
})), _$escape(_$createComponent(Show, {
|
|
221
|
+
get when() {
|
|
222
|
+
return props.min || props.max;
|
|
223
|
+
},
|
|
224
|
+
get children() {
|
|
225
|
+
return _$ssr(_tmpl$3, props.min ? _$escape(inputMessages().limitFrom({
|
|
226
|
+
date: formatDateInput(props.min, context().locale)
|
|
227
|
+
})) : "", props.max ? _$escape(inputMessages().limitUntil({
|
|
228
|
+
date: formatDateInput(props.max, context().locale)
|
|
229
|
+
})) : "");
|
|
230
|
+
}
|
|
231
|
+
})));
|
|
232
|
+
}
|
|
233
|
+
//# sourceMappingURL=date-picker-panel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["inputs/date-picker-panel.tsx"],"sourcesContent":["import { type DateContext, dates } from \"@k2b/stdlib\";\nimport { createEffect, createMemo, createSignal, For, type JSX, onCleanup, onMount, Show } from \"solid-js\";\nimport { resolveUiMessages, useUiMessages } from \"../intl/messages\";\nimport { isWeekendKey } from \"../intl/weekend\";\nimport { formatDateInput } from \"./date-input\";\nimport { resolveDateInputMessages } from \"./date-input-messages\";\nimport {\n type DateRangeValue,\n dateKey,\n inRange,\n isRangeEdge,\n monthDate,\n monthNames,\n msUntilNextDay,\n pickerContext,\n resolveFocusDay,\n weekendBands,\n yearMonth,\n} from \"./date-picker\";\n\ntype PanelView = \"days\" | \"months\";\n\n/**\n * One month of days, with the year and month views. It loads when a date field first shows in the browser, so a page\n * that renders a date field carries only the field up front (the packed consumer budget); the period picker and the\n * phone sheet use it too.\n */\nexport function DatePickerPanel(props: {\n visibleMonth: () => Date;\n setVisibleMonth: (date: Date) => void;\n selected?: () => string | null | undefined;\n range?: () => DateRangeValue;\n focusDate?: () => string | null | undefined;\n onSelect: (date: string) => void;\n onDayPreview?: (date: string | null) => void;\n dateConfig?: DateContext;\n /** Earliest and latest selectable day as date keys. */\n min?: string;\n max?: string;\n /** Which month steps this panel offers; a second month beside it offers the other one. */\n nav?: \"both\" | \"previous\" | \"next\";\n /** Leaves the days of neighbouring months empty (`visibility: hidden`), so two months side by side never show a day twice. */\n hideOutside?: boolean;\n /** Whether a day is already on screen, also in a neighbouring panel; arrow keys then move there without paging. */\n isShown?: (date: Date) => boolean;\n /** Where keyboard navigation looks for the day to focus; the panel itself by default. */\n focusRoot?: () => HTMLElement | undefined;\n}): JSX.Element {\n const messages = useUiMessages();\n const [view, setView] = createSignal<PanelView>(\"days\");\n const context = createMemo(() => pickerContext(props.dateConfig));\n const month = createMemo(() => yearMonth(props.visibleMonth(), context()));\n // Always six weeks: typing moves an open calendar between months, and a month with fewer weeks would resize it.\n const weeks = createMemo(() => {\n const grid = [...dates.getMonthGrid(month().year, month().month, context())];\n while (grid.length < 6) {\n const last = grid[grid.length - 1]!.at(-1)!;\n grid.push(Array.from({ length: 7 }, (_, index) => dates.addDays(last, index + 1, context())));\n }\n return grid;\n });\n const blocked = (key: string) => Boolean((props.min && key < props.min) || (props.max && key > props.max));\n const inputMessages = createMemo(() => resolveDateInputMessages(context().locale));\n const weekdays = createMemo(() => dates.weekdays(context()));\n const months = createMemo(() => monthNames(context()));\n const dayNameFormatter = createMemo(\n () =>\n new Intl.DateTimeFormat(context().locale, {\n weekday: \"long\",\n year: \"numeric\",\n month: \"long\",\n day: \"numeric\",\n timeZone: context().timeZone,\n }),\n );\n const dayRows = createMemo(() => {\n const visibleMonth = props.visibleMonth();\n const dateContext = context();\n const formatter = dayNameFormatter();\n return weeks().map((week) =>\n week.map((day) => ({\n day,\n key: dates.formatDateKey(day, dateContext),\n outside: !dates.isSameMonth(day, visibleMonth, dateContext),\n label: formatter.format(day),\n number: dates.formatDayNumber(day, dateContext),\n })),\n );\n });\n // Today in the picker's time zone, the zone its values use. The browser reads\n // the clock again at the next midnight there, when a hidden tab becomes visible\n // again (timers may not fire on time while the device sleeps), and when the\n // date config changes. The mark and its timer share each reading, so neither\n // starts from an old one.\n const [clockCheck, checkClock] = createSignal<void>(undefined, { equals: false });\n const now = createMemo(() => {\n clockCheck();\n context();\n return new Date();\n });\n const todayKey = createMemo(() => dateKey(now(), context()));\n // The day's name is formatted in the date locale, so \"today\" joins it in the same language.\n const todayLabel = (date: string) => resolveUiMessages(context().locale).todayDate({ date });\n createEffect(() => {\n const timer = window.setTimeout(() => checkClock(), msUntilNextDay(now(), context()));\n onCleanup(() => window.clearTimeout(timer));\n });\n onMount(() => {\n const refresh = () => {\n if (document.visibilityState === \"visible\") checkClock();\n };\n document.addEventListener(\"visibilitychange\", refresh);\n onCleanup(() => document.removeEventListener(\"visibilitychange\", refresh));\n });\n // The weekend columns of the locale, read from the first week so they follow the grid's first day of the week.\n const weekendColumns = createMemo(() => (dayRows()[0] ?? []).map((cell) => isWeekendKey(cell.key, context().locale)));\n const bands = createMemo(() => weekendBands(weekendColumns()));\n let calendar: HTMLElement | undefined;\n // Days that belong to the visible month; the roving tabindex must land on one\n // of them or the grid becomes unreachable by keyboard after month navigation.\n const monthDayKeys = createMemo(() =>\n dayRows()\n .flat()\n .filter((day) => !day.outside && !blocked(day.key))\n .map((day) => day.key),\n );\n // Remembers where arrow-key navigation left off so Tab returns to that day.\n const [focusedKey, setFocusedKey] = createSignal<string>();\n const defaultFocus = createMemo(() =>\n resolveFocusDay(monthDayKeys(), focusedKey() || props.focusDate?.() || props.selected?.() || todayKey()),\n );\n\n const moveMonth = (delta: number) => props.setVisibleMonth(dates.addMonths(props.visibleMonth(), delta, context()));\n const moveYear = (delta: number) => props.setVisibleMonth(monthDate(month().year + delta, month().month, context()));\n const previousLabel = () => (view() === \"days\" ? messages().previousMonth : messages().previousYear);\n const nextLabel = () => (view() === \"days\" ? messages().nextMonth : messages().nextYear);\n // A step whose whole month (or year) lies outside min/max is not offered.\n const stepBlocked = (delta: number) => {\n if (view() === \"days\") {\n const target = dateKey(dates.addMonths(props.visibleMonth(), delta, context()), context()).slice(0, 7);\n return Boolean((props.min && target < props.min.slice(0, 7)) || (props.max && target > props.max.slice(0, 7)));\n }\n const year = String(month().year + delta);\n return Boolean((props.min && year < props.min.slice(0, 4)) || (props.max && year > props.max.slice(0, 4)));\n };\n\n const focusDate = (date: Date) => {\n const targetKey = dateKey(date, context());\n if (blocked(targetKey)) return;\n const shown = props.isShown ? props.isShown(date) : dates.isSameMonth(date, props.visibleMonth(), context());\n if (!shown) props.setVisibleMonth(date);\n queueMicrotask(() =>\n (props.focusRoot?.() ?? calendar)?.querySelector<HTMLElement>(`[data-date-day=\"${targetKey}\"]:not([data-hidden=\"true\"])`)?.focus(),\n );\n };\n\n const handleDayKeyDown = (event: KeyboardEvent, day: Date) => {\n const deltas: Partial<Record<string, number>> = { ArrowLeft: -1, ArrowRight: 1, ArrowUp: -7, ArrowDown: 7 };\n const delta = deltas[event.key];\n if (delta !== undefined) {\n event.preventDefault();\n focusDate(dates.addDays(day, delta, context()));\n return;\n }\n if (event.key === \"PageUp\" || event.key === \"PageDown\") {\n event.preventDefault();\n focusDate(dates.addMonths(day, event.key === \"PageUp\" ? -1 : 1, context()));\n return;\n }\n if (event.key === \"Home\" || event.key === \"End\") {\n event.preventDefault();\n const buttons = Array.from(\n (event.currentTarget as HTMLButtonElement).closest(\".k2b-date-grid\")!.querySelectorAll<HTMLButtonElement>(\"[data-date-day]\"),\n );\n const index = buttons.indexOf(event.currentTarget as HTMLButtonElement);\n const offset = event.key === \"Home\" ? -(index % 7) : 6 - (index % 7);\n focusDate(dates.addDays(day, offset, context()));\n }\n };\n\n return (\n <section ref={calendar} class=\"k2b-date-calendar\" aria-label={messages().calendar}>\n <header class=\"k2b-date-calendar__header\">\n <button\n type=\"button\"\n class=\"k2b-date-calendar__nav\"\n data-hidden={props.nav === \"next\" ? \"true\" : undefined}\n onClick={() => (view() === \"days\" ? moveMonth(-1) : moveYear(-1))}\n disabled={stepBlocked(-1)}\n aria-label={previousLabel()}\n >\n <i class=\"ti ti-chevron-left\" aria-hidden=\"true\" />\n </button>\n <button type=\"button\" class=\"k2b-date-calendar__title\" onClick={() => setView(view() === \"days\" ? \"months\" : \"days\")}>\n <Show when={view() === \"days\"} fallback={month().year}>\n {dates.formatMonthYear(props.visibleMonth(), context())}\n </Show>\n </button>\n <button\n type=\"button\"\n class=\"k2b-date-calendar__nav\"\n data-hidden={props.nav === \"previous\" ? \"true\" : undefined}\n onClick={() => (view() === \"days\" ? moveMonth(1) : moveYear(1))}\n disabled={stepBlocked(1)}\n aria-label={nextLabel()}\n >\n <i class=\"ti ti-chevron-right\" aria-hidden=\"true\" />\n </button>\n </header>\n\n <Show\n when={view() === \"days\"}\n fallback={\n <div class=\"k2b-date-months\" role=\"group\" aria-label={`Months in ${month().year}`}>\n <For each={months()}>\n {(name, index) => (\n <button\n type=\"button\"\n aria-pressed={index() === month().month}\n data-selected={index() === month().month ? \"true\" : undefined}\n onClick={() => {\n props.setVisibleMonth(monthDate(month().year, index(), context()));\n setView(\"days\");\n }}\n >\n {name}\n </button>\n )}\n </For>\n </div>\n }\n >\n {/* The weekend is a calm band behind its columns, from the weekday row through the last week. The band only\n paints a background, so it never moves a day. */}\n <div class=\"k2b-date-weekdays\" aria-hidden=\"true\">\n <For each={bands()}>\n {(band) => <span class=\"k2b-date-weekend\" style={{ \"grid-column\": `${band.start + 1} / span ${band.span}` }} />}\n </For>\n <For each={weekdays()}>{(day, index) => <span data-weekend={weekendColumns()[index()] ? \"true\" : undefined}>{day}</span>}</For>\n </div>\n <div class=\"k2b-date-grid\" role=\"grid\">\n <For each={bands()}>\n {(band) => (\n <span\n class=\"k2b-date-weekend\"\n aria-hidden=\"true\"\n style={{ \"grid-column\": `${band.start + 1} / span ${band.span}`, \"grid-row\": `1 / span ${dayRows().length}` }}\n />\n )}\n </For>\n <For each={dayRows()}>\n {(week) => (\n // A week of a neighbouring month only, left empty beside a second month, is hidden as a whole.\n <div\n class=\"k2b-date-week\"\n role=\"row\"\n aria-hidden={props.hideOutside && week.every((cell) => cell.outside) ? \"true\" : undefined}\n >\n <For each={week}>\n {(cell, cellIndex) => {\n const selected = () => props.selected?.() === cell.key;\n const range = () => props.range?.() ?? { start: null, end: null };\n const active = () => selected() || isRangeEdge(cell.key, range());\n const focusable = () => cell.key === defaultFocus();\n const today = () => cell.key === todayKey();\n const hidden = () => Boolean(props.hideOutside && cell.outside);\n const label = () => {\n const name = today() ? todayLabel(cell.label) : cell.label;\n return blocked(cell.key) ? inputMessages().notSelectable({ date: name }) : name;\n };\n return (\n <button\n type=\"button\"\n role=\"gridcell\"\n data-date-day={cell.key}\n data-date-focus={focusable() ? \"true\" : undefined}\n data-outside={cell.outside ? \"true\" : undefined}\n data-hidden={hidden() ? \"true\" : undefined}\n data-weekend={weekendColumns()[cellIndex()] ? \"true\" : undefined}\n data-in-range={inRange(cell.key, range()) && !active() ? \"true\" : undefined}\n data-today={today() ? \"true\" : undefined}\n aria-current={today() ? \"date\" : undefined}\n aria-label={label()}\n aria-selected={active()}\n disabled={blocked(cell.key)}\n tabIndex={focusable() ? 0 : -1}\n onClick={() => props.onSelect(cell.key)}\n onKeyDown={(event) => handleDayKeyDown(event, cell.day)}\n onBlur={() => props.onDayPreview?.(null)}\n onFocus={() => {\n setFocusedKey(cell.key);\n props.onDayPreview?.(cell.key);\n }}\n onPointerEnter={() => props.onDayPreview?.(cell.key)}\n onPointerLeave={() => props.onDayPreview?.(null)}\n >\n {cell.number}\n </button>\n );\n }}\n </For>\n </div>\n )}\n </For>\n </div>\n </Show>\n <Show when={props.min || props.max}>\n <footer class=\"k2b-date-calendar__limits\">\n <span>{props.min ? inputMessages().limitFrom({ date: formatDateInput(props.min, context().locale) }) : \"\"}</span>\n <span>{props.max ? inputMessages().limitUntil({ date: formatDateInput(props.max, context().locale) }) : \"\"}</span>\n </footer>\n </Show>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA,SAA2B,KAAK,QAAQ,aAAa;AACrD,SAAS,YAAY,EAAE,UAAU,EAAE,YAAY,EAAE,GAAG,EAAY,SAAS,EAAE,OAAO,EAAE,IAAI,QAAQ,UAAU;AAC1G,SAAS,iBAAiB,EAAE,aAAa,QAAQ,kBAAkB;AACnE,SAAS,YAAY,QAAQ,iBAAiB;AAC9C,SAAS,eAAe,QAAQ,cAAc;AAC9C,SAAS,wBAAwB,QAAQ,uBAAuB;AAChE,SAEE,OAAO,EACP,OAAO,EACP,WAAW,EACX,SAAS,EACT,UAAU,EACV,cAAc,EACd,aAAa,EACb,eAAe,EACf,YAAY,EACZ,SAAS,QACJ,eAAe;AAItB;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS,eAAe,CAAC,KAoB/B,EAAe;EACd,MAAM,QAAQ,GAA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,CAAC,SAAS,CAAC;QAAE,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM;MAAE,CAAC,CAAC,IAAG,EAAE,EAClG,KAAK,CAAC,GAAG,YAAG,aAAa,CAAC,CAAC,CAAC,UAAU,CAAC;QAAE,IAAI,EAAE,eAAe,CAAC,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM;MAAE,CAAC,CAAC,IAAG,EAAE;IAAA;EAAA;AAKpH","ignoreList":[]}
|
|
@@ -115,7 +115,7 @@ export const imageCropRectToPixels = (rect, imageSize) => {
|
|
|
115
115
|
const cropped = async (source, state, output) => {
|
|
116
116
|
const {
|
|
117
117
|
img
|
|
118
|
-
} = await import("
|
|
118
|
+
} = await import("./image-tools");
|
|
119
119
|
let data = await img.create(source);
|
|
120
120
|
if (state.rotation) data = await img.rotate(state.rotation)(data);
|
|
121
121
|
const crop = imageCropRectToPixels(state.crop, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["inputs/image-crop.ts"],"sourcesContent":["export type ImageCropAspect = \"free\" | { width: number; height: number };\nexport type ImageCropRotation = 0 | 90 | 180 | 270;\nexport type ImageCropRect = { x: number; y: number; width: number; height: number };\nexport type ImageCropState = { crop: ImageCropRect; rotation: ImageCropRotation };\nexport type ImageCropSource = File | Blob | HTMLImageElement | HTMLCanvasElement | string;\nexport type ImageCropOutput = {\n width?: number;\n height?: number;\n maxWidth?: number;\n maxHeight?: number;\n format?: \"webp\" | \"jpeg\" | \"png\";\n quality?: number;\n};\nexport type ImageCropSize = { width: number; height: number };\nexport type ImageCropResizeHandle = \"nw\" | \"ne\" | \"sw\" | \"se\";\n\nconst MIN_CROP_SIZE = 0.08;\nconst clamp = (value: number, min: number, max: number) => Math.max(min, Math.min(max, value));\nconst aspectRatio = (aspect: Exclude<ImageCropAspect, \"free\">) =>\n aspect.width > 0 && aspect.height > 0 ? aspect.width / aspect.height : 1;\n\nexport const normalizeImageCropRotation = (rotation: number): ImageCropRotation =>\n ((((Math.round(rotation / 90) * 90) % 360) + 360) % 360) as ImageCropRotation;\n\nexport const rotateImageCropRight = (rotation: ImageCropRotation): ImageCropRotation => normalizeImageCropRotation(rotation + 90);\n\nexport const getInitialImageCropRect = (imageSize: ImageCropSize, aspect: ImageCropAspect = \"free\"): ImageCropRect => {\n if (aspect === \"free\") return { x: 0.1, y: 0.1, width: 0.8, height: 0.8 };\n const target = aspectRatio(aspect);\n const source = imageSize.width > 0 && imageSize.height > 0 ? imageSize.width / imageSize.height : 1;\n let width = 0.86;\n let height = (width * source) / target;\n if (height > 0.86) {\n height = 0.86;\n width = (height * target) / source;\n }\n width = clamp(width, MIN_CROP_SIZE, 1);\n height = clamp(height, MIN_CROP_SIZE, 1);\n return { x: (1 - width) / 2, y: (1 - height) / 2, width, height };\n};\n\nexport const clampImageCropRect = (rect: ImageCropRect, imageSize: ImageCropSize, aspect: ImageCropAspect = \"free\"): ImageCropRect => {\n if (aspect === \"free\") {\n const width = clamp(rect.width, MIN_CROP_SIZE, 1);\n const height = clamp(rect.height, MIN_CROP_SIZE, 1);\n return { x: clamp(rect.x, 0, 1 - width), y: clamp(rect.y, 0, 1 - height), width, height };\n }\n const target = aspectRatio(aspect);\n const source = imageSize.width > 0 && imageSize.height > 0 ? imageSize.width / imageSize.height : 1;\n let width = clamp(rect.width, MIN_CROP_SIZE, 1);\n let height = (width * source) / target;\n if (height > 1) {\n height = 1;\n width = (height * target) / source;\n }\n return { x: clamp(rect.x, 0, 1 - width), y: clamp(rect.y, 0, 1 - height), width, height };\n};\n\nexport const resizeImageCropAroundCenter = (\n rect: ImageCropRect,\n imageSize: ImageCropSize,\n aspect: ImageCropAspect,\n scale: number,\n): ImageCropRect => {\n const safeScale = clamp(scale, 0.2, 5);\n const centerX = rect.x + rect.width / 2;\n const centerY = rect.y + rect.height / 2;\n const width = clamp(rect.width / safeScale, MIN_CROP_SIZE, 1);\n const height =\n aspect === \"free\"\n ? clamp(rect.height / safeScale, MIN_CROP_SIZE, 1)\n : (width * (imageSize.width / Math.max(1, imageSize.height))) / aspectRatio(aspect);\n return clampImageCropRect({ x: centerX - width / 2, y: centerY - height / 2, width, height }, imageSize, aspect);\n};\n\n/** Resizes a crop from one corner while keeping the opposite corner anchored. */\nexport const resizeImageCropFromCorner = (\n rect: ImageCropRect,\n imageSize: ImageCropSize,\n aspect: ImageCropAspect,\n handle: ImageCropResizeHandle,\n dx: number,\n dy: number,\n): ImageCropRect => {\n const movesEast = handle.includes(\"e\");\n const movesSouth = handle.includes(\"s\");\n const anchorX = movesEast ? rect.x : rect.x + rect.width;\n const anchorY = movesSouth ? rect.y : rect.y + rect.height;\n const requestedWidth = rect.width + (movesEast ? dx : -dx);\n const requestedHeight = rect.height + (movesSouth ? dy : -dy);\n\n if (aspect === \"free\") {\n const width = clamp(requestedWidth, MIN_CROP_SIZE, movesEast ? 1 - anchorX : anchorX);\n const height = clamp(requestedHeight, MIN_CROP_SIZE, movesSouth ? 1 - anchorY : anchorY);\n return {\n x: movesEast ? anchorX : anchorX - width,\n y: movesSouth ? anchorY : anchorY - height,\n width,\n height,\n };\n }\n\n const source = imageSize.width > 0 && imageSize.height > 0 ? imageSize.width / imageSize.height : 1;\n const target = aspectRatio(aspect);\n const widthFromHeight = (requestedHeight * target) / source;\n const requested = Math.abs(requestedWidth - rect.width) >= Math.abs(widthFromHeight - rect.width) ? requestedWidth : widthFromHeight;\n const horizontalLimit = movesEast ? 1 - anchorX : anchorX;\n const verticalLimit = movesSouth ? 1 - anchorY : anchorY;\n const maxWidth = Math.max(0, Math.min(horizontalLimit, (verticalLimit * target) / source));\n const minimumWidth = Math.min(maxWidth, Math.max(MIN_CROP_SIZE, (MIN_CROP_SIZE * target) / source));\n const width = clamp(requested, minimumWidth, maxWidth);\n const height = (width * source) / target;\n\n return {\n x: movesEast ? anchorX : anchorX - width,\n y: movesSouth ? anchorY : anchorY - height,\n width,\n height,\n };\n};\n\nexport const imageCropRectToPixels = (rect: ImageCropRect, imageSize: ImageCropSize) => {\n const x = clamp(rect.x, 0, 1 - MIN_CROP_SIZE);\n const y = clamp(rect.y, 0, 1 - MIN_CROP_SIZE);\n return {\n x: Math.round(x * imageSize.width),\n y: Math.round(y * imageSize.height),\n width: Math.max(1, Math.round(clamp(rect.width, MIN_CROP_SIZE, 1 - x) * imageSize.width)),\n height: Math.max(1, Math.round(clamp(rect.height, MIN_CROP_SIZE, 1 - y) * imageSize.height)),\n };\n};\n\nconst cropped = async (source: ImageCropSource, state: ImageCropState, output: ImageCropOutput) => {\n const { img } = await import(\"@k2b/stdlib/browser\");\n let data = await img.create(source);\n if (state.rotation) data = await img.rotate(state.rotation)(data);\n const crop = imageCropRectToPixels(state.crop, { width: data.width, height: data.height });\n data = await img.crop(crop.x, crop.y, crop.width, crop.height)(data);\n if (output.width || output.height) {\n data = await img.resize(output.width, output.height, \"fill\")(data);\n } else if (output.maxWidth || output.maxHeight) {\n const ratio = Math.min(1, (output.maxWidth ?? data.width) / data.width, (output.maxHeight ?? data.height) / data.height);\n if (ratio < 1) data = await img.resize(Math.round(data.width * ratio), Math.round(data.height * ratio), \"fill\")(data);\n }\n return { img, data };\n};\n\nexport const createCroppedImageCanvas = async (\n source: ImageCropSource,\n state: ImageCropState,\n output: ImageCropOutput = {},\n): Promise<HTMLCanvasElement> => {\n const result = await cropped(source, state, output);\n return result.img.toCanvas(result.data);\n};\n\nexport const createCroppedImageDataUrl = async (\n source: ImageCropSource,\n state: ImageCropState,\n output: ImageCropOutput = {},\n): Promise<string> => {\n const result = await cropped(source, state, output);\n return result.img.toBase64(output.format ?? \"webp\", output.quality ?? 0.86)(result.data);\n};\n"],"mappings":"AAgBA,MAAM,aAAa,GAAG,IAAI;AAC1B,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,E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AAQ,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC,MAAM,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC;IACxH,IAAI,KAAK,GAAG,CAAC,EAAE,IAAI,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC;EACvH;EACA,OAAO;IAAE,GAAG;IAAE;EAAK,CAAC;AACtB,CAAC;AAED,OAAO,MAAM,wBAAwB,GAAG,OACtC,MAAuB,EACvB,KAAqB,EACrB,MAAuB,GAAG,CAAC,CAAC,KACG;EAC/B,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;EACnD,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;AACzC,CAAC;AAED,OAAO,MAAM,yBAAyB,GAAG,OACvC,MAAuB,EACvB,KAAqB,EACrB,MAAuB,GAAG,CAAC,CAAC,KACR;EACpB,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC;EACnD,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;AAC1F,CAAC","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":[],"sources":["inputs/image-crop.ts"],"sourcesContent":["export type ImageCropAspect = \"free\" | { width: number; height: number };\nexport type ImageCropRotation = 0 | 90 | 180 | 270;\nexport type ImageCropRect = { x: number; y: number; width: number; height: number };\nexport type ImageCropState = { crop: ImageCropRect; rotation: ImageCropRotation };\nexport type ImageCropSource = File | Blob | HTMLImageElement | HTMLCanvasElement | string;\nexport type ImageCropOutput = {\n width?: number;\n height?: number;\n maxWidth?: number;\n maxHeight?: number;\n format?: \"webp\" | \"jpeg\" | \"png\";\n quality?: number;\n};\nexport type ImageCropSize = { width: number; height: number };\nexport type ImageCropResizeHandle = \"nw\" | \"ne\" | \"sw\" | \"se\";\n\nconst MIN_CROP_SIZE = 0.08;\nconst clamp = (value: number, min: number, max: number) => Math.max(min, Math.min(max, value));\nconst aspectRatio = (aspect: Exclude<ImageCropAspect, \"free\">) =>\n aspect.width > 0 && aspect.height > 0 ? aspect.width / aspect.height : 1;\n\nexport const normalizeImageCropRotation = (rotation: number): ImageCropRotation =>\n ((((Math.round(rotation / 90) * 90) % 360) + 360) % 360) as ImageCropRotation;\n\nexport const rotateImageCropRight = (rotation: ImageCropRotation): ImageCropRotation => normalizeImageCropRotation(rotation + 90);\n\nexport const getInitialImageCropRect = (imageSize: ImageCropSize, aspect: ImageCropAspect = \"free\"): ImageCropRect => {\n if (aspect === \"free\") return { x: 0.1, y: 0.1, width: 0.8, height: 0.8 };\n const target = aspectRatio(aspect);\n const source = imageSize.width > 0 && imageSize.height > 0 ? imageSize.width / imageSize.height : 1;\n let width = 0.86;\n let height = (width * source) / target;\n if (height > 0.86) {\n height = 0.86;\n width = (height * target) / source;\n }\n width = clamp(width, MIN_CROP_SIZE, 1);\n height = clamp(height, MIN_CROP_SIZE, 1);\n return { x: (1 - width) / 2, y: (1 - height) / 2, width, height };\n};\n\nexport const clampImageCropRect = (rect: ImageCropRect, imageSize: ImageCropSize, aspect: ImageCropAspect = \"free\"): ImageCropRect => {\n if (aspect === \"free\") {\n const width = clamp(rect.width, MIN_CROP_SIZE, 1);\n const height = clamp(rect.height, MIN_CROP_SIZE, 1);\n return { x: clamp(rect.x, 0, 1 - width), y: clamp(rect.y, 0, 1 - height), width, height };\n }\n const target = aspectRatio(aspect);\n const source = imageSize.width > 0 && imageSize.height > 0 ? imageSize.width / imageSize.height : 1;\n let width = clamp(rect.width, MIN_CROP_SIZE, 1);\n let height = (width * source) / target;\n if (height > 1) {\n height = 1;\n width = (height * target) / source;\n }\n return { x: clamp(rect.x, 0, 1 - width), y: clamp(rect.y, 0, 1 - height), width, height };\n};\n\nexport const resizeImageCropAroundCenter = (\n rect: ImageCropRect,\n imageSize: ImageCropSize,\n aspect: ImageCropAspect,\n scale: number,\n): ImageCropRect => {\n const safeScale = clamp(scale, 0.2, 5);\n const centerX = rect.x + rect.width / 2;\n const centerY = rect.y + rect.height / 2;\n const width = clamp(rect.width / safeScale, MIN_CROP_SIZE, 1);\n const height =\n aspect === \"free\"\n ? clamp(rect.height / safeScale, MIN_CROP_SIZE, 1)\n : (width * (imageSize.width / Math.max(1, imageSize.height))) / aspectRatio(aspect);\n return clampImageCropRect({ x: centerX - width / 2, y: centerY - height / 2, width, height }, imageSize, aspect);\n};\n\n/** Resizes a crop from one corner while keeping the opposite corner anchored. */\nexport const resizeImageCropFromCorner = (\n rect: ImageCropRect,\n imageSize: ImageCropSize,\n aspect: ImageCropAspect,\n handle: ImageCropResizeHandle,\n dx: number,\n dy: number,\n): ImageCropRect => {\n const movesEast = handle.includes(\"e\");\n const movesSouth = handle.includes(\"s\");\n const anchorX = movesEast ? rect.x : rect.x + rect.width;\n const anchorY = movesSouth ? rect.y : rect.y + rect.height;\n const requestedWidth = rect.width + (movesEast ? dx : -dx);\n const requestedHeight = rect.height + (movesSouth ? dy : -dy);\n\n if (aspect === \"free\") {\n const width = clamp(requestedWidth, MIN_CROP_SIZE, movesEast ? 1 - anchorX : anchorX);\n const height = clamp(requestedHeight, MIN_CROP_SIZE, movesSouth ? 1 - anchorY : anchorY);\n return {\n x: movesEast ? anchorX : anchorX - width,\n y: movesSouth ? anchorY : anchorY - height,\n width,\n height,\n };\n }\n\n const source = imageSize.width > 0 && imageSize.height > 0 ? imageSize.width / imageSize.height : 1;\n const target = aspectRatio(aspect);\n const widthFromHeight = (requestedHeight * target) / source;\n const requested = Math.abs(requestedWidth - rect.width) >= Math.abs(widthFromHeight - rect.width) ? requestedWidth : widthFromHeight;\n const horizontalLimit = movesEast ? 1 - anchorX : anchorX;\n const verticalLimit = movesSouth ? 1 - anchorY : anchorY;\n const maxWidth = Math.max(0, Math.min(horizontalLimit, (verticalLimit * target) / source));\n const minimumWidth = Math.min(maxWidth, Math.max(MIN_CROP_SIZE, (MIN_CROP_SIZE * target) / source));\n const width = clamp(requested, minimumWidth, maxWidth);\n const height = (width * source) / target;\n\n return {\n x: movesEast ? anchorX : anchorX - width,\n y: movesSouth ? anchorY : anchorY - height,\n width,\n height,\n };\n};\n\nexport const imageCropRectToPixels = (rect: ImageCropRect, imageSize: ImageCropSize) => {\n const x = clamp(rect.x, 0, 1 - MIN_CROP_SIZE);\n const y = clamp(rect.y, 0, 1 - MIN_CROP_SIZE);\n return {\n x: Math.round(x * imageSize.width),\n y: Math.round(y * imageSize.height),\n width: Math.max(1, Math.round(clamp(rect.width, MIN_CROP_SIZE, 1 - x) * imageSize.width)),\n height: Math.max(1, Math.round(clamp(rect.height, MIN_CROP_SIZE, 1 - y) * imageSize.height)),\n };\n};\n\nconst cropped = async (source: ImageCropSource, state: ImageCropState, output: ImageCropOutput) => {\n const { img } = await import(\"./image-tools\");\n let data = await img.create(source);\n if (state.rotation) data = await img.rotate(state.rotation)(data);\n const crop = imageCropRectToPixels(state.crop, { width: data.width, height: data.height });\n data = await img.crop(crop.x, crop.y, crop.width, crop.height)(data);\n if (output.width || output.height) {\n data = await img.resize(output.width, output.height, \"fill\")(data);\n } else if (output.maxWidth || output.maxHeight) {\n const ratio = Math.min(1, (output.maxWidth ?? data.width) / data.width, (output.maxHeight ?? data.height) / data.height);\n if (ratio < 1) data = await img.resize(Math.round(data.width * ratio), Math.round(data.height * ratio), \"fill\")(data);\n }\n return { img, data };\n};\n\nexport const createCroppedImageCanvas = async (\n source: ImageCropSource,\n state: ImageCropState,\n output: ImageCropOutput = {},\n): Promise<HTMLCanvasElement> => {\n const result = await cropped(source, state, output);\n return result.img.toCanvas(result.data);\n};\n\nexport const createCroppedImageDataUrl = async (\n source: ImageCropSource,\n state: ImageCropState,\n output: ImageCropOutput = {},\n): Promise<string> => {\n const result = await cropped(source, state, output);\n return result.img.toBase64(output.format ?? \"webp\", output.quality ?? 0.86)(result.data);\n};\n"],"mappings":"AAgBA,MAAM,aAAa,GAAG,IAAI;AAC1B,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,KAAK,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAC9F,MAAM,WAAW,GAAI,MAAwC,IAC3D,MAAM,CAAC,KAAK,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,GAAG,MAAM,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC;AAE1E,OAAO,MAAM,0BAA0B,GAAI,QAAgB,IACxD,CAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,GAAG,EAAE,GAAI,GAAG,GAAI,GAAG,IAAI,GAAyB;AAE/E,OAAO,MAAM,oBAAoB,GAAI,QAA2B,IAAwB,0BAA0B,CAAC,QAAQ,GAAG,EAAE,CAAC;AAEjI,OAAO,MAAM,uBAAuB,GAAG,CAAC,SAAwB,EAAE,MAAuB,GAAG,MAAM,KAAoB;EACpH,IAAI,MAAM,KAAK,MAAM,EAAE,OAAO;IAAE,CAAC,EAAE,GAAG;IAAE,CAAC,EAAE,GAAG;IAAE,KAAK,EAAE,GAAG;IAAE,MAAM,EAAE;EAAI,CAAC;EACzE,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,CAAC;EAClC,MAAM,MAAM,GAAG,SAAS,CAAC,KAAK,GAAG,CAAC,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC,KAAK,GAAG,SAAS,CAAC,M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AM,EAAE,KAAK,EAAE,MAAM,CAAC;EACnD,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,EAAE,MAAM,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;AAC1F,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
// Loaded on demand by image inputs. A named re-export keeps the import narrow: `import("@k2b/stdlib/browser")` would
|
|
2
|
+
// load every browser utility and make island builds keep unused barrel modules in static chunks (#3504).
|
|
3
|
+
export { img } from "@k2b/stdlib/browser";
|
|
4
|
+
//# sourceMappingURL=image-tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["inputs/image-tools.ts"],"sourcesContent":["// Loaded on demand by image inputs. A named re-export keeps the import narrow: `import(\"@k2b/stdlib/browser\")` would\n// load every browser utility and make island builds keep unused barrel modules in static chunks (#3504).\nexport { img } from \"@k2b/stdlib/browser\";\n"],"mappings":"AAAA;AACA;AACA,SAAS,GAAG,QAAQ,qBAAqB","ignoreList":[]}
|
|
@@ -6,7 +6,6 @@ const inputMessages = i18n.define({
|
|
|
6
6
|
en: {
|
|
7
7
|
decreaseValue: "Decrease value",
|
|
8
8
|
increaseValue: "Increase value",
|
|
9
|
-
hidePassword: "Hide password",
|
|
10
9
|
showPassword: "Show password",
|
|
11
10
|
useColor: "Use a color",
|
|
12
11
|
useTransparent: "Use transparent",
|
|
@@ -19,6 +18,10 @@ const inputMessages = i18n.define({
|
|
|
19
18
|
}) => `Reset to ${value}`,
|
|
20
19
|
timeLetters: "hh:mm",
|
|
21
20
|
notATime: "Not a time. Example: 09:30",
|
|
21
|
+
notANumber: ({
|
|
22
|
+
example
|
|
23
|
+
}) => `Not a number. Example: ${example}`,
|
|
24
|
+
noNegativeNumbers: "No negative numbers.",
|
|
22
25
|
timeRequired: "Enter a time.",
|
|
23
26
|
earliestTime: ({
|
|
24
27
|
time
|
|
@@ -30,7 +33,6 @@ const inputMessages = i18n.define({
|
|
|
30
33
|
de: {
|
|
31
34
|
decreaseValue: "Wert verringern",
|
|
32
35
|
increaseValue: "Wert erhöhen",
|
|
33
|
-
hidePassword: "Passwort ausblenden",
|
|
34
36
|
showPassword: "Passwort anzeigen",
|
|
35
37
|
useColor: "Farbe verwenden",
|
|
36
38
|
useTransparent: "Transparent verwenden",
|
|
@@ -43,6 +45,10 @@ const inputMessages = i18n.define({
|
|
|
43
45
|
}) => `Zurücksetzen auf ${value}`,
|
|
44
46
|
timeLetters: "hh:mm",
|
|
45
47
|
notATime: "Keine Uhrzeit. Beispiel: 09:30",
|
|
48
|
+
notANumber: ({
|
|
49
|
+
example
|
|
50
|
+
}) => `Keine Zahl. Beispiel: ${example}`,
|
|
51
|
+
noNegativeNumbers: "Keine negativen Zahlen.",
|
|
46
52
|
timeRequired: "Bitte eine Uhrzeit eingeben.",
|
|
47
53
|
earliestTime: ({
|
|
48
54
|
time
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["inputs/input-messages.ts"],"sourcesContent":["import { i18n } from \"@k2b/stdlib\";\nimport { useLocale } from \"../intl/locale\";\n\nconst inputMessages = i18n.define({\n baseLocale: \"en\",\n messages: {\n en: {\n decreaseValue: \"Decrease value\",\n increaseValue: \"Increase value\",\n
|
|
1
|
+
{"version":3,"names":[],"sources":["inputs/input-messages.ts"],"sourcesContent":["import { i18n } from \"@k2b/stdlib\";\nimport { useLocale } from \"../intl/locale\";\n\nconst inputMessages = i18n.define({\n baseLocale: \"en\",\n messages: {\n en: {\n decreaseValue: \"Decrease value\",\n increaseValue: \"Increase value\",\n showPassword: \"Show password\",\n useColor: \"Use a color\",\n useTransparent: \"Use transparent\",\n pinDigit: ({ index, total }: { index: number; total: number }) => `PIN digit ${index} of ${total}`,\n resetTo: ({ value }: { value: string }) => `Reset to ${value}`,\n timeLetters: \"hh:mm\",\n notATime: \"Not a time. Example: 09:30\",\n notANumber: ({ example }: { example: string }) => `Not a number. Example: ${example}`,\n noNegativeNumbers: \"No negative numbers.\",\n timeRequired: \"Enter a time.\",\n earliestTime: ({ time }: { time: string }) => `${time} at the earliest.`,\n latestTime: ({ time }: { time: string }) => `${time} at the latest.`,\n },\n de: {\n decreaseValue: \"Wert verringern\",\n increaseValue: \"Wert erhöhen\",\n showPassword: \"Passwort anzeigen\",\n useColor: \"Farbe verwenden\",\n useTransparent: \"Transparent verwenden\",\n pinDigit: ({ index, total }) => `PIN-Ziffer ${index} von ${total}`,\n resetTo: ({ value }) => `Zurücksetzen auf ${value}`,\n timeLetters: \"hh:mm\",\n notATime: \"Keine Uhrzeit. Beispiel: 09:30\",\n notANumber: ({ example }) => `Keine Zahl. Beispiel: ${example}`,\n noNegativeNumbers: \"Keine negativen Zahlen.\",\n timeRequired: \"Bitte eine Uhrzeit eingeben.\",\n earliestTime: ({ time }) => `Frühestens ${time}.`,\n latestTime: ({ time }) => `Spätestens ${time}.`,\n },\n },\n});\n\nexport type InputMessages = ReturnType<(typeof inputMessages)[\"resolve\"]>[\"t\"];\n\n/** Resolved from the inherited render locale. */\nexport const useInputMessages = (): (() => InputMessages) => {\n const locale = useLocale();\n return () => inputMessages.resolve([locale()]).t;\n};\n\nexport const checkInputMessages = () => inputMessages.check();\n"],"mappings":"AAAA,SAAS,IAAI,QAAQ,aAAa;AAClC,SAAS,SAAS,QAAQ,gBAAgB;AAE1C,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC;EAChC,UAAU,EAAE,IAAI;EAChB,QAAQ,EAAE;IACR,EAAE,EAAE;MACF,aAAa,EAAE,gBAAgB;MAC/B,aAAa,EAAE,gBAAgB;MAC/B,YAAY,EAAE,eAAe;MAC7B,QAAQ,EAAE,aAAa;MACvB,cAAc,EAAE,iBAAiB;MACjC,QAAQ,EAAE,CAAC;QAAE,KAAK;QAAE;MAAwC,CAAC,KAAK,aAAa,KAAK,OAAO,KAAK,EAAE;MAClG,OAAO,E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AAkB,GAAG,MAAM,aAAa,CAAC,KAAK,CAAC,CAAC","ignoreList":[]}
|
|
@@ -65,14 +65,14 @@ export function Field(props) {
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
})), _$escape(_$createComponent(Show, {
|
|
68
|
+
})), _$escape(props.children), _$escape(_$createComponent(Show, {
|
|
69
69
|
get when() {
|
|
70
70
|
return props.description;
|
|
71
71
|
},
|
|
72
72
|
get children() {
|
|
73
73
|
return _$ssr(_tmpl$5, _$ssrAttribute("id", _$escape(props.meta.descriptionId, true), false), _$escape(props.description));
|
|
74
74
|
}
|
|
75
|
-
})), _$escape(
|
|
75
|
+
})), _$escape(_$createComponent(Show, {
|
|
76
76
|
get when() {
|
|
77
77
|
return error();
|
|
78
78
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"],"sources":["internal/field.tsx"],"sourcesContent":["import { createUniqueId, type JSX, Show } from \"solid-js\";\nimport type { FieldProps } from \"../inputs/field-contract\";\nimport { resolveMaybeAccessor } from \"../inputs/field-contract\";\n\nexport type FieldMeta = {\n controlId: string;\n labelId: string;\n descriptionId: string;\n errorId: string;\n};\n\nexport const createFieldMeta = (id?: string): FieldMeta => {\n const generatedId = createUniqueId();\n const controlId = id ?? `k2b-field-${generatedId}`;\n\n return {\n controlId,\n labelId: `${controlId}-label`,\n descriptionId: `${controlId}-description`,\n errorId: `${controlId}-error`,\n };\n};\n\ntype FieldLayoutProps = {\n children: JSX.Element;\n meta: FieldMeta;\n fill?: boolean;\n /** Composite controls use aria-labelledby instead of an HTML label target. */\n labelFor?: string | false;\n /** Optional controls beside the label, outside its clickable target. */\n labelEnd?: JSX.Element;\n} & Pick<FieldProps, \"class\" | \"description\" | \"error\" | \"label\" | \"required\" | \"disabled\">;\n\nexport function Field(props: FieldLayoutProps): JSX.Element {\n const error = () => resolveMaybeAccessor(props.error);\n const label = () => (\n <Show\n when={props.labelFor !== false}\n fallback={\n <span id={props.meta.labelId} class=\"k2b-field__label\">\n {props.label}\n <Show when={props.required}>\n <span class=\"k2b-field__required\" aria-hidden=\"true\">\n *\n </span>\n </Show>\n </span>\n }\n >\n <label id={props.meta.labelId} class=\"k2b-field__label\" for={props.labelFor || props.meta.controlId}>\n {props.label}\n <Show when={props.required}>\n <span class=\"k2b-field__required\" aria-hidden=\"true\">\n *\n </span>\n </Show>\n </label>\n </Show>\n );\n\n return (\n <div\n class={`k2b-field ${props.class ?? \"\"}`}\n data-disabled={props.disabled ? \"true\" : undefined}\n data-fill={props.fill ? \"true\" : undefined}\n data-invalid={error() ? \"true\" : undefined}\n >\n <Show when={props.label}>\n <Show when={props.labelEnd} fallback={label()}>\n <div class=\"k2b-field__label-row\">\n {label()}\n {props.labelEnd}\n </div>\n </Show>\n </Show>\n <Show when={props.description}>\n <p class=\"k2b-field__description\" id={props.meta.descriptionId}>\n {props.description}\n </p>\n </Show>\n
|
|
1
|
+
{"version":3,"names":["aria-label","aria-labelledby","aria-describedby","aria-invalid","aria-required"],"sources":["internal/field.tsx"],"sourcesContent":["import { createUniqueId, type JSX, Show } from \"solid-js\";\nimport type { FieldProps } from \"../inputs/field-contract\";\nimport { resolveMaybeAccessor } from \"../inputs/field-contract\";\n\nexport type FieldMeta = {\n controlId: string;\n labelId: string;\n descriptionId: string;\n errorId: string;\n};\n\nexport const createFieldMeta = (id?: string): FieldMeta => {\n const generatedId = createUniqueId();\n const controlId = id ?? `k2b-field-${generatedId}`;\n\n return {\n controlId,\n labelId: `${controlId}-label`,\n descriptionId: `${controlId}-description`,\n errorId: `${controlId}-error`,\n };\n};\n\ntype FieldLayoutProps = {\n children: JSX.Element;\n meta: FieldMeta;\n fill?: boolean;\n /** Composite controls use aria-labelledby instead of an HTML label target. */\n labelFor?: string | false;\n /** Optional controls beside the label, outside its clickable target. */\n labelEnd?: JSX.Element;\n} & Pick<FieldProps, \"class\" | \"description\" | \"error\" | \"label\" | \"required\" | \"disabled\">;\n\nexport function Field(props: FieldLayoutProps): JSX.Element {\n const error = () => resolveMaybeAccessor(props.error);\n const label = () => (\n <Show\n when={props.labelFor !== false}\n fallback={\n <span id={props.meta.labelId} class=\"k2b-field__label\">\n {props.label}\n <Show when={props.required}>\n <span class=\"k2b-field__required\" aria-hidden=\"true\">\n *\n </span>\n </Show>\n </span>\n }\n >\n <label id={props.meta.labelId} class=\"k2b-field__label\" for={props.labelFor || props.meta.controlId}>\n {props.label}\n <Show when={props.required}>\n <span class=\"k2b-field__required\" aria-hidden=\"true\">\n *\n </span>\n </Show>\n </label>\n </Show>\n );\n\n return (\n <div\n class={`k2b-field ${props.class ?? \"\"}`}\n data-disabled={props.disabled ? \"true\" : undefined}\n data-fill={props.fill ? \"true\" : undefined}\n data-invalid={error() ? \"true\" : undefined}\n >\n <Show when={props.label}>\n <Show when={props.labelEnd} fallback={label()}>\n <div class=\"k2b-field__label-row\">\n {label()}\n {props.labelEnd}\n </div>\n </Show>\n </Show>\n {props.children}\n {/* K5: help and error stand under the control, so fields in a row keep their controls on one line. */}\n <Show when={props.description}>\n <p class=\"k2b-field__description\" id={props.meta.descriptionId}>\n {props.description}\n </p>\n </Show>\n <Show when={error()}>\n <p class=\"k2b-field__error\" id={props.meta.errorId} role=\"alert\" aria-live=\"polite\">\n {error()}\n </p>\n </Show>\n </div>\n );\n}\n\ntype FieldAriaOwner = Pick<FieldProps, \"aria-describedby\" | \"aria-label\" | \"description\" | \"error\" | \"label\" | \"required\">;\n\nexport const fieldDescribedBy = (meta: FieldMeta, owner: FieldAriaOwner): string | undefined =>\n [\n owner[\"aria-describedby\"],\n owner.description ? meta.descriptionId : undefined,\n resolveMaybeAccessor(owner.error) ? meta.errorId : undefined,\n ]\n .filter(Boolean)\n .join(\" \") || undefined;\n\nexport const fieldControlAria = (meta: FieldMeta, owner: FieldAriaOwner) => ({\n get \"aria-label\"() {\n return owner.label ? undefined : owner[\"aria-label\"];\n },\n get \"aria-labelledby\"() {\n return owner.label ? meta.labelId : undefined;\n },\n get \"aria-describedby\"() {\n return fieldDescribedBy(meta, owner);\n },\n get \"aria-invalid\"() {\n return resolveMaybeAccessor(owner.error) ? (\"true\" as const) : undefined;\n },\n get \"aria-required\"() {\n return owner.required || undefined;\n },\n});\n"],"mappings":";;;;;;;;;;;AAAA,SAAS,cAAc,EAAY,IAAI,QAAQ,UAAU;AAEzD,SAAS,oBAAoB,QAAQ,0BAA0B;AAS/D,OAAO,MAAM,eAAe,GAAI,EAAW,IAAgB;EACzD,MAAM,WAAW,GAAG,cAAc,CAAC,CAAC;EACpC,MAAM,SAAS,GAAG,EAAE,IAAI,aAAa,WAAW,EAAE;EAElD,OAAO;IACL,SAAS;IACT,OAAO,EAAE,GAAG,SAAS,QAAQ;IAC7B,aAAa,EAAE,GAAG,SAAS,cAAc;IACzC,OAAO,EAAE,GAAG,SAAS;EACvB,CAAC;AACH,CAAC;AAYD,OAAO,SAAS,KAAK,CAAC,KAAuB,EAAe;EAC1D,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC;EACrD,MAAM,KAAK,GAAG,wBACX,IAAI;IAAA,IACH,IAAI;MAAA,OAAE,KAAK,CAAC,QAAQ,KAAK,KAAK;IAAA;IAAA,IAC9B,QAAQ;MAAA,oDACI,KAAK,CAAC,IAAI,CAAC,OAAO,0BACzB,KAAK,CAAC,KAAK,8BACX,IAAI;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,QAAQ;QAAA;QAAA;UAAA;QAAA;MAAA;IAAA;IAAA;MAAA,oDAQnB,KAAK,CAAC,IAAI,CAAC,OAAO,gDAAgC,KAAK,CAAC,QAAQ,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS,0BAChG,KAAK,CAAC,KAAK,8BACX,IAAI;QAAA,IAAC,IAAI;UAAA,OAAE,KAAK,CAAC,QAAQ;QAAA;QAAA;UAAA;QAAA;MAAA;IAAA;EAAA,EAO/B;EAED,sBAEW,sBA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;IACjB,OAAO,KAAK,CAAC,KAAK,GAAG,SAAS,GAAG,KAAK,CAAC,YAAY,CAAC;EACtD,CAAC;EACD,IAAI,iBAAiBC,CAAA,EAAG;IACtB,OAAO,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,OAAO,GAAG,SAAS;EAC/C,CAAC;EACD,IAAI,kBAAkBC,CAAA,EAAG;IACvB,OAAO,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC;EACtC,CAAC;EACD,IAAI,cAAcC,CAAA,EAAG;IACnB,OAAO,oBAAoB,CAAC,KAAK,CAAC,KAAK,CAAC,GAAI,MAAM,GAAa,SAAS;EAC1E,CAAC;EACD,IAAI,eAAeC,CAAA,EAAG;IACpB,OAAO,KAAK,CAAC,QAAQ,IAAI,SAAS;EACpC;AACF,CAAC,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Whether resolved children render something; a Show whose condition is false, or a boolean, renders nothing. */
|
|
2
|
+
export const rendersSomething = nodes => nodes.some(node => node != null && typeof node !== "boolean" && node !== "");
|
|
3
|
+
//# sourceMappingURL=renders-something.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["internal/renders-something.ts"],"sourcesContent":["/** Whether resolved children render something; a Show whose condition is false, or a boolean, renders nothing. */\nexport const rendersSomething = (nodes: unknown[]): boolean =>\n nodes.some((node) => node != null && typeof node !== \"boolean\" && node !== \"\");\n"],"mappings":"AAAA;AACA,OAAO,MAAM,gBAAgB,GAAI,KAAgB,IAC/C,KAAK,CAAC,IAAI,CAAE,IAAI,IAAK,IAAI,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,EAAE,CAAC","ignoreList":[]}
|