@grampro/kit 0.0.0-stage → 2.4.1
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 +173 -0
- package/LICENSE +15 -0
- package/README.md +193 -2
- package/index.cjs +1410 -0
- package/package.json +77 -6
- 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,29 @@
|
|
|
1
|
+
# Spinner
|
|
2
|
+
|
|
3
|
+
A loading indicator for React 19, on its own or covering busy content, styled to
|
|
4
|
+
match the rest of the library. No runtime dependencies besides React.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { Spinner, useDelayedLoading } from "@/components/spinner";
|
|
8
|
+
import "@/components/spinner/styles.css";
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
<Spinner /> {/* 24 px ring in the current text color */}
|
|
13
|
+
<Spinner size="sm" showLabel label="Saving…" />
|
|
14
|
+
<Spinner loading={isPending} delay={250} minDuration={600}>
|
|
15
|
+
<Chart /> {/* covered and inert while loading */}
|
|
16
|
+
</Spinner>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
| Prop | Default | Description |
|
|
20
|
+
| --- | --- | --- |
|
|
21
|
+
| `loading` | `true` | With children, covers them while true. |
|
|
22
|
+
| `size` | `md` | `xs` 12 · `sm` 16 · `md` 24 · `lg` 32 · `xl` 48, or pixels. |
|
|
23
|
+
| `variant` | `ring` | `ring` or `dots`. |
|
|
24
|
+
| `label` / `showLabel` | "Loading" / `false` | Announced text; optionally shown. |
|
|
25
|
+
| `delay` / `minDuration` | `0` / `0` | Wait before showing; stay at least this long once shown. |
|
|
26
|
+
| `className`, `classNames`, `style`, `localeText` | — | Slots: `root`, `status`, `indicator`, `label`, `content`, `overlay`. |
|
|
27
|
+
|
|
28
|
+
`useDelayedLoading(loading, { delay, minDuration })` applies the same timing to
|
|
29
|
+
any loading UI. `stepVisibility` is the framework-free rule behind it.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type SpinnerSize = "xs" | "sm" | "md" | "lg" | "xl";
|
|
2
|
+
|
|
3
|
+
export type SpinnerVariant = "ring" | "dots";
|
|
4
|
+
|
|
5
|
+
export interface VisibilityOptions {
|
|
6
|
+
/** Wait this long before showing, so fast work never flashes a spinner. Default 0. */
|
|
7
|
+
delay?: number;
|
|
8
|
+
/** Once shown, stay at least this long, so it doesn't blink off. Default 0. */
|
|
9
|
+
minDuration?: number;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface VisibilityMarks {
|
|
13
|
+
visible: boolean;
|
|
14
|
+
/** When `loading` last turned true, or null while not loading. */
|
|
15
|
+
loadingSince: number | null;
|
|
16
|
+
/** When the spinner last appeared, or null while hidden. */
|
|
17
|
+
visibleSince: number | null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface VisibilityStep {
|
|
21
|
+
visible: boolean;
|
|
22
|
+
/** Milliseconds until the answer can change, or null when it won't on its own. */
|
|
23
|
+
recheckIn: number | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SpinnerLocaleText {
|
|
27
|
+
loading: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { SpinnerSize, VisibilityMarks, VisibilityOptions, VisibilityStep } from "./types";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Whether a spinner should be on screen right now. A short `delay` hides work
|
|
5
|
+
* that finishes quickly; a `minDuration` keeps a spinner that did appear from
|
|
6
|
+
* vanishing a moment later. Both avoid the flicker of a spinner that blinks.
|
|
7
|
+
*/
|
|
8
|
+
export function stepVisibility(
|
|
9
|
+
loading: boolean,
|
|
10
|
+
marks: VisibilityMarks,
|
|
11
|
+
now: number,
|
|
12
|
+
options: VisibilityOptions = {},
|
|
13
|
+
): VisibilityStep {
|
|
14
|
+
const delay = Math.max(0, options.delay ?? 0);
|
|
15
|
+
const minDuration = Math.max(0, options.minDuration ?? 0);
|
|
16
|
+
|
|
17
|
+
if (loading && !marks.visible) {
|
|
18
|
+
const waited = now - (marks.loadingSince ?? now);
|
|
19
|
+
return waited >= delay ? { visible: true, recheckIn: null } : { visible: false, recheckIn: delay - waited };
|
|
20
|
+
}
|
|
21
|
+
if (!loading && marks.visible) {
|
|
22
|
+
const shown = now - (marks.visibleSince ?? now);
|
|
23
|
+
return shown >= minDuration
|
|
24
|
+
? { visible: false, recheckIn: null }
|
|
25
|
+
: { visible: true, recheckIn: minDuration - shown };
|
|
26
|
+
}
|
|
27
|
+
return { visible: marks.visible, recheckIn: null };
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const SIZES: Record<SpinnerSize, number> = { xs: 12, sm: 16, md: 24, lg: 32, xl: 48 };
|
|
31
|
+
|
|
32
|
+
/** Pixel size for a named size; numbers pass through. */
|
|
33
|
+
export const spinnerPixels = (size: SpinnerSize | number = "md") =>
|
|
34
|
+
typeof size === "number" ? Math.max(1, size) : SIZES[size];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Spinner } from "./react/Spinner";
|
|
2
|
+
export type { SpinnerProps } from "./react/Spinner";
|
|
3
|
+
export { useDelayedLoading } from "./react/useDelayedLoading";
|
|
4
|
+
export { defaultSpinnerText } from "./react/locale";
|
|
5
|
+
export type { SpinnerSlot } from "./react/props";
|
|
6
|
+
export * from "./core";
|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
{
|
|
2
|
+
"passportVersion": "1.0.0",
|
|
3
|
+
"identity": {
|
|
4
|
+
"component": "Spinner",
|
|
5
|
+
"folder": "spinner",
|
|
6
|
+
"exports": [
|
|
7
|
+
"Spinner"
|
|
8
|
+
]
|
|
9
|
+
},
|
|
10
|
+
"source": {
|
|
11
|
+
"libraryVersion": "2.4.1",
|
|
12
|
+
"files": [
|
|
13
|
+
"core/index.ts",
|
|
14
|
+
"core/types.ts",
|
|
15
|
+
"core/visibility.ts",
|
|
16
|
+
"index.ts",
|
|
17
|
+
"react/Spinner.tsx",
|
|
18
|
+
"react/locale.ts",
|
|
19
|
+
"react/props.ts",
|
|
20
|
+
"react/useDelayedLoading.ts"
|
|
21
|
+
],
|
|
22
|
+
"sourceHash": "sha256:2b6b8fa25750f5a491b73f37711de1beed2b1bcf9e38e2cf1b1f419d763b6c2e"
|
|
23
|
+
},
|
|
24
|
+
"props": [
|
|
25
|
+
{
|
|
26
|
+
"name": "aria-describedby",
|
|
27
|
+
"type": "string",
|
|
28
|
+
"typeText": "string | undefined",
|
|
29
|
+
"required": false,
|
|
30
|
+
"origin": "inherited"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"name": "aria-label",
|
|
34
|
+
"type": "string",
|
|
35
|
+
"typeText": "string | undefined",
|
|
36
|
+
"required": false,
|
|
37
|
+
"origin": "inherited"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
"name": "aria-labelledby",
|
|
41
|
+
"type": "string",
|
|
42
|
+
"typeText": "string | undefined",
|
|
43
|
+
"required": false,
|
|
44
|
+
"origin": "inherited"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"name": "children",
|
|
48
|
+
"type": "other",
|
|
49
|
+
"typeText": "ReactNode",
|
|
50
|
+
"required": false,
|
|
51
|
+
"origin": "derived",
|
|
52
|
+
"description": "Content to cover while loading. It becomes inert, so it can't be clicked or focused.",
|
|
53
|
+
"descriptionOrigin": "jsdoc"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "className",
|
|
57
|
+
"type": "string",
|
|
58
|
+
"typeText": "string | undefined",
|
|
59
|
+
"required": false,
|
|
60
|
+
"origin": "inherited"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"name": "classNames",
|
|
64
|
+
"type": "other",
|
|
65
|
+
"typeText": "Partial<Record<SpinnerSlot, string>> | undefined",
|
|
66
|
+
"required": false,
|
|
67
|
+
"origin": "derived"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "delay",
|
|
71
|
+
"type": "number",
|
|
72
|
+
"typeText": "number | undefined",
|
|
73
|
+
"required": false,
|
|
74
|
+
"default": 0,
|
|
75
|
+
"origin": "derived",
|
|
76
|
+
"description": "Milliseconds to wait before showing, so fast work doesn't flash. Default 0.",
|
|
77
|
+
"descriptionOrigin": "jsdoc"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"name": "hidden",
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"typeText": "boolean | undefined",
|
|
83
|
+
"required": false,
|
|
84
|
+
"origin": "inherited"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "id",
|
|
88
|
+
"type": "string",
|
|
89
|
+
"typeText": "string | undefined",
|
|
90
|
+
"required": false,
|
|
91
|
+
"origin": "inherited"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "label",
|
|
95
|
+
"type": "string",
|
|
96
|
+
"typeText": "string | undefined",
|
|
97
|
+
"required": false,
|
|
98
|
+
"origin": "derived",
|
|
99
|
+
"description": "What screen readers announce. Default \"Loading\".",
|
|
100
|
+
"descriptionOrigin": "jsdoc"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"name": "loading",
|
|
104
|
+
"type": "boolean",
|
|
105
|
+
"typeText": "boolean | undefined",
|
|
106
|
+
"required": false,
|
|
107
|
+
"default": true,
|
|
108
|
+
"origin": "derived",
|
|
109
|
+
"description": "Default true. With `children`, the spinner covers them while this is true.",
|
|
110
|
+
"descriptionOrigin": "jsdoc"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"name": "localeText",
|
|
114
|
+
"type": "other",
|
|
115
|
+
"typeText": "Partial<SpinnerLocaleText> | undefined",
|
|
116
|
+
"required": false,
|
|
117
|
+
"origin": "derived"
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
"name": "minDuration",
|
|
121
|
+
"type": "number",
|
|
122
|
+
"typeText": "number | undefined",
|
|
123
|
+
"required": false,
|
|
124
|
+
"default": 0,
|
|
125
|
+
"origin": "derived",
|
|
126
|
+
"description": "Once shown, stay at least this many milliseconds. Default 0.",
|
|
127
|
+
"descriptionOrigin": "jsdoc"
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
"name": "role",
|
|
131
|
+
"type": "other",
|
|
132
|
+
"typeText": "AriaRole | undefined",
|
|
133
|
+
"required": false,
|
|
134
|
+
"origin": "inherited"
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"name": "showLabel",
|
|
138
|
+
"type": "boolean",
|
|
139
|
+
"typeText": "boolean | undefined",
|
|
140
|
+
"required": false,
|
|
141
|
+
"default": false,
|
|
142
|
+
"origin": "derived",
|
|
143
|
+
"description": "Show the label next to the spinner.",
|
|
144
|
+
"descriptionOrigin": "jsdoc"
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
"name": "size",
|
|
148
|
+
"type": "other",
|
|
149
|
+
"typeText": "number | SpinnerSize | undefined",
|
|
150
|
+
"required": false,
|
|
151
|
+
"default": "md",
|
|
152
|
+
"origin": "derived",
|
|
153
|
+
"description": "Default `md` (24 px); a number is pixels.",
|
|
154
|
+
"descriptionOrigin": "jsdoc"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"name": "style",
|
|
158
|
+
"type": "other",
|
|
159
|
+
"typeText": "CSSProperties | undefined",
|
|
160
|
+
"required": false,
|
|
161
|
+
"origin": "inherited"
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
"name": "tabIndex",
|
|
165
|
+
"type": "number",
|
|
166
|
+
"typeText": "number | undefined",
|
|
167
|
+
"required": false,
|
|
168
|
+
"origin": "inherited"
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"name": "title",
|
|
172
|
+
"type": "string",
|
|
173
|
+
"typeText": "string | undefined",
|
|
174
|
+
"required": false,
|
|
175
|
+
"origin": "inherited"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"name": "variant",
|
|
179
|
+
"type": "enum",
|
|
180
|
+
"values": [
|
|
181
|
+
"dots",
|
|
182
|
+
"ring"
|
|
183
|
+
],
|
|
184
|
+
"typeText": "SpinnerVariant | undefined",
|
|
185
|
+
"required": false,
|
|
186
|
+
"default": "ring",
|
|
187
|
+
"origin": "derived",
|
|
188
|
+
"description": "Default `ring`.",
|
|
189
|
+
"descriptionOrigin": "jsdoc"
|
|
190
|
+
}
|
|
191
|
+
],
|
|
192
|
+
"inherits": [
|
|
193
|
+
{
|
|
194
|
+
"from": "HTMLAttributes<HTMLElement>",
|
|
195
|
+
"omitted": [
|
|
196
|
+
"children"
|
|
197
|
+
],
|
|
198
|
+
"passthrough": true
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
"events": [],
|
|
202
|
+
"slots": [
|
|
203
|
+
"root",
|
|
204
|
+
"status",
|
|
205
|
+
"indicator",
|
|
206
|
+
"label",
|
|
207
|
+
"content",
|
|
208
|
+
"overlay"
|
|
209
|
+
],
|
|
210
|
+
"states": [
|
|
211
|
+
{
|
|
212
|
+
"attr": "data-loading"
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
"attr": "data-theme",
|
|
216
|
+
"values": [
|
|
217
|
+
"dark",
|
|
218
|
+
"light"
|
|
219
|
+
]
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
"attr": "data-variant",
|
|
223
|
+
"values": [
|
|
224
|
+
"dots"
|
|
225
|
+
]
|
|
226
|
+
}
|
|
227
|
+
],
|
|
228
|
+
"accessibility": {
|
|
229
|
+
"supplied": [],
|
|
230
|
+
"required": []
|
|
231
|
+
},
|
|
232
|
+
"composition": {},
|
|
233
|
+
"operations": {},
|
|
234
|
+
"intentDomains": [],
|
|
235
|
+
"safeMutations": {},
|
|
236
|
+
"examples": [],
|
|
237
|
+
"coverage": {
|
|
238
|
+
"propsTotal": 20,
|
|
239
|
+
"propsDescribed": 8,
|
|
240
|
+
"describedPct": 40,
|
|
241
|
+
"authoredSections": [
|
|
242
|
+
"accessibility"
|
|
243
|
+
]
|
|
244
|
+
}
|
|
245
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useMemo, type CSSProperties, type HTMLAttributes, type ReactNode } from "react";
|
|
4
|
+
import { spinnerPixels } from "../core/visibility";
|
|
5
|
+
import type { SpinnerLocaleText, SpinnerSize, SpinnerVariant } from "../core/types";
|
|
6
|
+
import { defaultSpinnerText } from "./locale";
|
|
7
|
+
import { cx, type SpinnerSlot } from "./props";
|
|
8
|
+
import { useDelayedLoading } from "./useDelayedLoading";
|
|
9
|
+
|
|
10
|
+
export interface SpinnerProps extends Omit<HTMLAttributes<HTMLElement>, "children"> {
|
|
11
|
+
/** Default true. With `children`, the spinner covers them while this is true. */
|
|
12
|
+
loading?: boolean;
|
|
13
|
+
/** Default `md` (24 px); a number is pixels. */
|
|
14
|
+
size?: SpinnerSize | number;
|
|
15
|
+
/** Default `ring`. */
|
|
16
|
+
variant?: SpinnerVariant;
|
|
17
|
+
/** What screen readers announce. Default "Loading". */
|
|
18
|
+
label?: string;
|
|
19
|
+
/** Show the label next to the spinner. */
|
|
20
|
+
showLabel?: boolean;
|
|
21
|
+
/** Milliseconds to wait before showing, so fast work doesn't flash. Default 0. */
|
|
22
|
+
delay?: number;
|
|
23
|
+
/** Once shown, stay at least this many milliseconds. Default 0. */
|
|
24
|
+
minDuration?: number;
|
|
25
|
+
/** Content to cover while loading. It becomes inert, so it can't be clicked or focused. */
|
|
26
|
+
children?: ReactNode;
|
|
27
|
+
classNames?: Partial<Record<SpinnerSlot, string>>;
|
|
28
|
+
localeText?: Partial<SpinnerLocaleText>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** A loading indicator, on its own or covering content that is busy. */
|
|
32
|
+
export function Spinner(props: SpinnerProps) {
|
|
33
|
+
const {
|
|
34
|
+
loading = true,
|
|
35
|
+
size = "md",
|
|
36
|
+
variant = "ring",
|
|
37
|
+
label,
|
|
38
|
+
showLabel = false,
|
|
39
|
+
delay = 0,
|
|
40
|
+
minDuration = 0,
|
|
41
|
+
children,
|
|
42
|
+
className,
|
|
43
|
+
classNames,
|
|
44
|
+
style,
|
|
45
|
+
localeText,
|
|
46
|
+
...rest
|
|
47
|
+
} = props;
|
|
48
|
+
|
|
49
|
+
const text = useMemo(() => ({ ...defaultSpinnerText, ...localeText }), [localeText]);
|
|
50
|
+
const visible = useDelayedLoading(loading, { delay, minDuration });
|
|
51
|
+
const sized = { "--sp-size": `${spinnerPixels(size)}px`, ...style } as CSSProperties;
|
|
52
|
+
|
|
53
|
+
const status = (
|
|
54
|
+
<span role="status" className={cx("sp-status", classNames?.status)}>
|
|
55
|
+
<span className={cx("sp-indicator", classNames?.indicator)} data-variant={variant} aria-hidden="true">
|
|
56
|
+
{variant === "dots" ? (
|
|
57
|
+
<>
|
|
58
|
+
<span className="sp-dot" />
|
|
59
|
+
<span className="sp-dot" />
|
|
60
|
+
<span className="sp-dot" />
|
|
61
|
+
</>
|
|
62
|
+
) : (
|
|
63
|
+
<svg className="sp-ring" viewBox="0 0 24 24" focusable="false">
|
|
64
|
+
<circle className="sp-track" cx="12" cy="12" r="9.5" />
|
|
65
|
+
<circle className="sp-arc" cx="12" cy="12" r="9.5" pathLength={100} />
|
|
66
|
+
</svg>
|
|
67
|
+
)}
|
|
68
|
+
</span>
|
|
69
|
+
<span className={showLabel ? cx("sp-label", classNames?.label) : "sp-sr-only"}>{label ?? text.loading}</span>
|
|
70
|
+
</span>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
if (children === undefined) {
|
|
74
|
+
if (!visible) return null;
|
|
75
|
+
return (
|
|
76
|
+
<span {...rest} className={cx("sp-root", classNames?.root, className)} style={sized} data-variant={variant}>
|
|
77
|
+
{status}
|
|
78
|
+
</span>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div
|
|
84
|
+
{...rest}
|
|
85
|
+
className={cx("sp-container", classNames?.root, className)}
|
|
86
|
+
style={sized}
|
|
87
|
+
aria-busy={visible || undefined}
|
|
88
|
+
data-loading={visible || undefined}
|
|
89
|
+
>
|
|
90
|
+
<div className={cx("sp-content", classNames?.content)} inert={visible}>
|
|
91
|
+
{children}
|
|
92
|
+
</div>
|
|
93
|
+
{visible && <div className={cx("sp-overlay", classNames?.overlay)}>{status}</div>}
|
|
94
|
+
</div>
|
|
95
|
+
);
|
|
96
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { stepVisibility } from "../core/visibility";
|
|
5
|
+
import type { VisibilityMarks, VisibilityOptions } from "../core/types";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* `loading`, smoothed for display: true only after `delay` has passed, and then
|
|
9
|
+
* for at least `minDuration`. Use it for any loading UI, not just the Spinner.
|
|
10
|
+
*/
|
|
11
|
+
export function useDelayedLoading(loading: boolean, options: VisibilityOptions = {}): boolean {
|
|
12
|
+
const { delay = 0, minDuration = 0 } = options;
|
|
13
|
+
const immediate = delay <= 0 && minDuration <= 0;
|
|
14
|
+
const [visible, setVisible] = useState(() => loading && delay <= 0);
|
|
15
|
+
const marks = useRef<VisibilityMarks>({ visible: loading && delay <= 0, loadingSince: null, visibleSince: null });
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (immediate) return;
|
|
19
|
+
const current = marks.current;
|
|
20
|
+
const now = Date.now();
|
|
21
|
+
current.loadingSince = loading ? (current.loadingSince ?? now) : null;
|
|
22
|
+
if (current.visible) current.visibleSince ??= now;
|
|
23
|
+
|
|
24
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
25
|
+
const evaluate = () => {
|
|
26
|
+
const step = stepVisibility(loading, current, Date.now(), { delay, minDuration });
|
|
27
|
+
if (step.visible !== current.visible) {
|
|
28
|
+
current.visible = step.visible;
|
|
29
|
+
current.visibleSince = step.visible ? Date.now() : null;
|
|
30
|
+
setVisible(step.visible);
|
|
31
|
+
}
|
|
32
|
+
if (step.recheckIn !== null) timer = setTimeout(evaluate, step.recheckIn);
|
|
33
|
+
};
|
|
34
|
+
timer = setTimeout(evaluate, 0);
|
|
35
|
+
return () => clearTimeout(timer);
|
|
36
|
+
}, [loading, delay, minDuration, immediate]);
|
|
37
|
+
|
|
38
|
+
return immediate ? loading : visible;
|
|
39
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Spinner styles.
|
|
3
|
+
*
|
|
4
|
+
* The indicator draws in `currentColor`, so it takes the color of its
|
|
5
|
+
* surroundings. Tokens read the shared --gbs-* variables when they are set on
|
|
6
|
+
* an ancestor. Rules are unlayered: they beat a framework reset on
|
|
7
|
+
* specificity, and lose to anything you pass through `className`. With
|
|
8
|
+
* Tailwind v4, import this file after the framework and inside its components
|
|
9
|
+
* layer - see the README.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
.sp-root,
|
|
13
|
+
.sp-container {
|
|
14
|
+
--sp-size: 24px;
|
|
15
|
+
--sp-color: currentColor;
|
|
16
|
+
--sp-track: color-mix(in oklab, currentColor 18%, transparent);
|
|
17
|
+
--sp-duration: 0.8s;
|
|
18
|
+
--sp-overlay-bg: color-mix(in oklab, var(--gbs-bg, var(--dg-bg, light-dark(#ffffff, #0b0b0e))) 72%, transparent);
|
|
19
|
+
--sp-overlay-color: var(--gbs-accent, var(--dg-accent, light-dark(#2563eb, #60a5fa)));
|
|
20
|
+
--sp-font-size: var(--gbs-font-size, var(--dg-font-size, 13px));
|
|
21
|
+
|
|
22
|
+
color-scheme: inherit;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
:where(.dark, [data-theme="dark"]) .sp-root {
|
|
26
|
+
color-scheme: dark;
|
|
27
|
+
}
|
|
28
|
+
:where(.light, [data-theme="light"]) .sp-root {
|
|
29
|
+
color-scheme: light;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
:where(.sp-root, .sp-container) *,
|
|
33
|
+
:where(.sp-root, .sp-container) *::before,
|
|
34
|
+
:where(.sp-root, .sp-container) *::after {
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
.sp-root {
|
|
39
|
+
display: inline-flex;
|
|
40
|
+
align-items: center;
|
|
41
|
+
vertical-align: middle;
|
|
42
|
+
color: var(--sp-color);
|
|
43
|
+
font-size: var(--sp-font-size);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sp-status {
|
|
47
|
+
display: inline-flex;
|
|
48
|
+
align-items: center;
|
|
49
|
+
gap: 8px;
|
|
50
|
+
}
|
|
51
|
+
.sp-label {
|
|
52
|
+
line-height: 1.4;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.sp-indicator {
|
|
56
|
+
display: inline-grid;
|
|
57
|
+
flex: none;
|
|
58
|
+
place-items: center;
|
|
59
|
+
width: var(--sp-size);
|
|
60
|
+
height: var(--sp-size);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/* ---------------------------------------------------------------- ring */
|
|
64
|
+
|
|
65
|
+
.sp-ring {
|
|
66
|
+
width: 100%;
|
|
67
|
+
height: 100%;
|
|
68
|
+
animation: sp-rotate var(--sp-duration) linear infinite;
|
|
69
|
+
}
|
|
70
|
+
.sp-track,
|
|
71
|
+
.sp-arc {
|
|
72
|
+
fill: none;
|
|
73
|
+
stroke-width: 2.5;
|
|
74
|
+
}
|
|
75
|
+
.sp-track {
|
|
76
|
+
stroke: var(--sp-track);
|
|
77
|
+
}
|
|
78
|
+
.sp-arc {
|
|
79
|
+
stroke: currentColor;
|
|
80
|
+
stroke-linecap: round;
|
|
81
|
+
stroke-dasharray: 28 100;
|
|
82
|
+
}
|
|
83
|
+
@keyframes sp-rotate {
|
|
84
|
+
to {
|
|
85
|
+
transform: rotate(360deg);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/* ---------------------------------------------------------------- dots */
|
|
90
|
+
|
|
91
|
+
.sp-indicator[data-variant="dots"] {
|
|
92
|
+
grid-auto-flow: column;
|
|
93
|
+
gap: calc(var(--sp-size) * 0.1);
|
|
94
|
+
}
|
|
95
|
+
.sp-dot {
|
|
96
|
+
width: calc(var(--sp-size) * 0.22);
|
|
97
|
+
aspect-ratio: 1;
|
|
98
|
+
border-radius: 50%;
|
|
99
|
+
background: currentColor;
|
|
100
|
+
animation: sp-pulse calc(var(--sp-duration) * 1.4) ease-in-out infinite;
|
|
101
|
+
}
|
|
102
|
+
.sp-dot:nth-child(2) {
|
|
103
|
+
animation-delay: calc(var(--sp-duration) * 0.18);
|
|
104
|
+
}
|
|
105
|
+
.sp-dot:nth-child(3) {
|
|
106
|
+
animation-delay: calc(var(--sp-duration) * 0.36);
|
|
107
|
+
}
|
|
108
|
+
@keyframes sp-pulse {
|
|
109
|
+
0%,
|
|
110
|
+
80%,
|
|
111
|
+
100% {
|
|
112
|
+
opacity: 0.25;
|
|
113
|
+
scale: 0.7;
|
|
114
|
+
}
|
|
115
|
+
40% {
|
|
116
|
+
opacity: 1;
|
|
117
|
+
scale: 1;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/* ----------------------------------------------------------- container */
|
|
122
|
+
|
|
123
|
+
.sp-container {
|
|
124
|
+
position: relative;
|
|
125
|
+
}
|
|
126
|
+
.sp-overlay {
|
|
127
|
+
position: absolute;
|
|
128
|
+
inset: 0;
|
|
129
|
+
z-index: 1;
|
|
130
|
+
display: grid;
|
|
131
|
+
place-items: center;
|
|
132
|
+
border-radius: inherit;
|
|
133
|
+
background: var(--sp-overlay-bg);
|
|
134
|
+
color: var(--sp-overlay-color);
|
|
135
|
+
font-size: var(--sp-font-size);
|
|
136
|
+
animation: sp-fade 150ms ease both;
|
|
137
|
+
}
|
|
138
|
+
@keyframes sp-fade {
|
|
139
|
+
from {
|
|
140
|
+
opacity: 0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
.sp-sr-only {
|
|
145
|
+
position: absolute;
|
|
146
|
+
width: 1px;
|
|
147
|
+
height: 1px;
|
|
148
|
+
margin: -1px;
|
|
149
|
+
padding: 0;
|
|
150
|
+
overflow: hidden;
|
|
151
|
+
clip-path: inset(50%);
|
|
152
|
+
white-space: nowrap;
|
|
153
|
+
border: 0;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/* Slower, not stopped: a frozen spinner reads as a hang. */
|
|
157
|
+
@media (prefers-reduced-motion: reduce) {
|
|
158
|
+
.sp-root,
|
|
159
|
+
.sp-container {
|
|
160
|
+
--sp-duration: 2.4s;
|
|
161
|
+
}
|
|
162
|
+
.sp-overlay {
|
|
163
|
+
animation: none;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@media (forced-colors: active) {
|
|
168
|
+
.sp-arc,
|
|
169
|
+
.sp-dot {
|
|
170
|
+
stroke: CanvasText;
|
|
171
|
+
background: CanvasText;
|
|
172
|
+
}
|
|
173
|
+
}
|