@jcsoftdev/ui 0.3.0 → 0.5.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/CHANGELOG.md +200 -1
- package/README.md +56 -3
- package/bin/ui-theme.mjs +13 -2
- package/dist/atoms/button/button.d.ts +8 -1
- package/dist/atoms/button/button.js +10 -3
- package/dist/atoms/checkbox/checkbox.js +3 -1
- package/dist/atoms/chip/chip.d.ts +11 -3
- package/dist/atoms/chip/chip.js +8 -1
- package/dist/atoms/chip/index.d.ts +1 -1
- package/dist/atoms/chip/index.js +2 -0
- package/dist/atoms/divider/divider.d.ts +15 -0
- package/dist/atoms/divider/divider.js +27 -0
- package/dist/atoms/divider/index.d.ts +1 -0
- package/dist/atoms/divider/index.js +1 -0
- package/dist/atoms/due-chip/due-chip.d.ts +31 -0
- package/dist/atoms/due-chip/due-chip.js +41 -0
- package/dist/atoms/due-chip/index.d.ts +2 -0
- package/dist/atoms/due-chip/index.js +6 -0
- package/dist/atoms/due-chip/model.d.ts +25 -0
- package/dist/atoms/due-chip/model.js +44 -0
- package/dist/atoms/icon-button/icon-button.d.ts +22 -0
- package/dist/atoms/icon-button/icon-button.js +38 -0
- package/dist/atoms/icon-button/index.d.ts +1 -0
- package/dist/atoms/icon-button/index.js +8 -0
- package/dist/atoms/index.d.ts +6 -0
- package/dist/atoms/index.js +6 -0
- package/dist/atoms/internal/hit-area.d.ts +6 -0
- package/dist/atoms/internal/hit-area.js +4 -0
- package/dist/atoms/kbd/index.d.ts +1 -0
- package/dist/atoms/kbd/index.js +4 -0
- package/dist/atoms/kbd/kbd.d.ts +7 -0
- package/dist/atoms/kbd/kbd.js +17 -0
- package/dist/atoms/radio-group/radio-group.js +6 -2
- package/dist/atoms/seal/index.d.ts +1 -0
- package/dist/atoms/seal/index.js +4 -0
- package/dist/atoms/seal/seal.d.ts +30 -0
- package/dist/atoms/seal/seal.js +71 -0
- package/dist/atoms/spinner/index.d.ts +1 -0
- package/dist/atoms/spinner/index.js +5 -0
- package/dist/atoms/spinner/spinner.d.ts +19 -0
- package/dist/atoms/spinner/spinner.js +31 -0
- package/dist/atoms/switch/switch.js +3 -1
- package/dist/auth/auth-illustration/auth-illustration.d.ts +35 -0
- package/dist/auth/auth-illustration/auth-illustration.js +72 -0
- package/dist/auth/auth-illustration/index.d.ts +3 -0
- package/dist/auth/auth-illustration/index.js +11 -0
- package/dist/auth/auth-illustration/look.d.ts +30 -0
- package/dist/auth/auth-illustration/look.js +0 -0
- package/dist/auth/auth-illustration/model.d.ts +133 -0
- package/dist/auth/auth-illustration/model.js +202 -0
- package/dist/auth/auth-illustration/use-art-pointer.d.ts +9 -0
- package/dist/auth/auth-illustration/use-art-pointer.js +69 -0
- package/dist/auth/auth-layout/auth-layout.d.ts +80 -0
- package/dist/auth/auth-layout/auth-layout.js +190 -0
- package/dist/auth/auth-layout/index.d.ts +1 -0
- package/dist/auth/auth-layout/index.js +1 -0
- package/dist/auth/character/character.d.ts +12 -0
- package/dist/auth/character/character.js +333 -0
- package/dist/auth/character/index.d.ts +1 -0
- package/dist/auth/character/index.js +1 -0
- package/dist/auth/index.d.ts +4 -0
- package/dist/auth/index.js +4 -0
- package/dist/auth/internal/auth-context.d.ts +17 -0
- package/dist/auth/internal/auth-context.js +10 -0
- package/dist/auth/internal/auth-styles.d.ts +1 -0
- package/dist/auth/internal/auth-styles.js +29 -0
- package/dist/auth/internal/portal-glyphs.d.ts +6 -0
- package/dist/auth/internal/portal-glyphs.js +39 -0
- package/dist/auth/login-form/context.d.ts +51 -0
- package/dist/auth/login-form/context.js +12 -0
- package/dist/auth/login-form/index.d.ts +2 -0
- package/dist/auth/login-form/index.js +23 -0
- package/dist/auth/login-form/login-form.d.ts +66 -0
- package/dist/auth/login-form/login-form.js +233 -0
- package/dist/auth/login-form/parts.d.ts +71 -0
- package/dist/auth/login-form/parts.js +371 -0
- package/dist/auth/looks/auth-illustration-any.d.ts +16 -0
- package/dist/auth/looks/auth-illustration-any.js +24 -0
- package/dist/auth/looks/index.d.ts +1 -0
- package/dist/auth/looks/index.js +1 -0
- package/dist/auth/mosaic/index.d.ts +1 -0
- package/dist/auth/mosaic/index.js +1 -0
- package/dist/auth/mosaic/mosaic.d.ts +11 -0
- package/dist/auth/mosaic/mosaic.js +195 -0
- package/dist/auth/slabs/index.d.ts +1 -0
- package/dist/auth/slabs/index.js +1 -0
- package/dist/auth/slabs/slabs.d.ts +13 -0
- package/dist/auth/slabs/slabs.js +136 -0
- package/dist/auth/stack/index.d.ts +1 -0
- package/dist/auth/stack/index.js +1 -0
- package/dist/auth/stack/stack.d.ts +6 -0
- package/dist/auth/stack/stack.js +222 -0
- package/dist/auth/statement/index.d.ts +1 -0
- package/dist/auth/statement/index.js +1 -0
- package/dist/auth/statement/statement.d.ts +13 -0
- package/dist/auth/statement/statement.js +99 -0
- package/dist/calendar/date-calendar/date-calendar.d.ts +32 -0
- package/dist/calendar/date-calendar/date-calendar.js +189 -0
- package/dist/calendar/date-calendar/index.d.ts +1 -0
- package/dist/calendar/date-calendar/index.js +6 -0
- package/dist/calendar/index.d.ts +1 -0
- package/dist/calendar/index.js +1 -0
- package/dist/calendar/internal/date-utils.d.ts +26 -0
- package/dist/calendar/internal/date-utils.js +95 -1
- package/dist/containers/aside/aside.d.ts +14 -0
- package/dist/containers/aside/aside.js +25 -0
- package/dist/containers/aside/index.d.ts +1 -0
- package/dist/containers/aside/index.js +5 -0
- package/dist/containers/banner/banner.d.ts +4 -1
- package/dist/containers/banner/banner.js +9 -1
- package/dist/containers/description-list/description-list.d.ts +29 -6
- package/dist/containers/description-list/description-list.js +47 -6
- package/dist/containers/feed/feed.d.ts +23 -0
- package/dist/containers/feed/feed.js +77 -0
- package/dist/containers/feed/index.d.ts +2 -0
- package/dist/containers/feed/index.js +10 -0
- package/dist/containers/feed/model.d.ts +19 -0
- package/dist/containers/feed/model.js +38 -0
- package/dist/containers/index.d.ts +6 -0
- package/dist/containers/index.js +6 -0
- package/dist/containers/kpi/kpi.d.ts +50 -8
- package/dist/containers/kpi/kpi.js +91 -39
- package/dist/containers/list-detail/index.d.ts +1 -0
- package/dist/containers/list-detail/index.js +20 -0
- package/dist/containers/list-detail/list-detail.d.ts +55 -0
- package/dist/containers/list-detail/list-detail.js +221 -0
- package/dist/containers/note/index.d.ts +1 -0
- package/dist/containers/note/index.js +4 -0
- package/dist/containers/note/note.d.ts +13 -0
- package/dist/containers/note/note.js +27 -0
- package/dist/containers/section/index.d.ts +1 -0
- package/dist/containers/section/index.js +6 -0
- package/dist/containers/section/section.d.ts +68 -0
- package/dist/containers/section/section.js +198 -0
- package/dist/containers/shortcuts/index.d.ts +1 -0
- package/dist/containers/shortcuts/index.js +8 -0
- package/dist/containers/shortcuts/shortcuts.d.ts +18 -0
- package/dist/containers/shortcuts/shortcuts.js +50 -0
- package/dist/containers/table/selection.d.ts +9 -0
- package/dist/containers/table/selection.js +20 -0
- package/dist/containers/table/table.d.ts +66 -4
- package/dist/containers/table/table.js +128 -7
- package/dist/containers/timeline/index.d.ts +1 -1
- package/dist/containers/timeline/index.js +4 -2
- package/dist/containers/timeline/timeline.d.ts +32 -5
- package/dist/containers/timeline/timeline.js +154 -90
- package/dist/forms/chip-group/chip-group.d.ts +54 -0
- package/dist/forms/chip-group/chip-group.js +114 -0
- package/dist/forms/chip-group/index.d.ts +1 -0
- package/dist/forms/chip-group/index.js +6 -0
- package/dist/forms/combobox/combobox.d.ts +60 -0
- package/dist/forms/combobox/combobox.js +281 -0
- package/dist/forms/combobox/index.d.ts +1 -0
- package/dist/forms/combobox/index.js +6 -0
- package/dist/forms/date-picker/date-picker.d.ts +40 -0
- package/dist/forms/date-picker/date-picker.js +183 -0
- package/dist/forms/date-picker/date-time-picker.d.ts +43 -0
- package/dist/forms/date-picker/date-time-picker.js +121 -0
- package/dist/forms/date-picker/index.d.ts +2 -0
- package/dist/forms/date-picker/index.js +10 -0
- package/dist/forms/date-picker/model.d.ts +35 -0
- package/dist/forms/date-picker/model.js +83 -0
- package/dist/forms/dropzone/dropzone.d.ts +30 -2
- package/dist/forms/dropzone/dropzone.js +153 -23
- package/dist/forms/field/field.d.ts +16 -10
- package/dist/forms/field/field.js +41 -5
- package/dist/forms/index.d.ts +5 -0
- package/dist/forms/index.js +5 -0
- package/dist/forms/input/index.d.ts +1 -1
- package/dist/forms/input/index.js +4 -1
- package/dist/forms/input/input.d.ts +21 -5
- package/dist/forms/input/input.js +75 -9
- package/dist/forms/input-icon/input-icon.d.ts +1 -1
- package/dist/forms/internal/listbox-items.d.ts +18 -0
- package/dist/forms/internal/listbox-items.js +88 -0
- package/dist/forms/internal/listbox.d.ts +44 -0
- package/dist/forms/internal/listbox.js +74 -0
- package/dist/forms/number-stepper/model.d.ts +16 -0
- package/dist/forms/number-stepper/model.js +23 -0
- package/dist/forms/number-stepper/number-stepper.d.ts +36 -6
- package/dist/forms/number-stepper/number-stepper.js +86 -37
- package/dist/forms/password-input/index.d.ts +1 -0
- package/dist/forms/password-input/index.js +1 -0
- package/dist/forms/password-input/password-input.d.ts +16 -0
- package/dist/forms/password-input/password-input.js +45 -0
- package/dist/forms/select-menu/index.d.ts +1 -0
- package/dist/forms/select-menu/index.js +6 -0
- package/dist/forms/select-menu/select-menu.d.ts +35 -0
- package/dist/forms/select-menu/select-menu.js +230 -0
- package/dist/i18n/strings.d.ts +153 -0
- package/dist/i18n/strings.js +86 -2
- package/dist/i18n/ui-strings-provider.d.ts +1 -1
- package/dist/i18n/ui-strings-provider.js +6 -2
- package/dist/icons/eye.d.ts +2 -0
- package/dist/icons/eye.js +11 -0
- package/dist/icons/graduation-cap.d.ts +2 -0
- package/dist/icons/graduation-cap.js +12 -0
- package/dist/icons/house.d.ts +2 -0
- package/dist/icons/house.js +11 -0
- package/dist/icons/index.d.ts +4 -0
- package/dist/icons/index.js +8 -0
- package/dist/icons/mail.d.ts +2 -0
- package/dist/icons/mail.js +11 -0
- package/dist/navigation/index.d.ts +1 -0
- package/dist/navigation/index.js +1 -0
- package/dist/navigation/stepper/index.d.ts +1 -1
- package/dist/navigation/stepper/index.js +3 -1
- package/dist/navigation/stepper/stepper.d.ts +8 -0
- package/dist/navigation/stepper/stepper.js +68 -45
- package/dist/navigation/tabs/index.d.ts +1 -0
- package/dist/navigation/tabs/index.js +6 -0
- package/dist/navigation/tabs/tabs-nav.d.ts +37 -0
- package/dist/navigation/tabs/tabs-nav.js +57 -0
- package/dist/navigation/wizard/index.d.ts +1 -0
- package/dist/navigation/wizard/index.js +6 -0
- package/dist/navigation/wizard/model.d.ts +33 -0
- package/dist/navigation/wizard/model.js +34 -0
- package/dist/navigation/wizard/wizard.d.ts +45 -0
- package/dist/navigation/wizard/wizard.js +169 -0
- package/dist/overlays/alert-dialog/alert-dialog.d.ts +103 -0
- package/dist/overlays/alert-dialog/alert-dialog.js +342 -0
- package/dist/overlays/alert-dialog/index.d.ts +1 -0
- package/dist/overlays/alert-dialog/index.js +26 -0
- package/dist/overlays/dropdown-menu/dropdown-menu.d.ts +17 -1
- package/dist/overlays/dropdown-menu/dropdown-menu.js +12 -4
- package/dist/overlays/dropdown-menu/index.d.ts +1 -1
- package/dist/overlays/dropdown-menu/index.js +8 -2
- package/dist/overlays/index.d.ts +2 -0
- package/dist/overlays/index.js +2 -0
- package/dist/overlays/testing/index.d.ts +5 -0
- package/dist/overlays/testing/index.js +4 -0
- package/dist/overlays/toaster/index.d.ts +2 -1
- package/dist/overlays/toaster/index.js +4 -2
- package/dist/overlays/toaster/toast-store.d.ts +6 -2
- package/dist/overlays/toaster/toast.d.ts +3 -0
- package/dist/overlays/toaster/toast.js +3 -0
- package/dist/overlays/toaster/toaster.d.ts +3 -0
- package/dist/overlays/toaster/toaster.js +36 -3
- package/dist/overlays/tooltip/index.d.ts +1 -0
- package/dist/overlays/tooltip/index.js +4 -0
- package/dist/overlays/tooltip/model.d.ts +10 -0
- package/dist/overlays/tooltip/model.js +13 -0
- package/dist/overlays/tooltip/tooltip.d.ts +41 -0
- package/dist/overlays/tooltip/tooltip.js +116 -0
- package/dist/primitives/use-dismissable-layer.js +1 -1
- package/dist/states/error-state/error-state.d.ts +6 -1
- package/dist/states/error-state/error-state.js +13 -9
- package/dist/states/skeleton/skeleton.d.ts +8 -2
- package/dist/states/skeleton/skeleton.js +44 -2
- package/icons/svg/eye.svg +4 -0
- package/icons/svg/graduation-cap.svg +5 -0
- package/icons/svg/house.svg +4 -0
- package/icons/svg/mail.svg +4 -0
- package/package.json +2 -2
- package/scripts/build-theme.mjs +12 -1
- package/src/atoms/button/button.tsx +25 -3
- package/src/atoms/checkbox/checkbox.tsx +3 -1
- package/src/atoms/chip/chip.tsx +18 -3
- package/src/atoms/chip/index.ts +2 -0
- package/src/atoms/divider/divider.tsx +40 -0
- package/src/atoms/divider/index.ts +1 -0
- package/src/atoms/due-chip/due-chip.tsx +75 -0
- package/src/atoms/due-chip/index.ts +2 -0
- package/src/atoms/due-chip/model.ts +67 -0
- package/src/atoms/icon-button/icon-button.tsx +58 -0
- package/src/atoms/icon-button/index.ts +6 -0
- package/src/atoms/index.ts +6 -0
- package/src/atoms/internal/hit-area.ts +7 -0
- package/src/atoms/kbd/index.ts +1 -0
- package/src/atoms/kbd/kbd.tsx +20 -0
- package/src/atoms/radio-group/radio-group.tsx +8 -2
- package/src/atoms/seal/index.ts +1 -0
- package/src/atoms/seal/seal.tsx +107 -0
- package/src/atoms/spinner/index.ts +1 -0
- package/src/atoms/spinner/spinner.tsx +49 -0
- package/src/atoms/switch/switch.tsx +3 -1
- package/src/auth/auth-illustration/auth-illustration.tsx +100 -0
- package/src/auth/auth-illustration/index.ts +8 -0
- package/src/auth/auth-illustration/look.ts +32 -0
- package/src/auth/auth-illustration/model.ts +330 -0
- package/src/auth/auth-illustration/use-art-pointer.ts +78 -0
- package/src/auth/auth-layout/auth-layout.tsx +282 -0
- package/src/auth/auth-layout/index.ts +1 -0
- package/src/auth/character/character.tsx +346 -0
- package/src/auth/character/index.ts +1 -0
- package/src/auth/index.ts +4 -0
- package/src/auth/internal/auth-context.ts +26 -0
- package/src/auth/internal/auth-styles.tsx +39 -0
- package/src/auth/internal/portal-glyphs.tsx +32 -0
- package/src/auth/login-form/context.ts +78 -0
- package/src/auth/login-form/index.ts +21 -0
- package/src/auth/login-form/login-form.tsx +330 -0
- package/src/auth/login-form/parts.tsx +457 -0
- package/src/auth/looks/auth-illustration-any.tsx +38 -0
- package/src/auth/looks/index.ts +1 -0
- package/src/auth/mosaic/index.ts +1 -0
- package/src/auth/mosaic/mosaic.tsx +255 -0
- package/src/auth/slabs/index.ts +1 -0
- package/src/auth/slabs/slabs.tsx +181 -0
- package/src/auth/stack/index.ts +1 -0
- package/src/auth/stack/stack.tsx +267 -0
- package/src/auth/statement/index.ts +1 -0
- package/src/auth/statement/statement.tsx +122 -0
- package/src/calendar/date-calendar/date-calendar.tsx +230 -0
- package/src/calendar/date-calendar/index.ts +5 -0
- package/src/calendar/index.ts +1 -0
- package/src/calendar/internal/date-utils.ts +115 -0
- package/src/containers/aside/aside.tsx +40 -0
- package/src/containers/aside/index.ts +1 -0
- package/src/containers/banner/banner.tsx +18 -1
- package/src/containers/description-list/description-list.tsx +85 -9
- package/src/containers/feed/feed.tsx +99 -0
- package/src/containers/feed/index.ts +8 -0
- package/src/containers/feed/model.ts +54 -0
- package/src/containers/index.ts +6 -0
- package/src/containers/kpi/kpi.tsx +161 -62
- package/src/containers/list-detail/index.ts +15 -0
- package/src/containers/list-detail/list-detail.tsx +293 -0
- package/src/containers/note/index.ts +1 -0
- package/src/containers/note/note.tsx +38 -0
- package/src/containers/section/index.ts +11 -0
- package/src/containers/section/section.tsx +281 -0
- package/src/containers/shortcuts/index.ts +6 -0
- package/src/containers/shortcuts/shortcuts.tsx +92 -0
- package/src/containers/table/selection.ts +26 -0
- package/src/containers/table/table.tsx +215 -13
- package/src/containers/timeline/index.ts +3 -0
- package/src/containers/timeline/timeline.tsx +204 -93
- package/src/forms/chip-group/chip-group.tsx +184 -0
- package/src/forms/chip-group/index.ts +8 -0
- package/src/forms/combobox/combobox.tsx +359 -0
- package/src/forms/combobox/index.ts +7 -0
- package/src/forms/date-picker/date-picker.tsx +239 -0
- package/src/forms/date-picker/date-time-picker.tsx +178 -0
- package/src/forms/date-picker/index.ts +10 -0
- package/src/forms/date-picker/model.ts +108 -0
- package/src/forms/dropzone/dropzone.tsx +217 -35
- package/src/forms/field/field.tsx +72 -7
- package/src/forms/index.ts +5 -0
- package/src/forms/input/index.ts +8 -1
- package/src/forms/input/input.tsx +99 -12
- package/src/forms/input-icon/input-icon.tsx +1 -1
- package/src/forms/internal/listbox-items.tsx +103 -0
- package/src/forms/internal/listbox.ts +124 -0
- package/src/forms/number-stepper/model.ts +35 -0
- package/src/forms/number-stepper/number-stepper.tsx +132 -42
- package/src/forms/password-input/index.ts +1 -0
- package/src/forms/password-input/password-input.tsx +57 -0
- package/src/forms/select-menu/index.ts +7 -0
- package/src/forms/select-menu/select-menu.tsx +280 -0
- package/src/i18n/strings.ts +153 -0
- package/src/i18n/ui-strings-provider.tsx +15 -4
- package/src/icons/eye.tsx +12 -0
- package/src/icons/graduation-cap.tsx +13 -0
- package/src/icons/house.tsx +12 -0
- package/src/icons/index.ts +4 -0
- package/src/icons/mail.tsx +12 -0
- package/src/navigation/index.ts +1 -0
- package/src/navigation/stepper/index.ts +7 -1
- package/src/navigation/stepper/stepper.tsx +41 -5
- package/src/navigation/tabs/index.ts +7 -0
- package/src/navigation/tabs/tabs-nav.tsx +131 -0
- package/src/navigation/wizard/index.ts +7 -0
- package/src/navigation/wizard/model.ts +61 -0
- package/src/navigation/wizard/wizard.tsx +222 -0
- package/src/overlays/alert-dialog/alert-dialog.tsx +486 -0
- package/src/overlays/alert-dialog/index.ts +19 -0
- package/src/overlays/dropdown-menu/dropdown-menu.tsx +29 -4
- package/src/overlays/dropdown-menu/index.ts +3 -0
- package/src/overlays/index.ts +2 -0
- package/src/overlays/testing/index.ts +5 -0
- package/src/overlays/toaster/index.ts +2 -0
- package/src/overlays/toaster/toast-store.ts +6 -2
- package/src/overlays/toaster/toast.ts +6 -0
- package/src/overlays/toaster/toaster.tsx +44 -2
- package/src/overlays/tooltip/index.ts +1 -0
- package/src/overlays/tooltip/model.ts +18 -0
- package/src/overlays/tooltip/tooltip.tsx +166 -0
- package/src/primitives/use-dismissable-layer.ts +7 -2
- package/src/states/error-state/error-state.tsx +19 -8
- package/src/states/skeleton/skeleton.tsx +68 -2
- package/styles/tailwind.css +33 -30
- package/styles/theme.css +33 -30
|
@@ -6,6 +6,9 @@ declare function toast(message: ReactNode, options?: ToastOptions): ToastId;
|
|
|
6
6
|
declare namespace toast {
|
|
7
7
|
var success: (message: ReactNode, options?: ToastOptions) => ToastId;
|
|
8
8
|
var error: (message: ReactNode, options?: ToastOptions) => ToastId;
|
|
9
|
+
var info: (message: ReactNode, options?: ToastOptions) => ToastId;
|
|
10
|
+
var warning: (message: ReactNode, options?: ToastOptions) => ToastId;
|
|
11
|
+
var danger: (message: ReactNode, options?: ToastOptions) => ToastId;
|
|
9
12
|
var dismiss: (id?: ToastId) => void;
|
|
10
13
|
}
|
|
11
14
|
export { toast };
|
|
@@ -4,6 +4,9 @@ function toast(message, options) {
|
|
|
4
4
|
}
|
|
5
5
|
toast.success = (message, options) => publish(message, "success", options);
|
|
6
6
|
toast.error = (message, options) => publish(message, "error", options);
|
|
7
|
+
toast.info = (message, options) => publish(message, "info", options);
|
|
8
|
+
toast.warning = (message, options) => publish(message, "warning", options);
|
|
9
|
+
toast.danger = toast.error;
|
|
7
10
|
toast.dismiss = (id) => dismiss(id);
|
|
8
11
|
export {
|
|
9
12
|
toast
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ClassNames } from "../../utils/class-names.js";
|
|
2
|
+
import { type ToastTone } from "./toast-store.js";
|
|
2
3
|
export type { ToastAction, ToastOptions } from "./toast.js";
|
|
3
4
|
export { toast } from "./toast.js";
|
|
4
5
|
export type ToasterPosition = "top-left" | "top-center" | "top-right" | "bottom-left" | "bottom-center" | "bottom-right";
|
|
@@ -22,6 +23,8 @@ export interface ToasterProps {
|
|
|
22
23
|
/** Text direction of the region. Defaults to the `dir` of the `<html>` element. */
|
|
23
24
|
dir?: "ltr" | "rtl";
|
|
24
25
|
}
|
|
26
|
+
/** Class map behind each tone. `default` is the inverted neutral toast; the others tint the surface. */
|
|
27
|
+
export declare const toastToneClasses: Readonly<Record<ToastTone, string>>;
|
|
25
28
|
/**
|
|
26
29
|
* Ephemeral, non-critical confirmations. Pass `action: { label, onClick }` to
|
|
27
30
|
* `toast()` for an undo button. Critical messages belong in a banner instead.
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
useState,
|
|
7
7
|
useSyncExternalStore
|
|
8
8
|
} from "react";
|
|
9
|
+
import { statusIcon } from "../../atoms/internal/status-icons.js";
|
|
9
10
|
import { useUiStrings } from "../../i18n/ui-strings-provider.js";
|
|
10
11
|
import { Portal } from "../../primitives/portal.js";
|
|
11
12
|
import { cn } from "../../utils/cn.js";
|
|
@@ -19,6 +20,33 @@ import {
|
|
|
19
20
|
subscribe
|
|
20
21
|
} from "./toast-store.js";
|
|
21
22
|
import { toast } from "./toast.js";
|
|
23
|
+
const toastToneClasses = {
|
|
24
|
+
default: "bg-toast-bg text-toast-ink",
|
|
25
|
+
success: "border border-success/40 bg-success-soft text-ink",
|
|
26
|
+
info: "border border-info/40 bg-info-soft text-ink",
|
|
27
|
+
warning: "border border-warning/40 bg-warning-soft text-ink",
|
|
28
|
+
error: "border border-danger/40 bg-danger-soft text-ink"
|
|
29
|
+
};
|
|
30
|
+
const toneActionClasses = {
|
|
31
|
+
default: "bg-toast-ink/18 text-toast-ink",
|
|
32
|
+
success: "bg-ink/10 text-ink hover:bg-ink/15",
|
|
33
|
+
info: "bg-ink/10 text-ink hover:bg-ink/15",
|
|
34
|
+
warning: "bg-ink/10 text-ink hover:bg-ink/15",
|
|
35
|
+
error: "bg-ink/10 text-ink hover:bg-ink/15"
|
|
36
|
+
};
|
|
37
|
+
const toneGlyph = {
|
|
38
|
+
default: null,
|
|
39
|
+
success: "success",
|
|
40
|
+
info: "info",
|
|
41
|
+
warning: "warning",
|
|
42
|
+
error: "danger"
|
|
43
|
+
};
|
|
44
|
+
const toneGlyphColor = {
|
|
45
|
+
success: "text-success",
|
|
46
|
+
info: "text-info",
|
|
47
|
+
warning: "text-warning",
|
|
48
|
+
danger: "text-danger"
|
|
49
|
+
};
|
|
22
50
|
const EXIT_MS = 200;
|
|
23
51
|
const SWIPE_THRESHOLD = 60;
|
|
24
52
|
const POSITION = {
|
|
@@ -107,6 +135,7 @@ function ToastItem({ record, duration, reducedMotion, classNames }) {
|
|
|
107
135
|
if (Math.abs(dx) >= SWIPE_THRESHOLD) dismiss(id);
|
|
108
136
|
};
|
|
109
137
|
const isError = tone === "error";
|
|
138
|
+
const glyph = toneGlyph[tone];
|
|
110
139
|
const closed = state === "closed";
|
|
111
140
|
const swiping = dragX !== 0;
|
|
112
141
|
return (
|
|
@@ -133,7 +162,8 @@ function ToastItem({ record, duration, reducedMotion, classNames }) {
|
|
|
133
162
|
onPointerCancel: endDrag,
|
|
134
163
|
style: swiping ? { transform: `translateX(${dragX}px)`, opacity: 1 - Math.abs(dragX) / 200 } : void 0,
|
|
135
164
|
className: cn(
|
|
136
|
-
"pointer-events-auto flex min-h-11 w-max max-w-[min(92vw,26rem)] touch-pan-y items-center gap-3 rounded-button
|
|
165
|
+
"pointer-events-auto flex min-h-11 w-max max-w-[min(92vw,26rem)] touch-pan-y items-center gap-3 rounded-button py-1.5 pr-2 pl-4 text-control shadow-overlay",
|
|
166
|
+
toastToneClasses[tone],
|
|
137
167
|
"transition-[opacity,transform] duration-200 ease-out motion-reduce:transition-none",
|
|
138
168
|
!entered && "opacity-0 data-[state=open]:translate-y-2",
|
|
139
169
|
closed && "opacity-0",
|
|
@@ -141,6 +171,7 @@ function ToastItem({ record, duration, reducedMotion, classNames }) {
|
|
|
141
171
|
classNames?.toast
|
|
142
172
|
),
|
|
143
173
|
children: [
|
|
174
|
+
glyph ? /* @__PURE__ */ jsx("span", { "data-slot": "glyph", className: cn("shrink-0", toneGlyphColor[glyph]), children: statusIcon(glyph, "size-4") }) : null,
|
|
144
175
|
/* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
|
|
145
176
|
/* @__PURE__ */ jsx("div", { className: classNames?.title, children: record.message }),
|
|
146
177
|
record.description ? /* @__PURE__ */ jsx("div", { className: cn("opacity-70", classNames?.description), children: record.description }) : null
|
|
@@ -150,7 +181,8 @@ function ToastItem({ record, duration, reducedMotion, classNames }) {
|
|
|
150
181
|
{
|
|
151
182
|
type: "button",
|
|
152
183
|
className: cn(
|
|
153
|
-
"h-8 shrink-0 rounded-button
|
|
184
|
+
"h-8 shrink-0 rounded-button px-3 font-bold focus-ring",
|
|
185
|
+
toneActionClasses[tone],
|
|
154
186
|
classNames?.action
|
|
155
187
|
),
|
|
156
188
|
onClick: (event) => {
|
|
@@ -228,5 +260,6 @@ function Toaster({
|
|
|
228
260
|
}
|
|
229
261
|
export {
|
|
230
262
|
Toaster,
|
|
231
|
-
toast
|
|
263
|
+
toast,
|
|
264
|
+
toastToneClasses
|
|
232
265
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Tooltip, type TooltipPart, type TooltipProps } from "./tooltip.js";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** Hover opens a tooltip for a mouse or pen, never for a finger: a tap must reach the control. */
|
|
2
|
+
export declare function opensOnHover(pointerType: string): boolean;
|
|
3
|
+
/**
|
|
4
|
+
* Focus opens a tooltip only when it came from the keyboard (`:focus-visible`) and not from a
|
|
5
|
+
* press that has just closed it, so clicking a button never makes its tooltip flicker back.
|
|
6
|
+
*/
|
|
7
|
+
export declare function opensOnFocus({ pressed, focusVisible, }: {
|
|
8
|
+
pressed: boolean;
|
|
9
|
+
focusVisible: boolean;
|
|
10
|
+
}): boolean;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ReactElement, type ReactNode } from "react";
|
|
2
|
+
import type { Align, Side } from "../../primitives/popper/geometry.js";
|
|
3
|
+
import type { ClassNames } from "../../utils/class-names.js";
|
|
4
|
+
import { type Material } from "../../utils/material.js";
|
|
5
|
+
export type TooltipPart = "content" | "shortcut";
|
|
6
|
+
export interface TooltipProps {
|
|
7
|
+
/** The hint. It repeats or complements the trigger's name; never put information only here. */
|
|
8
|
+
content: ReactNode;
|
|
9
|
+
/** Keyboard shortcut shown next to the hint, rendered as a `Kbd`. */
|
|
10
|
+
shortcut?: ReactNode;
|
|
11
|
+
side?: Side;
|
|
12
|
+
align?: Align;
|
|
13
|
+
/** Gap between the trigger and the tooltip, in px. */
|
|
14
|
+
sideOffset?: number;
|
|
15
|
+
/** ms the pointer must rest on the trigger before the tooltip opens. Keyboard focus opens at once. */
|
|
16
|
+
openDelay?: number;
|
|
17
|
+
/** ms before closing after the pointer leaves, so it can travel onto the tooltip (WCAG 1.4.13). */
|
|
18
|
+
closeDelay?: number;
|
|
19
|
+
/** Controlled open state. */
|
|
20
|
+
open?: boolean;
|
|
21
|
+
defaultOpen?: boolean;
|
|
22
|
+
onOpenChange?: (open: boolean) => void;
|
|
23
|
+
/** Never show the tooltip, e.g. when the label is already visible. */
|
|
24
|
+
disabled?: boolean;
|
|
25
|
+
/** Portal target. Defaults to `document.body`; pass an element to keep a scoped `data-style`. */
|
|
26
|
+
container?: HTMLElement | null;
|
|
27
|
+
/** Surface material; see `PopoverContent`. */
|
|
28
|
+
material?: Material;
|
|
29
|
+
className?: string;
|
|
30
|
+
/** Per-part classes merged with `cn`; consumer classes win. `className` still targets the content and is merged last. */
|
|
31
|
+
classNames?: ClassNames<TooltipPart>;
|
|
32
|
+
/** The element that gets the tooltip. It receives `aria-describedby` while the tooltip is open. */
|
|
33
|
+
children: ReactElement;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Short, non-interactive hint for a control. Opens on hover (after `openDelay`) and on keyboard
|
|
37
|
+
* focus, closes on Escape, blur, press and pointer leave. Touch never opens it by hover, so a tap
|
|
38
|
+
* always reaches the control. The trigger is described by it (`aria-describedby`), and the
|
|
39
|
+
* tooltip never takes focus.
|
|
40
|
+
*/
|
|
41
|
+
export declare function Tooltip({ content, shortcut, side, align, sideOffset, openDelay, closeDelay, open: openProp, defaultOpen, onOpenChange, disabled, container, material, className, classNames, children, }: TooltipProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import {
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useId,
|
|
7
|
+
useRef
|
|
8
|
+
} from "react";
|
|
9
|
+
import { Kbd } from "../../atoms/kbd/kbd.js";
|
|
10
|
+
import * as PopoverPrimitive from "../../primitives/popover/popover.js";
|
|
11
|
+
import { cn } from "../../utils/cn.js";
|
|
12
|
+
import { materialClass } from "../../utils/material.js";
|
|
13
|
+
import { Slot } from "../../utils/slot.js";
|
|
14
|
+
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
15
|
+
import { opensOnFocus, opensOnHover } from "./model.js";
|
|
16
|
+
function focusIsVisible(element) {
|
|
17
|
+
try {
|
|
18
|
+
return element.matches(":focus-visible");
|
|
19
|
+
} catch {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function Tooltip({
|
|
24
|
+
content,
|
|
25
|
+
shortcut,
|
|
26
|
+
side = "top",
|
|
27
|
+
align = "center",
|
|
28
|
+
sideOffset = 6,
|
|
29
|
+
openDelay = 300,
|
|
30
|
+
closeDelay = 100,
|
|
31
|
+
open: openProp,
|
|
32
|
+
defaultOpen = false,
|
|
33
|
+
onOpenChange,
|
|
34
|
+
disabled = false,
|
|
35
|
+
container,
|
|
36
|
+
material,
|
|
37
|
+
className,
|
|
38
|
+
classNames,
|
|
39
|
+
children
|
|
40
|
+
}) {
|
|
41
|
+
const [openState, setOpen] = useControllableState({
|
|
42
|
+
prop: openProp,
|
|
43
|
+
defaultProp: defaultOpen,
|
|
44
|
+
onChange: onOpenChange
|
|
45
|
+
});
|
|
46
|
+
const open = openState && !disabled;
|
|
47
|
+
const contentId = useId();
|
|
48
|
+
const timer = useRef(void 0);
|
|
49
|
+
const pressed = useRef(false);
|
|
50
|
+
const schedule = useCallback(
|
|
51
|
+
(next, delay) => {
|
|
52
|
+
window.clearTimeout(timer.current);
|
|
53
|
+
if (delay <= 0) setOpen(next);
|
|
54
|
+
else timer.current = window.setTimeout(() => setOpen(next), delay);
|
|
55
|
+
},
|
|
56
|
+
[setOpen]
|
|
57
|
+
);
|
|
58
|
+
useEffect(() => () => window.clearTimeout(timer.current), []);
|
|
59
|
+
const trigger = /* @__PURE__ */ jsx(
|
|
60
|
+
Slot,
|
|
61
|
+
{
|
|
62
|
+
"aria-describedby": open ? contentId : void 0,
|
|
63
|
+
onPointerEnter: (event) => {
|
|
64
|
+
if (opensOnHover(event.pointerType)) schedule(true, openDelay);
|
|
65
|
+
},
|
|
66
|
+
onPointerLeave: (event) => {
|
|
67
|
+
if (opensOnHover(event.pointerType)) schedule(false, closeDelay);
|
|
68
|
+
},
|
|
69
|
+
onPointerDown: () => {
|
|
70
|
+
pressed.current = true;
|
|
71
|
+
schedule(false, 0);
|
|
72
|
+
},
|
|
73
|
+
onFocus: (event) => {
|
|
74
|
+
if (opensOnFocus({ pressed: pressed.current, focusVisible: focusIsVisible(event.target) })) {
|
|
75
|
+
schedule(true, 0);
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
onBlur: () => {
|
|
79
|
+
pressed.current = false;
|
|
80
|
+
schedule(false, 0);
|
|
81
|
+
},
|
|
82
|
+
children
|
|
83
|
+
}
|
|
84
|
+
);
|
|
85
|
+
return /* @__PURE__ */ jsxs(PopoverPrimitive.Root, { open, onOpenChange: setOpen, children: [
|
|
86
|
+
/* @__PURE__ */ jsx(PopoverPrimitive.Anchor, { asChild: true, children: trigger }),
|
|
87
|
+
/* @__PURE__ */ jsx(PopoverPrimitive.Portal, { container, children: /* @__PURE__ */ jsxs(
|
|
88
|
+
PopoverPrimitive.Content,
|
|
89
|
+
{
|
|
90
|
+
id: contentId,
|
|
91
|
+
role: "tooltip",
|
|
92
|
+
side,
|
|
93
|
+
align,
|
|
94
|
+
sideOffset,
|
|
95
|
+
collisionPadding: 8,
|
|
96
|
+
onOpenAutoFocus: (event) => event.preventDefault(),
|
|
97
|
+
onCloseAutoFocus: (event) => event.preventDefault(),
|
|
98
|
+
onMouseEnter: () => schedule(true, 0),
|
|
99
|
+
onMouseLeave: () => schedule(false, closeDelay),
|
|
100
|
+
className: cn(
|
|
101
|
+
"z-85 flex w-max max-w-[min(16rem,var(--ui-popper-available-width))] items-center gap-2 rounded-popover surface-overlay px-2.5 py-1.5 text-meta text-ink shadow-overlay",
|
|
102
|
+
materialClass(material, "surface-solid"),
|
|
103
|
+
classNames?.content,
|
|
104
|
+
className
|
|
105
|
+
),
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 break-words", children: content }),
|
|
108
|
+
shortcut === void 0 ? null : /* @__PURE__ */ jsx(Kbd, { className: classNames?.shortcut, children: shortcut })
|
|
109
|
+
]
|
|
110
|
+
}
|
|
111
|
+
) })
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
Tooltip
|
|
116
|
+
};
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
useRef
|
|
6
6
|
} from "react";
|
|
7
7
|
import { useEnabledPointerEvents } from "./pointer-events-lock.js";
|
|
8
|
-
const FOREIGN_LAYER = "[role=listbox][data-state=open], [role=combobox][aria-expanded=true]";
|
|
8
|
+
const FOREIGN_LAYER = "[role=listbox][data-state=open]:not([data-ui-layer]), [role=combobox][aria-expanded=true]:not([data-ui-layer])";
|
|
9
9
|
const LAYER_BRANCH_ATTRIBUTE = "data-ui-layer-branch";
|
|
10
10
|
const LAYER_BRANCH = `[${LAYER_BRANCH_ATTRIBUTE}]`;
|
|
11
11
|
const ESCAPE_CLAIM = "[data-ui-escape-claim]";
|
|
@@ -12,8 +12,13 @@ export interface ErrorStateProps {
|
|
|
12
12
|
correlationLabel?: string;
|
|
13
13
|
onRetry?: () => void;
|
|
14
14
|
retryLabel?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Extra actions (buttons or links) in the same row as the retry button, under the message.
|
|
17
|
+
* Use it for "Go back" or "Contact support"; `onRetry` stays the shortcut for a plain retry.
|
|
18
|
+
*/
|
|
19
|
+
actions?: ReactNode;
|
|
15
20
|
/** `outlined` draws a danger border around the state. */
|
|
16
21
|
variant?: "plain" | "outlined";
|
|
17
22
|
className?: string;
|
|
18
23
|
}
|
|
19
|
-
export declare function ErrorState({ title, description, message, correlationId, correlationLabel, onRetry, retryLabel, variant, className, }: ErrorStateProps): import("react").JSX.Element;
|
|
24
|
+
export declare function ErrorState({ title, description, message, correlationId, correlationLabel, onRetry, retryLabel, actions, variant, className, }: ErrorStateProps): import("react").JSX.Element;
|
|
@@ -11,6 +11,7 @@ function ErrorState({
|
|
|
11
11
|
correlationLabel,
|
|
12
12
|
onRetry,
|
|
13
13
|
retryLabel,
|
|
14
|
+
actions,
|
|
14
15
|
variant = "plain",
|
|
15
16
|
className
|
|
16
17
|
}) {
|
|
@@ -34,15 +35,18 @@ function ErrorState({
|
|
|
34
35
|
" ",
|
|
35
36
|
correlationId
|
|
36
37
|
] }) : null,
|
|
37
|
-
onRetry ? /* @__PURE__ */
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
38
|
+
onRetry || displayable(actions) !== void 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-2 flex flex-wrap items-center justify-center gap-2", children: [
|
|
39
|
+
onRetry ? /* @__PURE__ */ jsx(
|
|
40
|
+
"button",
|
|
41
|
+
{
|
|
42
|
+
type: "button",
|
|
43
|
+
onClick: onRetry,
|
|
44
|
+
className: "inline-flex h-control-sm cursor-pointer items-center rounded-input border-control bg-surface-control px-3 font-semibold text-fs-130 text-ink hover:bg-surface-2",
|
|
45
|
+
children: retryLabel ?? strings.retry
|
|
46
|
+
}
|
|
47
|
+
) : null,
|
|
48
|
+
displayable(actions)
|
|
49
|
+
] }) : null
|
|
46
50
|
]
|
|
47
51
|
}
|
|
48
52
|
);
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
-
export type SkeletonVariant = "lines" | "table" | "card";
|
|
1
|
+
export type SkeletonVariant = "lines" | "table" | "card" | "list" | "kpis" | "key-value" | "bar";
|
|
2
2
|
export interface SkeletonProps {
|
|
3
3
|
variant?: SkeletonVariant;
|
|
4
4
|
/** Number of lines for the `lines` variant. */
|
|
5
5
|
lines?: number;
|
|
6
6
|
/** Number of rows for the `table` variant. */
|
|
7
7
|
rows?: number;
|
|
8
|
+
/** Number of items for the `list`, `kpis` and `key-value` variants. Defaults to 4, at most 12. */
|
|
9
|
+
count?: number;
|
|
8
10
|
/** Text announced to screen readers while loading. */
|
|
9
11
|
label?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Classes on the root. The `bar` variant is one block sized by them (`h-8 w-32`), 12px tall and
|
|
14
|
+
* full width otherwise.
|
|
15
|
+
*/
|
|
10
16
|
className?: string;
|
|
11
17
|
}
|
|
12
|
-
export declare function Skeleton({ variant, lines, rows, label, className, }: SkeletonProps): import("react").JSX.Element;
|
|
18
|
+
export declare function Skeleton({ variant, lines, rows, count, label, className, }: SkeletonProps): import("react").JSX.Element;
|
|
@@ -3,10 +3,17 @@ import { jsx, jsxs } from "react/jsx-runtime";
|
|
|
3
3
|
import { useUiStrings } from "../../i18n/index.js";
|
|
4
4
|
import { cn } from "../../utils/cn.js";
|
|
5
5
|
const PLACEHOLDER_IDS = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l"];
|
|
6
|
+
function Bar({ className }) {
|
|
7
|
+
return /* @__PURE__ */ jsx("span", { "aria-hidden": "true", className: cn("block h-3 rounded-xs bg-surface-2", className) });
|
|
8
|
+
}
|
|
9
|
+
function items(count, render) {
|
|
10
|
+
return PLACEHOLDER_IDS.slice(0, Math.max(0, count)).map((id, index) => render(id, index));
|
|
11
|
+
}
|
|
6
12
|
function Skeleton({
|
|
7
13
|
variant = "lines",
|
|
8
14
|
lines = 3,
|
|
9
15
|
rows = 4,
|
|
16
|
+
count = 4,
|
|
10
17
|
label,
|
|
11
18
|
className
|
|
12
19
|
}) {
|
|
@@ -17,7 +24,11 @@ function Skeleton({
|
|
|
17
24
|
role: "status",
|
|
18
25
|
"aria-busy": "true",
|
|
19
26
|
"aria-label": label ?? strings.loading,
|
|
20
|
-
className: cn(
|
|
27
|
+
className: cn(
|
|
28
|
+
"animate-pulse",
|
|
29
|
+
variant === "bar" && "block h-3 w-full rounded-xs bg-surface-2",
|
|
30
|
+
className
|
|
31
|
+
),
|
|
21
32
|
children: [
|
|
22
33
|
variant === "lines" ? /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: PLACEHOLDER_IDS.slice(0, lines).map((id, index) => /* @__PURE__ */ jsx(
|
|
23
34
|
"div",
|
|
@@ -28,11 +39,42 @@ function Skeleton({
|
|
|
28
39
|
id
|
|
29
40
|
)) }) : null,
|
|
30
41
|
variant === "table" ? /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-2", children: PLACEHOLDER_IDS.slice(0, rows).map((id) => /* @__PURE__ */ jsx("div", { className: "h-9 rounded-xs bg-surface-2" }, id)) }) : null,
|
|
31
|
-
variant === "card" ? /* @__PURE__ */ jsx("div", { className: "h-40 rounded-card bg-surface-2" }) : null
|
|
42
|
+
variant === "card" ? /* @__PURE__ */ jsx("div", { className: "h-40 rounded-card bg-surface-2" }) : null,
|
|
43
|
+
variant === "list" ? /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: items(count, (id, index) => /* @__PURE__ */ jsxs(
|
|
44
|
+
"div",
|
|
45
|
+
{
|
|
46
|
+
className: "grid min-h-11 grid-cols-[minmax(0,1fr)_auto] items-center gap-3 border-b-divider py-2.5 in-data-[density=touch]:min-h-14",
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ jsxs("span", { className: "flex flex-col gap-1.5", children: [
|
|
49
|
+
/* @__PURE__ */ jsx(Bar, { className: index % 2 === 0 ? "w-2/5" : "w-1/2" }),
|
|
50
|
+
/* @__PURE__ */ jsx(Bar, { className: "h-2.5 w-1/4" })
|
|
51
|
+
] }),
|
|
52
|
+
/* @__PURE__ */ jsx(Bar, { className: "w-14" })
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
id
|
|
56
|
+
)) }) : null,
|
|
57
|
+
variant === "kpis" ? /* @__PURE__ */ jsx("div", { className: "grid gap-3 [grid-template-columns:repeat(auto-fit,minmax(min(168px,100%),1fr))]", children: items(count, (id) => /* @__PURE__ */ jsxs(
|
|
58
|
+
"div",
|
|
59
|
+
{
|
|
60
|
+
className: "flex flex-col gap-2.5 rounded-card border-card bg-surface px-4 py-3.5",
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsx(Bar, { className: "w-1/2" }),
|
|
63
|
+
/* @__PURE__ */ jsx(Bar, { className: "h-6.5 w-2/3" }),
|
|
64
|
+
/* @__PURE__ */ jsx(Bar, { className: "w-1/3" })
|
|
65
|
+
]
|
|
66
|
+
},
|
|
67
|
+
id
|
|
68
|
+
)) }) : null,
|
|
69
|
+
variant === "key-value" ? /* @__PURE__ */ jsx("div", { className: "grid gap-x-4 gap-y-2.5 py-3 [grid-template-columns:minmax(min(6.5rem,40%),10rem)_minmax(0,1fr)]", children: items(count, (id, index) => /* @__PURE__ */ jsxs("div", { className: "contents", children: [
|
|
70
|
+
/* @__PURE__ */ jsx(Bar, { className: "w-3/4" }),
|
|
71
|
+
/* @__PURE__ */ jsx(Bar, { className: KEY_VALUE_WIDTHS[index % KEY_VALUE_WIDTHS.length] })
|
|
72
|
+
] }, id)) }) : null
|
|
32
73
|
]
|
|
33
74
|
}
|
|
34
75
|
);
|
|
35
76
|
}
|
|
77
|
+
const KEY_VALUE_WIDTHS = ["w-11/12", "w-3/4", "w-5/6", "w-2/3"];
|
|
36
78
|
export {
|
|
37
79
|
Skeleton
|
|
38
80
|
};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" />
|
|
3
|
+
<circle cx="12" cy="12" r="3" />
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<path d="M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0z" />
|
|
3
|
+
<path d="M22 10v6" />
|
|
4
|
+
<path d="M6 12.5V16a6 3 0 0 0 12 0v-3.5" />
|
|
5
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<path d="M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8" />
|
|
3
|
+
<path d="M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" />
|
|
4
|
+
</svg>
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
2
|
+
<path d="m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7" />
|
|
3
|
+
<rect x="2" y="4" width="20" height="16" rx="2" />
|
|
4
|
+
</svg>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jcsoftdev/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Token-driven React component library: React 19, Tailwind v4.",
|
|
5
5
|
"author": "jcsoftdev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"typescript": "^5.5.4",
|
|
103
103
|
"vite": "7.3.6",
|
|
104
104
|
"vitest": "4.1.11",
|
|
105
|
-
"@jcsoftdev/ui-tokens": "^0.
|
|
105
|
+
"@jcsoftdev/ui-tokens": "^0.5.0"
|
|
106
106
|
},
|
|
107
107
|
"publishConfig": {
|
|
108
108
|
"access": "public"
|
package/scripts/build-theme.mjs
CHANGED
|
@@ -336,7 +336,18 @@ export function buildThemeCss(tokens) {
|
|
|
336
336
|
cssRule(`@utility ${name}`, body),
|
|
337
337
|
);
|
|
338
338
|
const tail = utilities.length ? `\n${utilities.join("\n\n")}\n` : "";
|
|
339
|
-
|
|
339
|
+
// A token whose utility name equals its raw variable (`--radius-input: var(--radius-input)`) would
|
|
340
|
+
// be emitted into Tailwind's theme layer as a cycle, which resolves to nothing for any consumer that
|
|
341
|
+
// loads tokens.css below that layer. `reference` keeps the utilities and drops the declaration;
|
|
342
|
+
// the utilities read the raw variable directly because the block is also `inline`.
|
|
343
|
+
const selfReference = (l) => {
|
|
344
|
+
const m = /^\s*(--[\w-]+): var\((--[\w-]+)\);$/.exec(l);
|
|
345
|
+
return m !== null && m[1] === m[2];
|
|
346
|
+
};
|
|
347
|
+
const mapped = lines.filter((l) => !selfReference(l));
|
|
348
|
+
const same = lines.filter(selfReference);
|
|
349
|
+
const reference = same.length ? `\n@theme reference inline {\n${same.join("\n")}\n}\n` : "";
|
|
350
|
+
return `/* Generated by ui-theme from "${tokens.name}". Do not edit. */\n@theme inline {\n${mapped.join("\n")}\n}\n${reference}${tail}`;
|
|
340
351
|
}
|
|
341
352
|
|
|
342
353
|
export function buildFontsCss(tokens) {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
type ComponentPropsWithRef,
|
|
6
6
|
Fragment,
|
|
7
7
|
isValidElement,
|
|
8
|
+
type MouseEvent,
|
|
8
9
|
type ReactNode,
|
|
9
10
|
} from "react";
|
|
10
11
|
import { useUiStrings } from "../../i18n/index.js";
|
|
@@ -19,7 +20,7 @@ export type ButtonSize = "sm" | "md" | "lg";
|
|
|
19
20
|
* `cn(buttonVariantClasses.primary, "bg-brand")` on a link, or `{ ...buttonVariantClasses, brand: "..." }`.
|
|
20
21
|
*/
|
|
21
22
|
export const buttonVariantClasses: Readonly<Record<ButtonVariant, string>> = {
|
|
22
|
-
primary: "bg-accent text-on-accent font-bold hover:bg-accent-ink",
|
|
23
|
+
primary: "bg-accent text-on-accent font-bold hover:bg-accent-ink hover:text-surface",
|
|
23
24
|
secondary: "bg-surface-control text-ink shadow-control hover:bg-surface-2",
|
|
24
25
|
ghost: "bg-transparent text-ink-2 hover:bg-surface-2 hover:text-ink",
|
|
25
26
|
danger: "bg-danger-soft text-danger hover:bg-danger-soft/70",
|
|
@@ -33,7 +34,7 @@ export const buttonSizeClasses: Readonly<Record<ButtonSize, string>> = {
|
|
|
33
34
|
};
|
|
34
35
|
|
|
35
36
|
const baseClasses =
|
|
36
|
-
"inline-flex min-w-0 max-w-full cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap rounded-button pressable focus-visible:focus-ring font-[650] no-underline disabled:cursor-not-allowed disabled:opacity-45 [&_svg]:shrink-0";
|
|
37
|
+
"inline-flex min-w-0 max-w-full cursor-pointer items-center justify-center gap-1.5 whitespace-nowrap rounded-button pressable focus-visible:focus-ring font-[650] no-underline disabled:cursor-not-allowed disabled:opacity-45 aria-busy:cursor-progress aria-busy:scale-none! [&_svg]:shrink-0";
|
|
37
38
|
|
|
38
39
|
export interface ButtonClassOptions {
|
|
39
40
|
variant?: ButtonVariant;
|
|
@@ -64,6 +65,13 @@ export function buttonClasses({
|
|
|
64
65
|
export interface ButtonProps extends ComponentPropsWithRef<"button"> {
|
|
65
66
|
variant?: ButtonVariant;
|
|
66
67
|
size?: ButtonSize;
|
|
68
|
+
/**
|
|
69
|
+
* Busy state: the button keeps its focus and its full colour, ignores clicks (a submit button no
|
|
70
|
+
* longer submits, including the implicit submit from Enter in a field of its form) and is exposed
|
|
71
|
+
* as `aria-disabled` and `aria-busy`. It is not natively `disabled`, so keyboard focus stays on it
|
|
72
|
+
* while the work runs; pass `disabled` for a button that must leave the tab order. The visible
|
|
73
|
+
* cue is `loadingLabel` or a spinner among the children: without either only the cursor changes.
|
|
74
|
+
*/
|
|
67
75
|
loading?: boolean;
|
|
68
76
|
/**
|
|
69
77
|
* Replaces the children while `loading` and is announced to screen readers. Without it the
|
|
@@ -86,9 +94,12 @@ export function Button({
|
|
|
86
94
|
asChild,
|
|
87
95
|
className,
|
|
88
96
|
children,
|
|
97
|
+
onClick,
|
|
89
98
|
...props
|
|
90
99
|
}: ButtonProps) {
|
|
91
100
|
const strings = useUiStrings();
|
|
101
|
+
// Natively disabled wins; a busy button stays focusable and swallows its activation instead.
|
|
102
|
+
const busy = Boolean(loading) && !disabled;
|
|
92
103
|
const Comp = asChild ? Slot : "button";
|
|
93
104
|
// Text runs get their own truncating span so a long label ends in "…" inside a narrow
|
|
94
105
|
// container instead of overflowing; icons keep their size. Slot needs its single child as is.
|
|
@@ -102,9 +113,11 @@ export function Button({
|
|
|
102
113
|
<Comp
|
|
103
114
|
{...(asChild ? {} : { type: "button" })}
|
|
104
115
|
aria-busy={loading ? "true" : undefined}
|
|
105
|
-
disabled={
|
|
116
|
+
aria-disabled={busy || undefined}
|
|
117
|
+
disabled={disabled}
|
|
106
118
|
className={buttonClasses({ variant, size, block, className })}
|
|
107
119
|
{...props}
|
|
120
|
+
onClick={busy ? ignoreClick : onClick}
|
|
108
121
|
>
|
|
109
122
|
{content}
|
|
110
123
|
</Comp>
|
|
@@ -120,6 +133,15 @@ export function Button({
|
|
|
120
133
|
);
|
|
121
134
|
}
|
|
122
135
|
|
|
136
|
+
/**
|
|
137
|
+
* Cancels the activation of a busy button: no handler runs, a submit button does not submit (an
|
|
138
|
+
* implicit submit from Enter in a field is a click on this button too) and a slotted link does not
|
|
139
|
+
* navigate.
|
|
140
|
+
*/
|
|
141
|
+
function ignoreClick(event: MouseEvent<HTMLElement>): void {
|
|
142
|
+
event.preventDefault();
|
|
143
|
+
}
|
|
144
|
+
|
|
123
145
|
function labelRun(child: ReactNode): ReactNode {
|
|
124
146
|
if (typeof child === "string" || typeof child === "number") {
|
|
125
147
|
return <span className="min-w-0 truncate">{child}</span>;
|
|
@@ -7,6 +7,7 @@ import { cn } from "../../utils/cn.js";
|
|
|
7
7
|
import { composeHandlers, useComposedRefs } from "../../utils/compose.js";
|
|
8
8
|
import { BubbleInput, useFormBubble, useFormReset } from "../../utils/form-bubble.js";
|
|
9
9
|
import { useControllableState } from "../../utils/use-controllable-state.js";
|
|
10
|
+
import { touchHitArea } from "../internal/hit-area.js";
|
|
10
11
|
|
|
11
12
|
export type CheckedState = boolean | "indeterminate";
|
|
12
13
|
|
|
@@ -86,7 +87,8 @@ export function Checkbox({
|
|
|
86
87
|
{...props}
|
|
87
88
|
ref={composedRef}
|
|
88
89
|
className={cn(
|
|
89
|
-
|
|
90
|
+
touchHitArea,
|
|
91
|
+
"group inline-flex size-10 shrink-0 items-center justify-center disabled:cursor-not-allowed disabled:opacity-50",
|
|
90
92
|
classNames?.root,
|
|
91
93
|
className,
|
|
92
94
|
)}
|