@grampro/kit 0.0.0-stage → 2.4.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/.gbs/skills/gbs-components/SKILL.md +190 -0
- package/.gbs/skills/gbs-components/references/accessibility.md +102 -0
- package/.gbs/skills/gbs-components/references/data-display.md +185 -0
- package/.gbs/skills/gbs-components/references/data-grid.md +116 -0
- package/.gbs/skills/gbs-components/references/forms.md +202 -0
- package/.gbs/skills/gbs-components/references/install.md +211 -0
- package/.gbs/skills/gbs-components/references/overlays.md +206 -0
- package/.gbs/skills/gbs-components/references/pickers.md +83 -0
- package/.gbs/skills/gbs-components/references/styling.md +246 -0
- package/.gbs/skills/gbs-components/references/toaster.md +57 -0
- package/CHANGELOG.md +139 -0
- package/LICENSE +15 -0
- package/README.md +193 -2
- package/index.cjs +1370 -0
- package/package.json +74 -4
- package/schema/passport-v1.schema.json +204 -0
- package/source/components/accordion/README.md +45 -0
- package/source/components/accordion/core/index.ts +2 -0
- package/source/components/accordion/core/open.ts +56 -0
- package/source/components/accordion/core/types.ts +17 -0
- package/source/components/accordion/index.ts +8 -0
- package/source/components/accordion/passport.json +259 -0
- package/source/components/accordion/react/Accordion.tsx +133 -0
- package/source/components/accordion/react/AccordionItem.tsx +120 -0
- package/source/components/accordion/react/context.ts +20 -0
- package/source/components/accordion/react/props.ts +13 -0
- package/source/components/accordion/styles.css +207 -0
- package/source/components/alert/README.md +39 -0
- package/source/components/alert/core/index.ts +2 -0
- package/source/components/alert/core/live.ts +25 -0
- package/source/components/alert/core/types.ts +7 -0
- package/source/components/alert/index.ts +5 -0
- package/source/components/alert/passport.json +250 -0
- package/source/components/alert/react/Alert.tsx +113 -0
- package/source/components/alert/react/icons.tsx +21 -0
- package/source/components/alert/react/locale.ts +5 -0
- package/source/components/alert/react/props.ts +11 -0
- package/source/components/alert/styles.css +154 -0
- package/source/components/avatar/core/identity.ts +103 -0
- package/source/components/avatar/core/index.ts +2 -0
- package/source/components/avatar/core/types.ts +12 -0
- package/source/components/avatar/index.ts +7 -0
- package/source/components/avatar/passport.json +294 -0
- package/source/components/avatar/react/Avatar.tsx +118 -0
- package/source/components/avatar/react/AvatarGroup.tsx +74 -0
- package/source/components/avatar/react/locale.ts +11 -0
- package/source/components/avatar/react/props.ts +6 -0
- package/source/components/avatar/styles.css +225 -0
- package/source/components/badge/README.md +37 -0
- package/source/components/badge/core/count.ts +37 -0
- package/source/components/badge/core/index.ts +2 -0
- package/source/components/badge/core/types.ts +11 -0
- package/source/components/badge/index.ts +7 -0
- package/source/components/badge/passport.json +332 -0
- package/source/components/badge/react/Badge.tsx +89 -0
- package/source/components/badge/react/Tag.tsx +82 -0
- package/source/components/badge/react/locale.ts +5 -0
- package/source/components/badge/react/props.ts +6 -0
- package/source/components/badge/styles.css +203 -0
- package/source/components/breadcrumb/README.md +34 -0
- package/source/components/breadcrumb/core/index.ts +4 -0
- package/source/components/breadcrumb/core/trail.ts +42 -0
- package/source/components/breadcrumb/core/types.ts +20 -0
- package/source/components/breadcrumb/index.ts +5 -0
- package/source/components/breadcrumb/passport.json +243 -0
- package/source/components/breadcrumb/react/Breadcrumb.tsx +177 -0
- package/source/components/breadcrumb/react/locale.ts +6 -0
- package/source/components/breadcrumb/react/props.ts +14 -0
- package/source/components/breadcrumb/styles.css +138 -0
- package/source/components/button/README.md +32 -0
- package/source/components/button/core/index.ts +3 -0
- package/source/components/button/core/state.ts +16 -0
- package/source/components/button/core/types.ts +28 -0
- package/source/components/button/index.ts +5 -0
- package/source/components/button/passport.json +402 -0
- package/source/components/button/passport.manual.json +31 -0
- package/source/components/button/react/Button.tsx +173 -0
- package/source/components/button/react/locale.ts +5 -0
- package/source/components/button/react/props.ts +23 -0
- package/source/components/button/styles.css +232 -0
- package/source/components/card/README.md +60 -0
- package/source/components/card/core/index.ts +4 -0
- package/source/components/card/core/trend.ts +32 -0
- package/source/components/card/core/types.ts +5 -0
- package/source/components/card/index.ts +5 -0
- package/source/components/card/passport.json +337 -0
- package/source/components/card/react/Card.tsx +133 -0
- package/source/components/card/react/Stat.tsx +127 -0
- package/source/components/card/react/props.ts +4 -0
- package/source/components/card/styles.css +230 -0
- package/source/components/checkbox/README.md +36 -0
- package/source/components/checkbox/core/group.ts +30 -0
- package/source/components/checkbox/core/index.ts +3 -0
- package/source/components/checkbox/core/types.ts +17 -0
- package/source/components/checkbox/index.ts +9 -0
- package/source/components/checkbox/passport.json +456 -0
- package/source/components/checkbox/react/Checkbox.tsx +147 -0
- package/source/components/checkbox/react/CheckboxGroup.tsx +149 -0
- package/source/components/checkbox/react/context.ts +16 -0
- package/source/components/checkbox/react/locale.ts +5 -0
- package/source/components/checkbox/react/props.ts +6 -0
- package/source/components/checkbox/styles.css +211 -0
- package/source/components/combobox/README.md +170 -0
- package/source/components/combobox/core/filter.ts +155 -0
- package/source/components/combobox/core/index.ts +16 -0
- package/source/components/combobox/core/types.ts +48 -0
- package/source/components/combobox/core/virtual.ts +67 -0
- package/source/components/combobox/index.ts +13 -0
- package/source/components/combobox/passport.json +456 -0
- package/source/components/combobox/react/Listbox.tsx +310 -0
- package/source/components/combobox/react/MultiSelect.tsx +265 -0
- package/source/components/combobox/react/Popover.tsx +38 -0
- package/source/components/combobox/react/Select.tsx +200 -0
- package/source/components/combobox/react/icons.tsx +11 -0
- package/source/components/combobox/react/locale.ts +16 -0
- package/source/components/combobox/react/props.ts +88 -0
- package/source/components/combobox/react/useCombobox.ts +409 -0
- package/source/components/combobox/styles.css +419 -0
- package/source/components/data-grid/README.md +233 -0
- package/source/components/data-grid/agent/coerce.ts +368 -0
- package/source/components/data-grid/agent/contract.ts +410 -0
- package/source/components/data-grid/agent/dataset.ts +92 -0
- package/source/components/data-grid/agent/engine.ts +470 -0
- package/source/components/data-grid/agent/executors.ts +155 -0
- package/source/components/data-grid/agent/index.ts +79 -0
- package/source/components/data-grid/agent/intent.ts +324 -0
- package/source/components/data-grid/agent/operations.ts +335 -0
- package/source/components/data-grid/agent/validate.ts +630 -0
- package/source/components/data-grid/agent/webmcp.ts +107 -0
- package/source/components/data-grid/core/columnHelper.ts +21 -0
- package/source/components/data-grid/core/columns.ts +288 -0
- package/source/components/data-grid/core/filtering.ts +237 -0
- package/source/components/data-grid/core/grid.ts +638 -0
- package/source/components/data-grid/core/index.ts +14 -0
- package/source/components/data-grid/core/rows.ts +64 -0
- package/source/components/data-grid/core/sorting.ts +133 -0
- package/source/components/data-grid/core/state.ts +82 -0
- package/source/components/data-grid/core/store.ts +52 -0
- package/source/components/data-grid/core/types.ts +302 -0
- package/source/components/data-grid/core/values.ts +98 -0
- package/source/components/data-grid/core/virtual.ts +85 -0
- package/source/components/data-grid/export/csv.ts +32 -0
- package/source/components/data-grid/export/download.ts +12 -0
- package/source/components/data-grid/export/pdf-font.ts +139 -0
- package/source/components/data-grid/export/pdf-writer.ts +113 -0
- package/source/components/data-grid/export/pdf.ts +379 -0
- package/source/components/data-grid/export/table.ts +73 -0
- package/source/components/data-grid/export/xlsx.ts +145 -0
- package/source/components/data-grid/export/zip.ts +87 -0
- package/source/components/data-grid/index.ts +14 -0
- package/source/components/data-grid/passport.json +1051 -0
- package/source/components/data-grid/passport.manual.json +255 -0
- package/source/components/data-grid/react/AskGrid.tsx +164 -0
- package/source/components/data-grid/react/Cell.tsx +282 -0
- package/source/components/data-grid/react/ColumnMenu.tsx +135 -0
- package/source/components/data-grid/react/DataGrid.tsx +335 -0
- package/source/components/data-grid/react/FilterForm.tsx +142 -0
- package/source/components/data-grid/react/HeaderRow.tsx +332 -0
- package/source/components/data-grid/react/Pagination.tsx +107 -0
- package/source/components/data-grid/react/Popover.tsx +35 -0
- package/source/components/data-grid/react/Row.tsx +85 -0
- package/source/components/data-grid/react/Toolbar.tsx +267 -0
- package/source/components/data-grid/react/Viewport.tsx +167 -0
- package/source/components/data-grid/react/context.ts +57 -0
- package/source/components/data-grid/react/hooks.ts +83 -0
- package/source/components/data-grid/react/icons.tsx +45 -0
- package/source/components/data-grid/react/keyboard.ts +110 -0
- package/source/components/data-grid/react/locale.ts +130 -0
- package/source/components/data-grid/styles.css +874 -0
- package/source/components/date-picker/README.md +141 -0
- package/source/components/date-picker/core/calendar.ts +266 -0
- package/source/components/date-picker/core/format.ts +170 -0
- package/source/components/date-picker/core/index.ts +41 -0
- package/source/components/date-picker/core/today.ts +72 -0
- package/source/components/date-picker/core/types.ts +68 -0
- package/source/components/date-picker/index.ts +16 -0
- package/source/components/date-picker/passport.json +407 -0
- package/source/components/date-picker/react/Calendar.tsx +160 -0
- package/source/components/date-picker/react/CalendarPanel.tsx +170 -0
- package/source/components/date-picker/react/DatePicker.tsx +249 -0
- package/source/components/date-picker/react/DateRangePicker.tsx +291 -0
- package/source/components/date-picker/react/MonthYearPanels.tsx +123 -0
- package/source/components/date-picker/react/Popover.tsx +45 -0
- package/source/components/date-picker/react/icons.tsx +15 -0
- package/source/components/date-picker/react/locale.ts +23 -0
- package/source/components/date-picker/react/props.ts +76 -0
- package/source/components/date-picker/react/useDatePicker.ts +557 -0
- package/source/components/date-picker/styles.css +445 -0
- package/source/components/dialog/README.md +39 -0
- package/source/components/dialog/core/api.ts +34 -0
- package/source/components/dialog/core/dialog.ts +11 -0
- package/source/components/dialog/core/index.ts +7 -0
- package/source/components/dialog/core/store.ts +81 -0
- package/source/components/dialog/core/types.ts +59 -0
- package/source/components/dialog/index.ts +7 -0
- package/source/components/dialog/passport.json +344 -0
- package/source/components/dialog/react/Dialog.tsx +279 -0
- package/source/components/dialog/react/DialogHost.tsx +45 -0
- package/source/components/dialog/react/icons.tsx +20 -0
- package/source/components/dialog/react/locale.ts +8 -0
- package/source/components/dialog/react/props.ts +13 -0
- package/source/components/dialog/styles.css +280 -0
- package/source/components/file-uploader/README.md +99 -0
- package/source/components/file-uploader/core/format.ts +79 -0
- package/source/components/file-uploader/core/index.ts +26 -0
- package/source/components/file-uploader/core/store.ts +432 -0
- package/source/components/file-uploader/core/transport.ts +154 -0
- package/source/components/file-uploader/core/types.ts +126 -0
- package/source/components/file-uploader/core/validate.ts +83 -0
- package/source/components/file-uploader/index.ts +7 -0
- package/source/components/file-uploader/passport.json +518 -0
- package/source/components/file-uploader/react/FileRow.tsx +268 -0
- package/source/components/file-uploader/react/FileUploader.tsx +511 -0
- package/source/components/file-uploader/react/icons.tsx +60 -0
- package/source/components/file-uploader/react/locale.ts +33 -0
- package/source/components/file-uploader/react/props.ts +31 -0
- package/source/components/file-uploader/react/useFileUploader.ts +32 -0
- package/source/components/file-uploader/styles.css +394 -0
- package/source/components/input/README.md +44 -0
- package/source/components/input/core/count.ts +5 -0
- package/source/components/input/core/index.ts +11 -0
- package/source/components/input/core/otp.ts +64 -0
- package/source/components/input/core/types.ts +14 -0
- package/source/components/input/index.ts +8 -0
- package/source/components/input/passport.json +536 -0
- package/source/components/input/react/Input.tsx +219 -0
- package/source/components/input/react/OtpInput.tsx +256 -0
- package/source/components/input/react/dom.ts +10 -0
- package/source/components/input/react/icons.tsx +17 -0
- package/source/components/input/react/locale.ts +9 -0
- package/source/components/input/react/props.ts +6 -0
- package/source/components/input/styles.css +295 -0
- package/source/components/menu/README.md +68 -0
- package/source/components/menu/core/index.ts +11 -0
- package/source/components/menu/core/navigation.ts +84 -0
- package/source/components/menu/core/types.ts +32 -0
- package/source/components/menu/index.ts +19 -0
- package/source/components/menu/passport.json +322 -0
- package/source/components/menu/react/Menu.tsx +371 -0
- package/source/components/menu/react/context.ts +31 -0
- package/source/components/menu/react/items.tsx +268 -0
- package/source/components/menu/react/locale.ts +6 -0
- package/source/components/menu/react/props.ts +4 -0
- package/source/components/menu/react/useMenuKeys.ts +124 -0
- package/source/components/menu/styles.css +224 -0
- package/source/components/modal/README.md +51 -0
- package/source/components/modal/core/dismiss.ts +29 -0
- package/source/components/modal/core/index.ts +3 -0
- package/source/components/modal/core/types.ts +27 -0
- package/source/components/modal/index.ts +5 -0
- package/source/components/modal/passport.json +289 -0
- package/source/components/modal/react/Modal.tsx +242 -0
- package/source/components/modal/react/icons.tsx +1 -0
- package/source/components/modal/react/locale.ts +5 -0
- package/source/components/modal/react/props.ts +17 -0
- package/source/components/modal/styles.css +241 -0
- package/source/components/number-input/README.md +53 -0
- package/source/components/number-input/core/format.ts +37 -0
- package/source/components/number-input/core/index.ts +4 -0
- package/source/components/number-input/core/parse.ts +118 -0
- package/source/components/number-input/core/step.ts +73 -0
- package/source/components/number-input/core/types.ts +32 -0
- package/source/components/number-input/index.ts +5 -0
- package/source/components/number-input/passport.json +541 -0
- package/source/components/number-input/react/NumberInput.tsx +465 -0
- package/source/components/number-input/react/icons.tsx +17 -0
- package/source/components/number-input/react/locale.ts +7 -0
- package/source/components/number-input/react/props.ts +11 -0
- package/source/components/number-input/styles.css +230 -0
- package/source/components/popover/README.md +44 -0
- package/source/components/popover/core/index.ts +2 -0
- package/source/components/popover/core/types.ts +12 -0
- package/source/components/popover/index.ts +4 -0
- package/source/components/popover/passport.json +238 -0
- package/source/components/popover/react/Popover.tsx +202 -0
- package/source/components/popover/react/locale.ts +5 -0
- package/source/components/popover/react/props.ts +4 -0
- package/source/components/popover/styles.css +148 -0
- package/source/components/progress/README.md +38 -0
- package/source/components/progress/core/index.ts +2 -0
- package/source/components/progress/core/progress.ts +40 -0
- package/source/components/progress/core/types.ts +23 -0
- package/source/components/progress/index.ts +7 -0
- package/source/components/progress/passport.json +270 -0
- package/source/components/progress/react/CircularProgress.tsx +106 -0
- package/source/components/progress/react/Progress.tsx +113 -0
- package/source/components/progress/react/locale.ts +7 -0
- package/source/components/progress/react/props.ts +6 -0
- package/source/components/progress/styles.css +200 -0
- package/source/components/radio-group/README.md +58 -0
- package/source/components/radio-group/core/group.ts +36 -0
- package/source/components/radio-group/core/index.ts +2 -0
- package/source/components/radio-group/core/types.ts +20 -0
- package/source/components/radio-group/index.ts +9 -0
- package/source/components/radio-group/passport.json +477 -0
- package/source/components/radio-group/react/Radio.tsx +144 -0
- package/source/components/radio-group/react/RadioGroup.tsx +179 -0
- package/source/components/radio-group/react/context.ts +18 -0
- package/source/components/radio-group/react/locale.ts +5 -0
- package/source/components/radio-group/react/props.ts +12 -0
- package/source/components/radio-group/styles.css +269 -0
- package/source/components/shared/README.md +54 -0
- package/source/components/shared/core/agent/adapter.ts +65 -0
- package/source/components/shared/core/agent/history.ts +120 -0
- package/source/components/shared/core/agent/index.ts +46 -0
- package/source/components/shared/core/agent/numbers.ts +217 -0
- package/source/components/shared/core/agent/schema.ts +180 -0
- package/source/components/shared/core/agent/types.ts +169 -0
- package/source/components/shared/core/agent/webmcp.ts +328 -0
- package/source/components/shared/core/cx.ts +9 -0
- package/source/components/shared/core/field.ts +35 -0
- package/source/components/shared/core/position.ts +124 -0
- package/source/components/shared/core/text.ts +14 -0
- package/source/components/shared/index.ts +17 -0
- package/source/components/shared/react/GramproAIProvider.tsx +50 -0
- package/source/components/shared/react/Popover.tsx +189 -0
- package/source/components/shared/react/icons.tsx +74 -0
- package/source/components/shared/react/useAskAgent.ts +217 -0
- package/source/components/shared/react/useControllableState.ts +42 -0
- package/source/components/shared/styles.css +79 -0
- package/source/components/shared/version.json +4 -0
- package/source/components/shared/version.ts +6 -0
- package/source/components/skeleton/README.md +58 -0
- package/source/components/skeleton/core/index.ts +3 -0
- package/source/components/skeleton/core/lines.ts +25 -0
- package/source/components/skeleton/core/types.ts +5 -0
- package/source/components/skeleton/index.ts +5 -0
- package/source/components/skeleton/passport.json +251 -0
- package/source/components/skeleton/react/Empty.tsx +51 -0
- package/source/components/skeleton/react/Skeleton.tsx +92 -0
- package/source/components/skeleton/react/props.ts +4 -0
- package/source/components/skeleton/styles.css +185 -0
- package/source/components/spinner/README.md +29 -0
- package/source/components/spinner/core/index.ts +3 -0
- package/source/components/spinner/core/types.ts +28 -0
- package/source/components/spinner/core/visibility.ts +34 -0
- package/source/components/spinner/index.ts +6 -0
- package/source/components/spinner/passport.json +245 -0
- package/source/components/spinner/react/Spinner.tsx +96 -0
- package/source/components/spinner/react/locale.ts +5 -0
- package/source/components/spinner/react/props.ts +4 -0
- package/source/components/spinner/react/useDelayedLoading.ts +39 -0
- package/source/components/spinner/styles.css +173 -0
- package/source/components/switch/README.md +46 -0
- package/source/components/switch/core/index.ts +2 -0
- package/source/components/switch/core/toggle.ts +54 -0
- package/source/components/switch/core/types.ts +9 -0
- package/source/components/switch/index.ts +5 -0
- package/source/components/switch/passport.json +421 -0
- package/source/components/switch/react/Switch.tsx +219 -0
- package/source/components/switch/react/locale.ts +5 -0
- package/source/components/switch/react/props.ts +12 -0
- package/source/components/switch/styles.css +227 -0
- package/source/components/tabs/README.md +32 -0
- package/source/components/tabs/core/index.ts +3 -0
- package/source/components/tabs/core/navigation.ts +54 -0
- package/source/components/tabs/core/types.ts +16 -0
- package/source/components/tabs/index.ts +5 -0
- package/source/components/tabs/passport.json +315 -0
- package/source/components/tabs/react/Tabs.tsx +306 -0
- package/source/components/tabs/react/context.ts +21 -0
- package/source/components/tabs/styles.css +263 -0
- package/source/components/textarea/README.md +39 -0
- package/source/components/textarea/core/count.ts +5 -0
- package/source/components/textarea/core/index.ts +4 -0
- package/source/components/textarea/core/size.ts +23 -0
- package/source/components/textarea/core/types.ts +17 -0
- package/source/components/textarea/index.ts +5 -0
- package/source/components/textarea/passport.json +382 -0
- package/source/components/textarea/react/Textarea.tsx +208 -0
- package/source/components/textarea/react/locale.ts +5 -0
- package/source/components/textarea/react/props.ts +4 -0
- package/source/components/textarea/styles.css +158 -0
- package/source/components/toaster/README.md +128 -0
- package/source/components/toaster/core/api.ts +87 -0
- package/source/components/toaster/core/index.ts +14 -0
- package/source/components/toaster/core/store.ts +211 -0
- package/source/components/toaster/core/toast.ts +12 -0
- package/source/components/toaster/core/types.ts +78 -0
- package/source/components/toaster/index.ts +6 -0
- package/source/components/toaster/passport.json +221 -0
- package/source/components/toaster/react/ToastItem.tsx +164 -0
- package/source/components/toaster/react/Toaster.tsx +187 -0
- package/source/components/toaster/react/icons.tsx +23 -0
- package/source/components/toaster/react/locale.ts +6 -0
- package/source/components/toaster/react/props.ts +15 -0
- package/source/components/toaster/react/useToasts.ts +11 -0
- package/source/components/toaster/styles.css +282 -0
- package/source/components/tooltip/README.md +43 -0
- package/source/components/tooltip/core/index.ts +4 -0
- package/source/components/tooltip/core/types.ts +4 -0
- package/source/components/tooltip/core/visibility.ts +34 -0
- package/source/components/tooltip/index.ts +3 -0
- package/source/components/tooltip/passport.json +170 -0
- package/source/components/tooltip/react/Tooltip.tsx +196 -0
- package/source/components/tooltip/react/props.ts +4 -0
- package/source/components/tooltip/styles.css +71 -0
- package/source/fallback/index.tsx +11 -0
- package/source/globalStyle.ts +74 -0
- package/source/hooks/SelectionHooks/type.ts +4 -0
- package/source/hooks/SelectionHooks/useClickOutside.ts +22 -0
- package/source/hooks/SelectionHooks/useMultiSelectState.ts +64 -0
- package/source/hooks/SelectionHooks/useSelectData.ts +58 -0
- package/source/hooks/SelectionHooks/useSelectState.ts +36 -0
- package/source/icon/Icon.tsx +102 -0
- package/source/icon/iconPaths.ts +206 -0
- package/source/legacy-components/bargraph/index.tsx +95 -0
- package/source/legacy-components/bargraph/type.ts +12 -0
- package/source/legacy-components/breadcrumb/index.tsx +66 -0
- package/source/legacy-components/breadcrumb/types.ts +10 -0
- package/source/legacy-components/button/index.tsx +42 -0
- package/source/legacy-components/card/index.tsx +31 -0
- package/source/legacy-components/checkbox/index.tsx +25 -0
- package/source/legacy-components/contextmenu/ContextMenu.tsx +87 -0
- package/source/legacy-components/contextmenu/ContextMenuItem.tsx +30 -0
- package/source/legacy-components/contextmenu/index.ts +2 -0
- package/source/legacy-components/contextmenu/types.ts +19 -0
- package/source/legacy-components/darkmode/index.tsx +55 -0
- package/source/legacy-components/datagrid/context/GridContext.tsx +215 -0
- package/source/legacy-components/datagrid/createTemplate.tsx +82 -0
- package/source/legacy-components/datagrid/hooks/index.ts +6 -0
- package/source/legacy-components/datagrid/hooks/useColumns.ts +33 -0
- package/source/legacy-components/datagrid/hooks/useDataSource.ts +54 -0
- package/source/legacy-components/datagrid/hooks/useFiltering.ts +169 -0
- package/source/legacy-components/datagrid/hooks/usePagination.ts +112 -0
- package/source/legacy-components/datagrid/hooks/useRowSelection.ts +48 -0
- package/source/legacy-components/datagrid/hooks/useSearch.ts +90 -0
- package/source/legacy-components/datagrid/index.tsx +28 -0
- package/source/legacy-components/datagrid/layout/FilterPopup.tsx +92 -0
- package/source/legacy-components/datagrid/layout/GridBody.tsx +184 -0
- package/source/legacy-components/datagrid/layout/GridPagination.tsx +119 -0
- package/source/legacy-components/datagrid/layout/GridToolbar.tsx +109 -0
- package/source/legacy-components/datagrid/layout/index.tsx +68 -0
- package/source/legacy-components/datagrid/type.ts +198 -0
- package/source/legacy-components/datepicker/index.tsx +365 -0
- package/source/legacy-components/datepicker/types.ts +12 -0
- package/source/legacy-components/dialog/index.tsx +44 -0
- package/source/legacy-components/dialog/types.ts +12 -0
- package/source/legacy-components/formrenderer/componentHandles/CheckBoxHandles.tsx +80 -0
- package/source/legacy-components/formrenderer/componentHandles/DatePickerHandles.tsx +93 -0
- package/source/legacy-components/formrenderer/componentHandles/InputHandles.tsx +106 -0
- package/source/legacy-components/formrenderer/componentHandles/MultiHandles.tsx +93 -0
- package/source/legacy-components/formrenderer/componentHandles/SelectHandles.tsx +95 -0
- package/source/legacy-components/formrenderer/helperFunctions.ts +72 -0
- package/source/legacy-components/formrenderer/index.tsx +93 -0
- package/source/legacy-components/formrenderer/types.ts +127 -0
- package/source/legacy-components/input/index.tsx +142 -0
- package/source/legacy-components/input/types.ts +10 -0
- package/source/legacy-components/materialInput/index.tsx +138 -0
- package/source/legacy-components/materialInput/types.ts +16 -0
- package/source/legacy-components/modal/index.tsx +152 -0
- package/source/legacy-components/modal/types.ts +19 -0
- package/source/legacy-components/multiselect/PortalDropDown.tsx +44 -0
- package/source/legacy-components/multiselect/index.tsx +269 -0
- package/source/legacy-components/multiselect/types.ts +26 -0
- package/source/legacy-components/navbar/AuthSection.tsx +98 -0
- package/source/legacy-components/navbar/MobileToggle.tsx +31 -0
- package/source/legacy-components/navbar/NavItemComponent.tsx +119 -0
- package/source/legacy-components/navbar/SearchBar.tsx +55 -0
- package/source/legacy-components/navbar/helperFunctions.ts +27 -0
- package/source/legacy-components/navbar/index.tsx +156 -0
- package/source/legacy-components/navbar/types.ts +69 -0
- package/source/legacy-components/select/PortalDropDown.tsx +59 -0
- package/source/legacy-components/select/index.tsx +249 -0
- package/source/legacy-components/select/types.ts +29 -0
- package/source/legacy-components/sidebar/components/MenuItem.tsx +101 -0
- package/source/legacy-components/sidebar/components/MenuSection.tsx +34 -0
- package/source/legacy-components/sidebar/components/SidebarFooter.tsx +50 -0
- package/source/legacy-components/sidebar/components/SidebarLogo.tsx +24 -0
- package/source/legacy-components/sidebar/components/SidebarMenu.tsx +29 -0
- package/source/legacy-components/sidebar/components/UserProfile.tsx +31 -0
- package/source/legacy-components/sidebar/hooks/useSidebarState.ts +41 -0
- package/source/legacy-components/sidebar/index.tsx +77 -0
- package/source/legacy-components/sidebar/type.ts +42 -0
- package/source/legacy-components/spinner/Stroke.tsx +89 -0
- package/source/legacy-components/spinner/index.tsx +54 -0
- package/source/legacy-components/spinner/types.ts +9 -0
- package/source/legacy-components/tabs/index.tsx +71 -0
- package/source/legacy-components/tabs/types.ts +16 -0
- package/source/legacy-components/textarea/index.tsx +123 -0
- package/source/legacy-components/textarea/types.ts +15 -0
- package/source/legacy-components/toast/ToastComponent.tsx +101 -0
- package/source/legacy-components/toast/ToastIcon.tsx +61 -0
- package/source/legacy-components/toast/index.tsx +42 -0
- package/source/legacy-components/toast/toastStore.ts +42 -0
- package/source/legacy-components/toast/types.ts +18 -0
- package/source/legacy-components/toast/useToast.ts +12 -0
- package/source/legacy-components/uploader/ProgressAnimation.tsx +50 -0
- package/source/legacy-components/uploader/UploadedFilePreview.tsx +130 -0
- package/source/legacy-components/uploader/index.tsx +311 -0
- package/source/legacy-components/uploader/types.ts +30 -0
- package/source/legacy-components/uploader/uploaderIcon.tsx +72 -0
- package/source/legacy-components/uploader/uploaderService.ts +134 -0
- package/source/legacy-components/useUploader/useUploader.tsx +310 -0
- package/source/legacy-components/usepaginateddata/usePaginatedData.ts +174 -0
- package/source/theme.ts +40 -0
- package/source/utils.ts +10 -0
- package/tools/env.cjs +61 -0
- package/tools/passport/cli.cjs +79 -0
- package/tools/passport/extract.cjs +493 -0
- package/tools/passport/index.cjs +185 -0
- package/tools/passport/merge.cjs +131 -0
- package/tools/passport/policy.cjs +65 -0
- package/tools/passport/validate.cjs +277 -0
- package/tools/ts-require.cjs +79 -0
|
@@ -0,0 +1,344 @@
|
|
|
1
|
+
{
|
|
2
|
+
"passportVersion": "1.0.0",
|
|
3
|
+
"identity": {
|
|
4
|
+
"component": "Dialog",
|
|
5
|
+
"folder": "dialog",
|
|
6
|
+
"exports": [
|
|
7
|
+
"Dialog",
|
|
8
|
+
"DialogHost"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"source": {
|
|
12
|
+
"libraryVersion": "2.4.0",
|
|
13
|
+
"files": [
|
|
14
|
+
"core/api.ts",
|
|
15
|
+
"core/dialog.ts",
|
|
16
|
+
"core/index.ts",
|
|
17
|
+
"core/store.ts",
|
|
18
|
+
"core/types.ts",
|
|
19
|
+
"index.ts",
|
|
20
|
+
"react/Dialog.tsx",
|
|
21
|
+
"react/DialogHost.tsx",
|
|
22
|
+
"react/icons.tsx",
|
|
23
|
+
"react/locale.ts",
|
|
24
|
+
"react/props.ts"
|
|
25
|
+
],
|
|
26
|
+
"sourceHash": "sha256:054631ef8ddc464b32edabedea2cf26e4aa7e57a18d596dc6a65081e790283b1"
|
|
27
|
+
},
|
|
28
|
+
"props": [
|
|
29
|
+
{
|
|
30
|
+
"name": "cancelLabel",
|
|
31
|
+
"type": "other",
|
|
32
|
+
"typeText": "ReactNode",
|
|
33
|
+
"required": false,
|
|
34
|
+
"origin": "derived"
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"name": "className",
|
|
38
|
+
"type": "string",
|
|
39
|
+
"typeText": "string | undefined",
|
|
40
|
+
"required": false,
|
|
41
|
+
"origin": "derived"
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
"name": "classNames",
|
|
45
|
+
"type": "other",
|
|
46
|
+
"typeText": "Partial<Record<DialogSlot, string>> | undefined",
|
|
47
|
+
"required": false,
|
|
48
|
+
"origin": "derived"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"name": "confirmLabel",
|
|
52
|
+
"type": "other",
|
|
53
|
+
"typeText": "ReactNode",
|
|
54
|
+
"required": false,
|
|
55
|
+
"origin": "derived"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"name": "defaultValue",
|
|
59
|
+
"type": "string",
|
|
60
|
+
"typeText": "string | undefined",
|
|
61
|
+
"required": false,
|
|
62
|
+
"default": "",
|
|
63
|
+
"origin": "derived"
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
"name": "description",
|
|
67
|
+
"type": "other",
|
|
68
|
+
"typeText": "ReactNode",
|
|
69
|
+
"required": false,
|
|
70
|
+
"origin": "derived"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"name": "dismissible",
|
|
74
|
+
"type": "boolean",
|
|
75
|
+
"typeText": "boolean | undefined",
|
|
76
|
+
"required": false,
|
|
77
|
+
"default": true,
|
|
78
|
+
"origin": "derived",
|
|
79
|
+
"description": "Escape and a backdrop click count as Cancel. Default true.",
|
|
80
|
+
"descriptionOrigin": "jsdoc"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"name": "icon",
|
|
84
|
+
"type": "other",
|
|
85
|
+
"typeText": "ReactNode",
|
|
86
|
+
"required": false,
|
|
87
|
+
"origin": "derived",
|
|
88
|
+
"description": "Replaces the intent's icon; `null` hides it.",
|
|
89
|
+
"descriptionOrigin": "jsdoc"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"name": "id",
|
|
93
|
+
"type": "string",
|
|
94
|
+
"typeText": "string | undefined",
|
|
95
|
+
"required": false,
|
|
96
|
+
"origin": "derived"
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
"name": "inputLabel",
|
|
100
|
+
"type": "other",
|
|
101
|
+
"typeText": "ReactNode",
|
|
102
|
+
"required": false,
|
|
103
|
+
"origin": "derived"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "inputType",
|
|
107
|
+
"type": "enum",
|
|
108
|
+
"values": [
|
|
109
|
+
"email",
|
|
110
|
+
"number",
|
|
111
|
+
"password",
|
|
112
|
+
"tel",
|
|
113
|
+
"text",
|
|
114
|
+
"url"
|
|
115
|
+
],
|
|
116
|
+
"typeText": "'number' | 'email' | 'tel' | 'text' | 'url' | 'password' | undefined",
|
|
117
|
+
"required": false,
|
|
118
|
+
"default": "text",
|
|
119
|
+
"origin": "derived"
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"name": "intent",
|
|
123
|
+
"type": "enum",
|
|
124
|
+
"values": [
|
|
125
|
+
"danger",
|
|
126
|
+
"default",
|
|
127
|
+
"info",
|
|
128
|
+
"success",
|
|
129
|
+
"warning"
|
|
130
|
+
],
|
|
131
|
+
"typeText": "DialogIntent | undefined",
|
|
132
|
+
"required": false,
|
|
133
|
+
"default": "default",
|
|
134
|
+
"origin": "derived",
|
|
135
|
+
"description": "Sets the icon and the confirm button's color. `danger` also focuses Cancel first.",
|
|
136
|
+
"descriptionOrigin": "jsdoc"
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
"name": "kind",
|
|
140
|
+
"type": "enum",
|
|
141
|
+
"values": [
|
|
142
|
+
"alert",
|
|
143
|
+
"confirm",
|
|
144
|
+
"prompt"
|
|
145
|
+
],
|
|
146
|
+
"typeText": "DialogKind | undefined",
|
|
147
|
+
"required": false,
|
|
148
|
+
"default": "confirm",
|
|
149
|
+
"origin": "derived",
|
|
150
|
+
"description": "`alert` has one button, `confirm` two, `prompt` adds a text field. Default `confirm`.",
|
|
151
|
+
"descriptionOrigin": "jsdoc"
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
"name": "localeText",
|
|
155
|
+
"type": "other",
|
|
156
|
+
"typeText": "Partial<DialogLocaleText> | undefined",
|
|
157
|
+
"required": false,
|
|
158
|
+
"origin": "derived"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"name": "onClose",
|
|
162
|
+
"type": "function",
|
|
163
|
+
"signature": "((action: DialogAction, value: string) => void) | undefined",
|
|
164
|
+
"required": false,
|
|
165
|
+
"origin": "derived",
|
|
166
|
+
"description": "The user answered. Set `open` to false here.",
|
|
167
|
+
"descriptionOrigin": "jsdoc"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
"name": "onConfirm",
|
|
171
|
+
"type": "function",
|
|
172
|
+
"signature": "((value: string) => void | Promise<void>) | undefined",
|
|
173
|
+
"required": false,
|
|
174
|
+
"origin": "derived",
|
|
175
|
+
"description": "Runs on Confirm, with the prompt's value. While its promise is pending the\nbuttons show progress; if it throws, the error message is shown and the\ndialog stays open.",
|
|
176
|
+
"descriptionOrigin": "jsdoc"
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
"name": "onExited",
|
|
180
|
+
"type": "function",
|
|
181
|
+
"signature": "(() => void) | undefined",
|
|
182
|
+
"required": false,
|
|
183
|
+
"origin": "derived",
|
|
184
|
+
"description": "The exit animation finished.",
|
|
185
|
+
"descriptionOrigin": "jsdoc"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"name": "open",
|
|
189
|
+
"type": "boolean",
|
|
190
|
+
"typeText": "boolean",
|
|
191
|
+
"required": true,
|
|
192
|
+
"origin": "derived"
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
"name": "placeholder",
|
|
196
|
+
"type": "string",
|
|
197
|
+
"typeText": "string | undefined",
|
|
198
|
+
"required": false,
|
|
199
|
+
"origin": "derived"
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
"name": "required",
|
|
203
|
+
"type": "boolean",
|
|
204
|
+
"typeText": "boolean | undefined",
|
|
205
|
+
"required": false,
|
|
206
|
+
"default": false,
|
|
207
|
+
"origin": "derived"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"name": "size",
|
|
211
|
+
"type": "enum",
|
|
212
|
+
"values": [
|
|
213
|
+
"md",
|
|
214
|
+
"sm"
|
|
215
|
+
],
|
|
216
|
+
"typeText": "DialogSize | undefined",
|
|
217
|
+
"required": false,
|
|
218
|
+
"default": "sm",
|
|
219
|
+
"origin": "derived"
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"name": "store",
|
|
223
|
+
"type": "other",
|
|
224
|
+
"typeText": "DialogStore | undefined",
|
|
225
|
+
"required": false,
|
|
226
|
+
"default": "dialogStore",
|
|
227
|
+
"origin": "derived",
|
|
228
|
+
"description": "A store from `createDialogStore()`. Defaults to the one behind `dialog`.",
|
|
229
|
+
"descriptionOrigin": "jsdoc"
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
"name": "style",
|
|
233
|
+
"type": "other",
|
|
234
|
+
"typeText": "CSSProperties | undefined",
|
|
235
|
+
"required": false,
|
|
236
|
+
"origin": "derived"
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
"name": "title",
|
|
240
|
+
"type": "other",
|
|
241
|
+
"typeText": "ReactNode",
|
|
242
|
+
"required": true,
|
|
243
|
+
"origin": "derived"
|
|
244
|
+
},
|
|
245
|
+
{
|
|
246
|
+
"name": "validate",
|
|
247
|
+
"type": "function",
|
|
248
|
+
"signature": "((value: string) => string | null | undefined) | undefined",
|
|
249
|
+
"required": false,
|
|
250
|
+
"origin": "derived",
|
|
251
|
+
"description": "Return a message to block confirming.",
|
|
252
|
+
"descriptionOrigin": "jsdoc"
|
|
253
|
+
}
|
|
254
|
+
],
|
|
255
|
+
"inherits": [
|
|
256
|
+
{
|
|
257
|
+
"from": "PromptOptions",
|
|
258
|
+
"omitted": [
|
|
259
|
+
"onConfirm"
|
|
260
|
+
],
|
|
261
|
+
"passthrough": true
|
|
262
|
+
}
|
|
263
|
+
],
|
|
264
|
+
"events": [
|
|
265
|
+
{
|
|
266
|
+
"name": "onClose",
|
|
267
|
+
"signature": "((action: DialogAction, value: string) => void) | undefined"
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
"name": "onConfirm",
|
|
271
|
+
"signature": "((value: string) => void | Promise<void>) | undefined"
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
"name": "onExited",
|
|
275
|
+
"signature": "(() => void) | undefined"
|
|
276
|
+
}
|
|
277
|
+
],
|
|
278
|
+
"slots": [
|
|
279
|
+
"root",
|
|
280
|
+
"body",
|
|
281
|
+
"icon",
|
|
282
|
+
"title",
|
|
283
|
+
"description",
|
|
284
|
+
"input",
|
|
285
|
+
"actions",
|
|
286
|
+
"confirm",
|
|
287
|
+
"cancel"
|
|
288
|
+
],
|
|
289
|
+
"states": [
|
|
290
|
+
{
|
|
291
|
+
"attr": "data-autofocus"
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
"attr": "data-intent",
|
|
295
|
+
"values": [
|
|
296
|
+
"danger",
|
|
297
|
+
"info",
|
|
298
|
+
"success",
|
|
299
|
+
"warning"
|
|
300
|
+
]
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"attr": "data-size",
|
|
304
|
+
"values": [
|
|
305
|
+
"md"
|
|
306
|
+
]
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
"attr": "data-state"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"attr": "data-theme",
|
|
313
|
+
"values": [
|
|
314
|
+
"dark",
|
|
315
|
+
"light"
|
|
316
|
+
]
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
"attr": "data-variant",
|
|
320
|
+
"values": [
|
|
321
|
+
"danger",
|
|
322
|
+
"primary",
|
|
323
|
+
"secondary"
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
],
|
|
327
|
+
"accessibility": {
|
|
328
|
+
"supplied": [],
|
|
329
|
+
"required": []
|
|
330
|
+
},
|
|
331
|
+
"composition": {},
|
|
332
|
+
"operations": {},
|
|
333
|
+
"intentDomains": [],
|
|
334
|
+
"safeMutations": {},
|
|
335
|
+
"examples": [],
|
|
336
|
+
"coverage": {
|
|
337
|
+
"propsTotal": 25,
|
|
338
|
+
"propsDescribed": 9,
|
|
339
|
+
"describedPct": 36,
|
|
340
|
+
"authoredSections": [
|
|
341
|
+
"accessibility"
|
|
342
|
+
]
|
|
343
|
+
}
|
|
344
|
+
}
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
useEffect,
|
|
5
|
+
useEffectEvent,
|
|
6
|
+
useId,
|
|
7
|
+
useMemo,
|
|
8
|
+
useRef,
|
|
9
|
+
useState,
|
|
10
|
+
type CSSProperties,
|
|
11
|
+
type MouseEvent,
|
|
12
|
+
type ReactNode,
|
|
13
|
+
} from "react";
|
|
14
|
+
import type {
|
|
15
|
+
DialogIntent,
|
|
16
|
+
DialogKind,
|
|
17
|
+
DialogLocaleText,
|
|
18
|
+
PromptOptions,
|
|
19
|
+
} from "../core/types";
|
|
20
|
+
import { DangerIcon, InfoIcon, SpinnerIcon, SuccessIcon, WarningIcon } from "./icons";
|
|
21
|
+
import { defaultDialogText } from "./locale";
|
|
22
|
+
import { cx, type DialogSlot } from "./props";
|
|
23
|
+
|
|
24
|
+
/** Matches the CSS transition, so content stays mounted while the dialog animates out. */
|
|
25
|
+
const EXIT_DURATION = 200;
|
|
26
|
+
|
|
27
|
+
const INTENT_ICONS: Record<DialogIntent, ReactNode> = {
|
|
28
|
+
default: null,
|
|
29
|
+
info: <InfoIcon />,
|
|
30
|
+
success: <SuccessIcon />,
|
|
31
|
+
warning: <WarningIcon />,
|
|
32
|
+
danger: <DangerIcon />,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export type DialogAction = "confirm" | "cancel";
|
|
36
|
+
|
|
37
|
+
export interface DialogProps extends Omit<PromptOptions, "onConfirm"> {
|
|
38
|
+
open: boolean;
|
|
39
|
+
/** `alert` has one button, `confirm` two, `prompt` adds a text field. Default `confirm`. */
|
|
40
|
+
kind?: DialogKind;
|
|
41
|
+
/**
|
|
42
|
+
* Runs on Confirm, with the prompt's value. While its promise is pending the
|
|
43
|
+
* buttons show progress; if it throws, the error message is shown and the
|
|
44
|
+
* dialog stays open.
|
|
45
|
+
*/
|
|
46
|
+
onConfirm?(value: string): void | Promise<void>;
|
|
47
|
+
/** The user answered. Set `open` to false here. */
|
|
48
|
+
onClose?(action: DialogAction, value: string): void;
|
|
49
|
+
/** The exit animation finished. */
|
|
50
|
+
onExited?(): void;
|
|
51
|
+
id?: string;
|
|
52
|
+
className?: string;
|
|
53
|
+
classNames?: Partial<Record<DialogSlot, string>>;
|
|
54
|
+
style?: CSSProperties;
|
|
55
|
+
localeText?: Partial<DialogLocaleText>;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
const outside = (event: MouseEvent<HTMLDialogElement>) => {
|
|
59
|
+
if (event.target !== event.currentTarget) return false;
|
|
60
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
61
|
+
const { clientX: x, clientY: y } = event;
|
|
62
|
+
return x < rect.left || x > rect.right || y < rect.top || y > rect.bottom;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/** An alert, confirm or prompt dialog. For the promise API, mount `<DialogHost />` and call `dialog.confirm()`. */
|
|
66
|
+
export function Dialog(props: DialogProps) {
|
|
67
|
+
const {
|
|
68
|
+
open,
|
|
69
|
+
kind = "confirm",
|
|
70
|
+
title,
|
|
71
|
+
description,
|
|
72
|
+
intent = "default",
|
|
73
|
+
icon,
|
|
74
|
+
confirmLabel,
|
|
75
|
+
cancelLabel,
|
|
76
|
+
dismissible = true,
|
|
77
|
+
size = "sm",
|
|
78
|
+
defaultValue = "",
|
|
79
|
+
placeholder,
|
|
80
|
+
inputLabel,
|
|
81
|
+
inputType = "text",
|
|
82
|
+
required = false,
|
|
83
|
+
validate,
|
|
84
|
+
onConfirm,
|
|
85
|
+
onClose,
|
|
86
|
+
onExited,
|
|
87
|
+
id: idProp,
|
|
88
|
+
className,
|
|
89
|
+
classNames,
|
|
90
|
+
style,
|
|
91
|
+
localeText,
|
|
92
|
+
} = props;
|
|
93
|
+
|
|
94
|
+
const reactId = useId();
|
|
95
|
+
const id = idProp ?? reactId;
|
|
96
|
+
const text = useMemo(() => ({ ...defaultDialogText, ...localeText }), [localeText]);
|
|
97
|
+
const dialogRef = useRef<HTMLDialogElement>(null);
|
|
98
|
+
const pressStartedOutside = useRef(false);
|
|
99
|
+
|
|
100
|
+
const [value, setValue] = useState(defaultValue);
|
|
101
|
+
const [error, setError] = useState<string | null>(null);
|
|
102
|
+
const [pending, setPending] = useState(false);
|
|
103
|
+
|
|
104
|
+
// Reset each time it opens, and keep content mounted through the exit transition.
|
|
105
|
+
const [previousOpen, setPreviousOpen] = useState(open);
|
|
106
|
+
const [closing, setClosing] = useState(false);
|
|
107
|
+
if (previousOpen !== open) {
|
|
108
|
+
setPreviousOpen(open);
|
|
109
|
+
setClosing(!open);
|
|
110
|
+
if (open) {
|
|
111
|
+
setValue(defaultValue);
|
|
112
|
+
setError(null);
|
|
113
|
+
setPending(false);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const exited = useEffectEvent(() => onExited?.());
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
if (!closing) return;
|
|
120
|
+
const timer = setTimeout(() => {
|
|
121
|
+
setClosing(false);
|
|
122
|
+
exited();
|
|
123
|
+
}, EXIT_DURATION);
|
|
124
|
+
return () => clearTimeout(timer);
|
|
125
|
+
}, [closing]);
|
|
126
|
+
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
const element = dialogRef.current;
|
|
129
|
+
if (!element) return;
|
|
130
|
+
if (open && !element.open) {
|
|
131
|
+
element.showModal();
|
|
132
|
+
element.querySelector<HTMLElement>("[data-autofocus]")?.focus();
|
|
133
|
+
} else if (!open && element.open) {
|
|
134
|
+
element.close();
|
|
135
|
+
}
|
|
136
|
+
}, [open]);
|
|
137
|
+
|
|
138
|
+
const confirm = async () => {
|
|
139
|
+
if (pending || !open) return;
|
|
140
|
+
if (kind === "prompt") {
|
|
141
|
+
const message = required && !value.trim() ? text.required : validate?.(value);
|
|
142
|
+
if (message) {
|
|
143
|
+
setError(message);
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (onConfirm) {
|
|
148
|
+
setPending(true);
|
|
149
|
+
setError(null);
|
|
150
|
+
try {
|
|
151
|
+
await onConfirm(value);
|
|
152
|
+
} catch (reason) {
|
|
153
|
+
setError(reason instanceof Error ? reason.message : String(reason));
|
|
154
|
+
setPending(false);
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
setPending(false);
|
|
158
|
+
}
|
|
159
|
+
onClose?.("confirm", value);
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const cancel = () => {
|
|
163
|
+
if (pending || !open) return;
|
|
164
|
+
onClose?.("cancel", value);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const mounted = open || closing;
|
|
168
|
+
const resolvedIcon = icon !== undefined ? icon : INTENT_ICONS[intent];
|
|
169
|
+
// A destructive confirm starts on Cancel, so a stray Enter doesn't delete anything.
|
|
170
|
+
const focusCancel = kind === "confirm" && intent === "danger";
|
|
171
|
+
const errorId = `${id}-error`;
|
|
172
|
+
|
|
173
|
+
return (
|
|
174
|
+
<dialog
|
|
175
|
+
ref={dialogRef}
|
|
176
|
+
id={id}
|
|
177
|
+
role="alertdialog"
|
|
178
|
+
aria-labelledby={`${id}-title`}
|
|
179
|
+
aria-describedby={description ? `${id}-description` : undefined}
|
|
180
|
+
className={cx("dl-root", classNames?.root, className)}
|
|
181
|
+
style={style}
|
|
182
|
+
data-intent={intent}
|
|
183
|
+
data-size={size}
|
|
184
|
+
data-state={open ? "open" : "closed"}
|
|
185
|
+
onCancel={(event) => {
|
|
186
|
+
event.preventDefault();
|
|
187
|
+
if (dismissible) cancel();
|
|
188
|
+
}}
|
|
189
|
+
onPointerDown={(event) => {
|
|
190
|
+
pressStartedOutside.current = outside(event);
|
|
191
|
+
}}
|
|
192
|
+
onClick={(event) => {
|
|
193
|
+
if (dismissible && pressStartedOutside.current && outside(event)) cancel();
|
|
194
|
+
pressStartedOutside.current = false;
|
|
195
|
+
}}
|
|
196
|
+
>
|
|
197
|
+
{mounted && (
|
|
198
|
+
<form
|
|
199
|
+
className="dl-form"
|
|
200
|
+
noValidate
|
|
201
|
+
onSubmit={(event) => {
|
|
202
|
+
event.preventDefault();
|
|
203
|
+
void confirm();
|
|
204
|
+
}}
|
|
205
|
+
>
|
|
206
|
+
<div className={cx("dl-body", classNames?.body)}>
|
|
207
|
+
{resolvedIcon != null && (
|
|
208
|
+
<span className={cx("dl-icon", classNames?.icon)} aria-hidden="true">
|
|
209
|
+
{resolvedIcon}
|
|
210
|
+
</span>
|
|
211
|
+
)}
|
|
212
|
+
<div className="dl-text">
|
|
213
|
+
<h2 id={`${id}-title`} className={cx("dl-title", classNames?.title)}>
|
|
214
|
+
{title}
|
|
215
|
+
</h2>
|
|
216
|
+
{description && (
|
|
217
|
+
<div id={`${id}-description`} className={cx("dl-description", classNames?.description)}>
|
|
218
|
+
{description}
|
|
219
|
+
</div>
|
|
220
|
+
)}
|
|
221
|
+
{kind === "prompt" && (
|
|
222
|
+
<label className="dl-field">
|
|
223
|
+
{inputLabel && <span className="dl-label">{inputLabel}</span>}
|
|
224
|
+
<input
|
|
225
|
+
className={cx("dl-input", classNames?.input)}
|
|
226
|
+
type={inputType}
|
|
227
|
+
value={value}
|
|
228
|
+
placeholder={placeholder}
|
|
229
|
+
required={required}
|
|
230
|
+
readOnly={pending}
|
|
231
|
+
data-autofocus=""
|
|
232
|
+
aria-invalid={error ? true : undefined}
|
|
233
|
+
aria-describedby={error ? errorId : undefined}
|
|
234
|
+
onChange={(event) => {
|
|
235
|
+
setValue(event.target.value);
|
|
236
|
+
if (error) setError(null);
|
|
237
|
+
}}
|
|
238
|
+
/>
|
|
239
|
+
</label>
|
|
240
|
+
)}
|
|
241
|
+
{error && (
|
|
242
|
+
<p id={errorId} className="dl-error" role="alert">
|
|
243
|
+
{error}
|
|
244
|
+
</p>
|
|
245
|
+
)}
|
|
246
|
+
</div>
|
|
247
|
+
</div>
|
|
248
|
+
|
|
249
|
+
<div className={cx("dl-actions", classNames?.actions)}>
|
|
250
|
+
{kind !== "alert" && (
|
|
251
|
+
<button
|
|
252
|
+
type="button"
|
|
253
|
+
className={cx("dl-button", classNames?.cancel)}
|
|
254
|
+
data-variant="secondary"
|
|
255
|
+
data-autofocus={focusCancel ? "" : undefined}
|
|
256
|
+
aria-disabled={pending || undefined}
|
|
257
|
+
onClick={cancel}
|
|
258
|
+
>
|
|
259
|
+
{cancelLabel ?? text.cancel}
|
|
260
|
+
</button>
|
|
261
|
+
)}
|
|
262
|
+
<button
|
|
263
|
+
type="submit"
|
|
264
|
+
className={cx("dl-button", classNames?.confirm)}
|
|
265
|
+
data-variant={intent === "danger" ? "danger" : "primary"}
|
|
266
|
+
data-autofocus={!focusCancel && kind !== "prompt" ? "" : undefined}
|
|
267
|
+
// aria-disabled rather than disabled, so focus stays on the button while it works.
|
|
268
|
+
aria-disabled={pending || undefined}
|
|
269
|
+
aria-busy={pending || undefined}
|
|
270
|
+
>
|
|
271
|
+
{pending && <SpinnerIcon />}
|
|
272
|
+
{confirmLabel ?? (kind === "alert" ? text.ok : text.confirm)}
|
|
273
|
+
</button>
|
|
274
|
+
</div>
|
|
275
|
+
</form>
|
|
276
|
+
)}
|
|
277
|
+
</dialog>
|
|
278
|
+
);
|
|
279
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useSyncExternalStore, type CSSProperties } from "react";
|
|
4
|
+
import { dialogStore } from "../core/dialog";
|
|
5
|
+
import type { DialogStore } from "../core/store";
|
|
6
|
+
import type { DialogLocaleText, DialogRequest } from "../core/types";
|
|
7
|
+
import { Dialog } from "./Dialog";
|
|
8
|
+
import type { DialogSlot } from "./props";
|
|
9
|
+
|
|
10
|
+
export interface DialogHostProps {
|
|
11
|
+
/** A store from `createDialogStore()`. Defaults to the one behind `dialog`. */
|
|
12
|
+
store?: DialogStore;
|
|
13
|
+
/** Applied to every dialog this host shows. */
|
|
14
|
+
className?: string;
|
|
15
|
+
classNames?: Partial<Record<DialogSlot, string>>;
|
|
16
|
+
style?: CSSProperties;
|
|
17
|
+
localeText?: Partial<DialogLocaleText>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Mount once. Shows the dialogs requested through `dialog.alert/confirm/prompt`, one at a time. */
|
|
21
|
+
export function DialogHost({ store = dialogStore, ...shared }: DialogHostProps) {
|
|
22
|
+
const { queue } = useSyncExternalStore(store.subscribe, store.getSnapshot, store.getServerSnapshot);
|
|
23
|
+
const current = queue[0];
|
|
24
|
+
|
|
25
|
+
// Keep the last dialog rendered while it animates out.
|
|
26
|
+
const [shown, setShown] = useState<DialogRequest | undefined>(current);
|
|
27
|
+
if (current && current !== shown) setShown(current);
|
|
28
|
+
|
|
29
|
+
if (!shown) return null;
|
|
30
|
+
|
|
31
|
+
return (
|
|
32
|
+
<Dialog
|
|
33
|
+
key={shown.id}
|
|
34
|
+
{...shown.options}
|
|
35
|
+
{...shared}
|
|
36
|
+
open={shown === current}
|
|
37
|
+
kind={shown.kind}
|
|
38
|
+
onConfirm={shown.options.onConfirm}
|
|
39
|
+
onClose={(action, value) => store.resolve(shown.id, action === "confirm", value)}
|
|
40
|
+
onExited={() => {
|
|
41
|
+
if (store.getSnapshot().queue.length === 0) setShown(undefined);
|
|
42
|
+
}}
|
|
43
|
+
/>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AlertCircleIcon,
|
|
3
|
+
InfoIcon as SharedInfo,
|
|
4
|
+
SpinnerIcon as SharedSpinner,
|
|
5
|
+
SuccessIcon as SharedSuccess,
|
|
6
|
+
WarningIcon as SharedWarning,
|
|
7
|
+
type IconProps,
|
|
8
|
+
} from "../../shared/react/icons";
|
|
9
|
+
|
|
10
|
+
/*
|
|
11
|
+
* The dialog draws its status icon at 20px, beside the title.
|
|
12
|
+
*/
|
|
13
|
+
export const InfoIcon = (p: IconProps) => <SharedInfo width={20} height={20} {...p} />;
|
|
14
|
+
export const SuccessIcon = (p: IconProps) => <SharedSuccess width={20} height={20} {...p} />;
|
|
15
|
+
export const WarningIcon = (p: IconProps) => <SharedWarning width={20} height={20} {...p} />;
|
|
16
|
+
export const DangerIcon = (p: IconProps) => <AlertCircleIcon width={20} height={20} {...p} />;
|
|
17
|
+
|
|
18
|
+
export const SpinnerIcon = (p: IconProps) => (
|
|
19
|
+
<SharedSpinner width={14} height={14} {...p} className="dl-spinner" />
|
|
20
|
+
);
|