@nizivo/react 0.0.0-stage → 0.2.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/LICENSE +202 -0
- package/README.md +120 -2
- package/THIRD_PARTY_NOTICES +68 -0
- package/dist/_engines/react-aria/dialog.client.js +126 -0
- package/dist/_engines/react-aria/dom-allowlist.js +19 -0
- package/dist/_engines/react-aria/dom.js +31 -0
- package/dist/_engines/react-aria/drawer.client.js +8 -0
- package/dist/_engines/react-aria/file-upload.client.js +50 -0
- package/dist/_engines/react-aria/locale.client.js +13 -0
- package/dist/_engines/react-aria/menu.client.js +229 -0
- package/dist/_engines/react-aria/open-state.client.js +53 -0
- package/dist/_engines/react-aria/outside-press.client.js +61 -0
- package/dist/_engines/react-aria/overlay.client.js +46 -0
- package/dist/_engines/react-aria/popover.client.js +148 -0
- package/dist/_engines/react-aria/popup.client.js +153 -0
- package/dist/_engines/react-aria/select.client.js +180 -0
- package/dist/_engines/react-aria/tabs.client.js +95 -0
- package/dist/_engines/react-aria/toast.client.js +38 -0
- package/dist/_engines/react-aria/tooltip.client.js +72 -0
- package/dist/_internal/cx.js +11 -0
- package/dist/_internal/data-status.d.ts +3 -0
- package/dist/_internal/data-status.js +13 -0
- package/dist/_internal/engine-part.d.ts +1 -0
- package/dist/_internal/field.js +20 -0
- package/dist/_internal/glyphs.js +87 -0
- package/dist/_internal/keys.js +62 -0
- package/dist/_internal/modal.client.js +54 -0
- package/dist/_internal/nested-focus.js +33 -0
- package/dist/_internal/overlay.d.ts +9 -0
- package/dist/_virtual/_rolldown/runtime.js +13 -0
- package/dist/alert/alert-dismiss.client.d.ts +32 -0
- package/dist/alert/alert-dismiss.client.js +38 -0
- package/dist/alert/alert.d.ts +28 -0
- package/dist/alert/alert.js +44 -0
- package/dist/alert/index.d.ts +3 -0
- package/dist/alert/index.js +3 -0
- package/dist/app-shell/app-shell.d.ts +24 -0
- package/dist/app-shell/app-shell.js +56 -0
- package/dist/app-shell/index.d.ts +2 -0
- package/dist/app-shell/index.js +1 -0
- package/dist/augment.d.ts +13 -0
- package/dist/augment.js +0 -0
- package/dist/avatar/avatar.d.ts +96 -0
- package/dist/avatar/avatar.js +94 -0
- package/dist/avatar/index.d.ts +2 -0
- package/dist/avatar/index.js +1 -0
- package/dist/badge/badge.d.ts +19 -0
- package/dist/badge/badge.js +22 -0
- package/dist/badge/index.d.ts +2 -0
- package/dist/badge/index.js +1 -0
- package/dist/banner/banner-dismiss.client.d.ts +32 -0
- package/dist/banner/banner-dismiss.client.js +38 -0
- package/dist/banner/banner.d.ts +34 -0
- package/dist/banner/banner.js +47 -0
- package/dist/banner/index.d.ts +3 -0
- package/dist/banner/index.js +3 -0
- package/dist/breadcrumb/breadcrumb.d.ts +46 -0
- package/dist/breadcrumb/breadcrumb.js +46 -0
- package/dist/breadcrumb/breadcrumb.parts.d.ts +6 -0
- package/dist/breadcrumb/breadcrumb.parts.js +9 -0
- package/dist/breadcrumb/index.d.ts +3 -0
- package/dist/breadcrumb/index.js +3 -0
- package/dist/button/button.d.ts +55 -0
- package/dist/button/button.js +62 -0
- package/dist/button/index.d.ts +2 -0
- package/dist/button/index.js +1 -0
- package/dist/card/card.d.ts +64 -0
- package/dist/card/card.js +62 -0
- package/dist/card/card.parts.d.ts +6 -0
- package/dist/card/card.parts.js +14 -0
- package/dist/card/index.d.ts +3 -0
- package/dist/card/index.js +3 -0
- package/dist/checkbox/checkbox.client.d.ts +37 -0
- package/dist/checkbox/checkbox.client.js +81 -0
- package/dist/checkbox/index.d.ts +2 -0
- package/dist/checkbox/index.js +1 -0
- package/dist/chip-group/chip-group.client.d.ts +88 -0
- package/dist/chip-group/chip-group.client.js +157 -0
- package/dist/chip-group/index.d.ts +2 -0
- package/dist/chip-group/index.js +1 -0
- package/dist/choice-card/choice-card.client.d.ts +66 -0
- package/dist/choice-card/choice-card.client.js +138 -0
- package/dist/choice-card/index.d.ts +2 -0
- package/dist/choice-card/index.js +1 -0
- package/dist/config/config.client.d.ts +24 -0
- package/dist/config/config.client.js +33 -0
- package/dist/config/index.d.ts +2 -0
- package/dist/config/index.js +1 -0
- package/dist/container/container.d.ts +13 -0
- package/dist/container/container.js +16 -0
- package/dist/container/index.d.ts +2 -0
- package/dist/container/index.js +1 -0
- package/dist/contracts/details.d.ts +13 -0
- package/dist/contracts/details.js +9 -0
- package/dist/contracts/index.d.ts +5 -0
- package/dist/contracts/index.js +5 -0
- package/dist/contracts/merge-props.d.ts +16 -0
- package/dist/contracts/merge-props.js +76 -0
- package/dist/contracts/render.d.ts +17 -0
- package/dist/contracts/render.js +43 -0
- package/dist/contracts/state.d.ts +42 -0
- package/dist/contracts/state.js +42 -0
- package/dist/css/alert.css +2 -0
- package/dist/css/app-shell.css +2 -0
- package/dist/css/avatar.css +2 -0
- package/dist/css/badge.css +2 -0
- package/dist/css/banner.css +2 -0
- package/dist/css/base.css +2 -0
- package/dist/css/breadcrumb.css +2 -0
- package/dist/css/button.css +2 -0
- package/dist/css/card.css +2 -0
- package/dist/css/checkbox.css +2 -0
- package/dist/css/chip-group.css +2 -0
- package/dist/css/choice-card.css +2 -0
- package/dist/css/container.css +2 -0
- package/dist/css/delta.css +2 -0
- package/dist/css/dialog.css +2 -0
- package/dist/css/drawer.css +2 -0
- package/dist/css/empty-state.css +2 -0
- package/dist/css/field.css +2 -0
- package/dist/css/fieldset.css +2 -0
- package/dist/css/file-upload.css +2 -0
- package/dist/css/form.css +2 -0
- package/dist/css/grid.css +2 -0
- package/dist/css/heading.css +2 -0
- package/dist/css/icon-button.css +2 -0
- package/dist/css/image.css +2 -0
- package/dist/css/inline-error.css +2 -0
- package/dist/css/inline.css +2 -0
- package/dist/css/input.css +2 -0
- package/dist/css/kbd.css +2 -0
- package/dist/css/kpi-tile.css +2 -0
- package/dist/css/menu.css +2 -0
- package/dist/css/meter.css +2 -0
- package/dist/css/metric.css +2 -0
- package/dist/css/mobile-tab-bar.css +2 -0
- package/dist/css/mobile-top-bar.css +2 -0
- package/dist/css/motion.css +2 -0
- package/dist/css/native-select.css +2 -0
- package/dist/css/nav-item.css +2 -0
- package/dist/css/number-value.css +2 -0
- package/dist/css/page-header.css +2 -0
- package/dist/css/pagination.css +2 -0
- package/dist/css/password-input.css +2 -0
- package/dist/css/popover.css +2 -0
- package/dist/css/progress-bar.css +2 -0
- package/dist/css/progress-ring.css +2 -0
- package/dist/css/radio-group.css +2 -0
- package/dist/css/ranked-list.css +2 -0
- package/dist/css/search-field.css +2 -0
- package/dist/css/segmented-control.css +2 -0
- package/dist/css/select.css +2 -0
- package/dist/css/separator.css +2 -0
- package/dist/css/sidebar.css +2 -0
- package/dist/css/skeleton.css +2 -0
- package/dist/css/split.css +2 -0
- package/dist/css/stack.css +2 -0
- package/dist/css/sticky-bar.css +2 -0
- package/dist/css/switch.css +2 -0
- package/dist/css/tab-nav.css +2 -0
- package/dist/css/table-selection.css +2 -0
- package/dist/css/table.css +2 -0
- package/dist/css/tabs.css +2 -0
- package/dist/css/text.css +2 -0
- package/dist/css/textarea.css +2 -0
- package/dist/css/toast.css +2 -0
- package/dist/css/tooltip.css +2 -0
- package/dist/css/top-bar.css +2 -0
- package/dist/css/trend-card.css +2 -0
- package/dist/delta/delta.d.ts +32 -0
- package/dist/delta/delta.js +50 -0
- package/dist/delta/index.d.ts +2 -0
- package/dist/delta/index.js +1 -0
- package/dist/dialog/dialog.client.d.ts +25 -0
- package/dist/dialog/dialog.client.js +145 -0
- package/dist/dialog/dialog.contract.d.ts +97 -0
- package/dist/dialog/dialog.parts.d.ts +6 -0
- package/dist/dialog/dialog.parts.js +15 -0
- package/dist/dialog/index.d.ts +5 -0
- package/dist/dialog/index.js +3 -0
- package/dist/drawer/drawer.client.d.ts +25 -0
- package/dist/drawer/drawer.client.js +154 -0
- package/dist/drawer/drawer.contract.d.ts +98 -0
- package/dist/drawer/drawer.parts.d.ts +6 -0
- package/dist/drawer/drawer.parts.js +16 -0
- package/dist/drawer/index.d.ts +5 -0
- package/dist/drawer/index.js +3 -0
- package/dist/empty-state/empty-state.d.ts +18 -0
- package/dist/empty-state/empty-state.js +32 -0
- package/dist/empty-state/index.d.ts +2 -0
- package/dist/empty-state/index.js +1 -0
- package/dist/field/field-scope.client.d.ts +50 -0
- package/dist/field/field-scope.client.js +212 -0
- package/dist/field/field-static.d.ts +122 -0
- package/dist/field/field-static.js +159 -0
- package/dist/field/field.d.ts +5 -0
- package/dist/field/field.js +53 -0
- package/dist/field/index.d.ts +4 -0
- package/dist/field/index.js +4 -0
- package/dist/fieldset/fieldset.d.ts +36 -0
- package/dist/fieldset/fieldset.js +63 -0
- package/dist/fieldset/index.d.ts +2 -0
- package/dist/fieldset/index.js +1 -0
- package/dist/file-upload/file-upload.client.d.ts +9 -0
- package/dist/file-upload/file-upload.client.js +406 -0
- package/dist/file-upload/file-upload.contract.d.ts +112 -0
- package/dist/file-upload/index.d.ts +3 -0
- package/dist/file-upload/index.js +1 -0
- package/dist/file-upload/seam.d.ts +1 -0
- package/dist/form/form.client.d.ts +38 -0
- package/dist/form/form.client.js +127 -0
- package/dist/form/form.d.ts +36 -0
- package/dist/form/form.js +29 -0
- package/dist/form/index.d.ts +4 -0
- package/dist/form/index.js +4 -0
- package/dist/form/submit-button.client.d.ts +20 -0
- package/dist/form/submit-button.client.js +19 -0
- package/dist/grid/grid.d.ts +38 -0
- package/dist/grid/grid.js +28 -0
- package/dist/grid/index.d.ts +2 -0
- package/dist/grid/index.js +1 -0
- package/dist/heading/heading.d.ts +30 -0
- package/dist/heading/heading.js +26 -0
- package/dist/heading/index.d.ts +2 -0
- package/dist/heading/index.js +1 -0
- package/dist/i18n/format-label.d.ts +24 -0
- package/dist/i18n/format-label.js +19 -0
- package/dist/i18n/index.d.ts +2 -0
- package/dist/i18n/index.js +1 -0
- package/dist/icon-button/icon-button-static.d.ts +23 -0
- package/dist/icon-button/icon-button-static.js +83 -0
- package/dist/icon-button/icon-button.client.js +29 -0
- package/dist/icon-button/icon-button.contract.d.ts +89 -0
- package/dist/icon-button/icon-button.d.ts +5 -0
- package/dist/icon-button/icon-button.js +21 -0
- package/dist/icon-button/index.d.ts +4 -0
- package/dist/icon-button/index.js +3 -0
- package/dist/image/image.d.ts +28 -0
- package/dist/image/image.js +24 -0
- package/dist/image/index.d.ts +2 -0
- package/dist/image/index.js +1 -0
- package/dist/index.d.ts +174 -0
- package/dist/index.js +96 -0
- package/dist/inline/index.d.ts +2 -0
- package/dist/inline/index.js +1 -0
- package/dist/inline/inline.d.ts +16 -0
- package/dist/inline/inline.js +14 -0
- package/dist/inline-error/index.d.ts +2 -0
- package/dist/inline-error/index.js +1 -0
- package/dist/inline-error/inline-error.d.ts +17 -0
- package/dist/inline-error/inline-error.js +33 -0
- package/dist/input/index.d.ts +2 -0
- package/dist/input/index.js +1 -0
- package/dist/input/input.client.d.ts +39 -0
- package/dist/input/input.client.js +82 -0
- package/dist/kbd/index.d.ts +2 -0
- package/dist/kbd/index.js +1 -0
- package/dist/kbd/kbd.d.ts +19 -0
- package/dist/kbd/kbd.js +68 -0
- package/dist/kpi-tile/index.d.ts +2 -0
- package/dist/kpi-tile/index.js +1 -0
- package/dist/kpi-tile/kpi-tile.d.ts +30 -0
- package/dist/kpi-tile/kpi-tile.js +48 -0
- package/dist/locales/en-US.d.ts +77 -0
- package/dist/locales/en-US.js +83 -0
- package/dist/menu/index.d.ts +5 -0
- package/dist/menu/index.js +3 -0
- package/dist/menu/menu.client.d.ts +14 -0
- package/dist/menu/menu.client.js +152 -0
- package/dist/menu/menu.contract.d.ts +152 -0
- package/dist/menu/menu.parts.d.ts +6 -0
- package/dist/menu/menu.parts.js +17 -0
- package/dist/meter/index.d.ts +2 -0
- package/dist/meter/index.js +1 -0
- package/dist/meter/meter.d.ts +43 -0
- package/dist/meter/meter.js +59 -0
- package/dist/metric/index.d.ts +2 -0
- package/dist/metric/index.js +1 -0
- package/dist/metric/metric.d.ts +72 -0
- package/dist/metric/metric.js +116 -0
- package/dist/mobile-tab-bar/index.d.ts +4 -0
- package/dist/mobile-tab-bar/index.js +4 -0
- package/dist/mobile-tab-bar/mobile-tab-bar-inset.client.js +38 -0
- package/dist/mobile-tab-bar/mobile-tab-bar-more.client.d.ts +26 -0
- package/dist/mobile-tab-bar/mobile-tab-bar-more.client.js +60 -0
- package/dist/mobile-tab-bar/mobile-tab-bar.d.ts +39 -0
- package/dist/mobile-tab-bar/mobile-tab-bar.js +54 -0
- package/dist/mobile-tab-bar/mobile-tab-bar.parts.d.ts +6 -0
- package/dist/mobile-tab-bar/mobile-tab-bar.parts.js +9 -0
- package/dist/mobile-top-bar/index.d.ts +2 -0
- package/dist/mobile-top-bar/index.js +1 -0
- package/dist/mobile-top-bar/mobile-top-bar.d.ts +17 -0
- package/dist/mobile-top-bar/mobile-top-bar.js +31 -0
- package/dist/motion/count-up.client.d.ts +39 -0
- package/dist/motion/count-up.client.js +109 -0
- package/dist/motion/index.d.ts +2 -0
- package/dist/motion/index.js +1 -0
- package/dist/native-select/index.d.ts +2 -0
- package/dist/native-select/index.js +1 -0
- package/dist/native-select/native-select.d.ts +43 -0
- package/dist/native-select/native-select.js +56 -0
- package/dist/nav-item/index.d.ts +2 -0
- package/dist/nav-item/index.js +1 -0
- package/dist/nav-item/nav-item.d.ts +35 -0
- package/dist/nav-item/nav-item.js +50 -0
- package/dist/number-value/index.d.ts +2 -0
- package/dist/number-value/index.js +1 -0
- package/dist/number-value/number-value.d.ts +25 -0
- package/dist/number-value/number-value.js +26 -0
- package/dist/page-header/index.d.ts +2 -0
- package/dist/page-header/index.js +1 -0
- package/dist/page-header/page-header.d.ts +19 -0
- package/dist/page-header/page-header.js +39 -0
- package/dist/pagination/index.d.ts +2 -0
- package/dist/pagination/index.js +1 -0
- package/dist/pagination/pagination.d.ts +74 -0
- package/dist/pagination/pagination.js +136 -0
- package/dist/password-input/index.d.ts +2 -0
- package/dist/password-input/index.js +1 -0
- package/dist/password-input/password-input.client.d.ts +52 -0
- package/dist/password-input/password-input.client.js +106 -0
- package/dist/popover/index.d.ts +5 -0
- package/dist/popover/index.js +3 -0
- package/dist/popover/popover.client.d.ts +20 -0
- package/dist/popover/popover.client.js +113 -0
- package/dist/popover/popover.contract.d.ts +88 -0
- package/dist/popover/popover.parts.d.ts +6 -0
- package/dist/popover/popover.parts.js +13 -0
- package/dist/progress-bar/index.d.ts +2 -0
- package/dist/progress-bar/index.js +1 -0
- package/dist/progress-bar/progress-bar.d.ts +34 -0
- package/dist/progress-bar/progress-bar.js +55 -0
- package/dist/progress-ring/index.d.ts +2 -0
- package/dist/progress-ring/index.js +1 -0
- package/dist/progress-ring/progress-ring.d.ts +38 -0
- package/dist/progress-ring/progress-ring.js +67 -0
- package/dist/radio-group/index.d.ts +3 -0
- package/dist/radio-group/index.js +3 -0
- package/dist/radio-group/radio-group.client.d.ts +22 -0
- package/dist/radio-group/radio-group.client.js +70 -0
- package/dist/radio-group/radio-group.d.ts +28 -0
- package/dist/radio-group/radio-group.js +35 -0
- package/dist/ranked-list/index.d.ts +3 -0
- package/dist/ranked-list/index.js +3 -0
- package/dist/ranked-list/ranked-list.d.ts +85 -0
- package/dist/ranked-list/ranked-list.js +153 -0
- package/dist/ranked-list/ranked-list.parts.d.ts +6 -0
- package/dist/ranked-list/ranked-list.parts.js +10 -0
- package/dist/search-field/index.d.ts +2 -0
- package/dist/search-field/index.js +1 -0
- package/dist/search-field/search-field.client.d.ts +55 -0
- package/dist/search-field/search-field.client.js +136 -0
- package/dist/segmented-control/index.d.ts +3 -0
- package/dist/segmented-control/index.js +3 -0
- package/dist/segmented-control/segmented-control.client.d.ts +61 -0
- package/dist/segmented-control/segmented-control.client.js +156 -0
- package/dist/segmented-control/segmented-control.parts.d.ts +6 -0
- package/dist/segmented-control/segmented-control.parts.js +9 -0
- package/dist/select/index.d.ts +5 -0
- package/dist/select/index.js +3 -0
- package/dist/select/select.client.d.ts +12 -0
- package/dist/select/select.client.js +152 -0
- package/dist/select/select.contract.d.ts +119 -0
- package/dist/select/select.parts.d.ts +6 -0
- package/dist/select/select.parts.js +15 -0
- package/dist/separator/index.d.ts +2 -0
- package/dist/separator/index.js +1 -0
- package/dist/separator/separator.d.ts +26 -0
- package/dist/separator/separator.js +23 -0
- package/dist/sidebar/index.d.ts +4 -0
- package/dist/sidebar/index.js +4 -0
- package/dist/sidebar/sidebar-item.client.d.ts +10 -0
- package/dist/sidebar/sidebar-item.client.js +55 -0
- package/dist/sidebar/sidebar.d.ts +45 -0
- package/dist/sidebar/sidebar.js +62 -0
- package/dist/sidebar/sidebar.parts.d.ts +6 -0
- package/dist/sidebar/sidebar.parts.js +11 -0
- package/dist/skeleton/index.d.ts +2 -0
- package/dist/skeleton/index.js +1 -0
- package/dist/skeleton/skeleton.d.ts +20 -0
- package/dist/skeleton/skeleton.js +19 -0
- package/dist/split/index.d.ts +3 -0
- package/dist/split/index.js +3 -0
- package/dist/split/split.d.ts +28 -0
- package/dist/split/split.js +33 -0
- package/dist/split/split.parts.d.ts +6 -0
- package/dist/split/split.parts.js +10 -0
- package/dist/stack/index.d.ts +2 -0
- package/dist/stack/index.js +1 -0
- package/dist/stack/stack.d.ts +17 -0
- package/dist/stack/stack.js +14 -0
- package/dist/sticky-bar/index.d.ts +2 -0
- package/dist/sticky-bar/index.js +1 -0
- package/dist/sticky-bar/sticky-bar.d.ts +16 -0
- package/dist/sticky-bar/sticky-bar.js +26 -0
- package/dist/styles.css +595 -0
- package/dist/switch/index.d.ts +2 -0
- package/dist/switch/index.js +1 -0
- package/dist/switch/switch.client.d.ts +33 -0
- package/dist/switch/switch.client.js +63 -0
- package/dist/tab-nav/index.d.ts +3 -0
- package/dist/tab-nav/index.js +3 -0
- package/dist/tab-nav/tab-nav.d.ts +36 -0
- package/dist/tab-nav/tab-nav.js +47 -0
- package/dist/tab-nav/tab-nav.parts.d.ts +6 -0
- package/dist/tab-nav/tab-nav.parts.js +9 -0
- package/dist/table/index.d.ts +3 -0
- package/dist/table/index.js +3 -0
- package/dist/table/table.d.ts +101 -0
- package/dist/table/table.js +121 -0
- package/dist/table/table.parts.d.ts +6 -0
- package/dist/table/table.parts.js +18 -0
- package/dist/table-selection/index.d.ts +3 -0
- package/dist/table-selection/index.js +3 -0
- package/dist/table-selection/table-selection.client.d.ts +14 -0
- package/dist/table-selection/table-selection.client.js +84 -0
- package/dist/table-selection/table-selection.d.ts +34 -0
- package/dist/table-selection/table-selection.js +50 -0
- package/dist/tabs/index.d.ts +4 -0
- package/dist/tabs/index.js +3 -0
- package/dist/tabs/tabs.client.d.ts +8 -0
- package/dist/tabs/tabs.client.js +68 -0
- package/dist/tabs/tabs.contract.d.ts +89 -0
- package/dist/tabs/tabs.parts.d.ts +6 -0
- package/dist/tabs/tabs.parts.js +11 -0
- package/dist/text/index.d.ts +2 -0
- package/dist/text/index.js +1 -0
- package/dist/text/text.d.ts +32 -0
- package/dist/text/text.js +17 -0
- package/dist/textarea/index.d.ts +2 -0
- package/dist/textarea/index.js +1 -0
- package/dist/textarea/textarea.client.d.ts +18 -0
- package/dist/textarea/textarea.client.js +31 -0
- package/dist/theme-script/index.d.ts +2 -0
- package/dist/theme-script/index.js +1 -0
- package/dist/theme-script/theme-script.d.ts +43 -0
- package/dist/theme-script/theme-script.js +46 -0
- package/dist/toast/index.d.ts +4 -0
- package/dist/toast/index.js +3 -0
- package/dist/toast/seam.d.ts +2 -0
- package/dist/toast/store.d.ts +19 -0
- package/dist/toast/store.js +136 -0
- package/dist/toast/toast.contract.d.ts +56 -0
- package/dist/toast/toaster.client.d.ts +10 -0
- package/dist/toast/toaster.client.js +305 -0
- package/dist/tooltip/index.d.ts +5 -0
- package/dist/tooltip/index.js +3 -0
- package/dist/tooltip/tooltip.client.d.ts +12 -0
- package/dist/tooltip/tooltip.client.js +51 -0
- package/dist/tooltip/tooltip.contract.d.ts +60 -0
- package/dist/tooltip/tooltip.parts.d.ts +6 -0
- package/dist/tooltip/tooltip.parts.js +10 -0
- package/dist/top-bar/index.d.ts +2 -0
- package/dist/top-bar/index.js +1 -0
- package/dist/top-bar/top-bar.d.ts +17 -0
- package/dist/top-bar/top-bar.js +35 -0
- package/dist/trend-card/index.d.ts +2 -0
- package/dist/trend-card/index.js +1 -0
- package/dist/trend-card/trend-card.d.ts +34 -0
- package/dist/trend-card/trend-card.js +74 -0
- package/package.json +447 -3
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RenderProp } from "../contracts/render.js";
|
|
2
|
+
import { ComponentPropsWithRef, ReactElement, ReactNode } from "react";
|
|
3
|
+
//#region src/form/form.client.d.ts
|
|
4
|
+
/** One Field's errors: a message, or several (the first is shown), or none. */
|
|
5
|
+
export type FormErrorValue = string | readonly string[] | null | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Errors keyed by the Field's `name`, as a server action returns them (Zod's
|
|
8
|
+
* `z.flattenError(error).fieldErrors`, or Conform's and TanStack Form's issues mapped to text). A
|
|
9
|
+
* nested name is one key, written as the Field's `name` is: `items.0.title`. Serialisable.
|
|
10
|
+
*/
|
|
11
|
+
export type FormErrors = Readonly<Record<string, FormErrorValue>>;
|
|
12
|
+
/** Form's own strings (§16.4): serialisable, English defaults. */
|
|
13
|
+
export interface FormLabels {
|
|
14
|
+
/** The error summary's title. @default 'There is a problem' */
|
|
15
|
+
summaryTitle: string;
|
|
16
|
+
}
|
|
17
|
+
export interface FormProps extends Omit<ComponentPropsWithRef<"form">, "children"> {
|
|
18
|
+
/**
|
|
19
|
+
* Errors by Field `name`, typically a server action's reply. Each one is presented by the Field
|
|
20
|
+
* with that `name` (the Field's own `error` prop wins over it) until the user edits that control.
|
|
21
|
+
* A new object (by identity) presents them all again and moves focus: to the error summary with
|
|
22
|
+
* `summary`, else to the first invalid control. The first render moves no focus.
|
|
23
|
+
*/
|
|
24
|
+
errors?: FormErrors | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Renders an error summary at the start of the form while `errors` presents a message: a title
|
|
27
|
+
* and one link per error to its control, in page order. New errors focus the summary instead of
|
|
28
|
+
* the first invalid control (GOV.UK's error summary). For long forms. @default false
|
|
29
|
+
*/
|
|
30
|
+
summary?: boolean;
|
|
31
|
+
/** Overrides Form's strings, for example `labels={{ summaryTitle: 'Es gibt ein Problem' }}`. */
|
|
32
|
+
labels?: Partial<FormLabels>;
|
|
33
|
+
/** Composition of the `<form>`. */
|
|
34
|
+
render?: RenderProp<Record<string, never>>;
|
|
35
|
+
children?: ReactNode;
|
|
36
|
+
}
|
|
37
|
+
export declare function Form({ errors, summary, labels: labelsProp, render, className, children, ...rest }: FormProps): ReactElement;
|
|
38
|
+
//#endregion
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cx } from "../_internal/cx.js";
|
|
3
|
+
import { mergeProps } from "../contracts/merge-props.js";
|
|
4
|
+
import { renderElement } from "../contracts/render.js";
|
|
5
|
+
import { Alert } from "../alert/alert.js";
|
|
6
|
+
import { useLabels } from "../config/config.client.js";
|
|
7
|
+
import { FormScope } from "../field/field-scope.client.js";
|
|
8
|
+
import { useEffectEvent, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
//#region src/form/form.client.tsx
|
|
11
|
+
const NONE = /* @__PURE__ */ new Set();
|
|
12
|
+
function Form({ errors, summary = false, labels: labelsProp, render, className, children, ...rest }) {
|
|
13
|
+
const labels = useLabels("form", labelsProp);
|
|
14
|
+
const [edited, setEdited] = useState({
|
|
15
|
+
for: errors,
|
|
16
|
+
names: NONE
|
|
17
|
+
});
|
|
18
|
+
const hidden = edited.for === errors ? edited.names : NONE;
|
|
19
|
+
const shown = useMemo(() => {
|
|
20
|
+
const out = /* @__PURE__ */ new Map();
|
|
21
|
+
for (const [name, value] of Object.entries(errors ?? {})) {
|
|
22
|
+
const message = typeof value === "string" ? value : value?.[0];
|
|
23
|
+
if (message !== void 0 && message !== "" && !hidden.has(name)) out.set(name, message);
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}, [errors, hidden]);
|
|
27
|
+
const form = useRef(null);
|
|
28
|
+
const summaryRef = useRef(null);
|
|
29
|
+
const listed = summary && shown.size > 0;
|
|
30
|
+
const [placed, setPlaced] = useState([]);
|
|
31
|
+
useLayoutEffect(() => {
|
|
32
|
+
const element = form.current;
|
|
33
|
+
if (!listed || element === null) return;
|
|
34
|
+
const next = [...shown.keys()].map((name) => [name, controlOf(element, name)]).toSorted(([, a], [, b]) => order(a, b)).map(([name, control]) => [name, control?.id || void 0]);
|
|
35
|
+
setPlaced((previous) => same(previous, next) ? previous : next);
|
|
36
|
+
}, [listed, shown]);
|
|
37
|
+
const seen = useRef(errors);
|
|
38
|
+
const moveFocus = useEffectEvent(() => {
|
|
39
|
+
const element = form.current;
|
|
40
|
+
if (element === null || shown.size === 0) return;
|
|
41
|
+
(summaryRef.current ?? firstInvalid(element))?.focus();
|
|
42
|
+
});
|
|
43
|
+
useLayoutEffect(() => {
|
|
44
|
+
if (seen.current === errors) return;
|
|
45
|
+
seen.current = errors;
|
|
46
|
+
moveFocus();
|
|
47
|
+
}, [errors]);
|
|
48
|
+
const own = {
|
|
49
|
+
"data-slot": "form",
|
|
50
|
+
className: cx("nz-form", className),
|
|
51
|
+
ref: form,
|
|
52
|
+
onInput(event) {
|
|
53
|
+
const { target } = event;
|
|
54
|
+
const name = "name" in target ? target.name : void 0;
|
|
55
|
+
if (typeof name === "string" && shown.has(name)) setEdited({
|
|
56
|
+
for: errors,
|
|
57
|
+
names: /* @__PURE__ */ new Set([...hidden, name])
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const rank = new Map(placed.map(([name], index) => [name, index]));
|
|
62
|
+
const ids = new Map(placed);
|
|
63
|
+
const items = [...shown].toSorted(([a], [b]) => (rank.get(a) ?? rank.size) - (rank.get(b) ?? rank.size));
|
|
64
|
+
const props = {
|
|
65
|
+
...mergeProps(own, rest),
|
|
66
|
+
children: /* @__PURE__ */ jsxs(Fragment, { children: [listed && /* @__PURE__ */ jsx("div", {
|
|
67
|
+
ref: summaryRef,
|
|
68
|
+
tabIndex: -1,
|
|
69
|
+
className: "nz-form-summary",
|
|
70
|
+
"data-slot": "form-summary",
|
|
71
|
+
children: /* @__PURE__ */ jsx(Alert, {
|
|
72
|
+
tone: "critical",
|
|
73
|
+
role: "alert",
|
|
74
|
+
title: labels?.summaryTitle ?? "There is a problem",
|
|
75
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
76
|
+
className: "nz-form-summary-list",
|
|
77
|
+
"data-slot": "form-summary-list",
|
|
78
|
+
children: items.map(([name, message]) => {
|
|
79
|
+
const id = ids.get(name);
|
|
80
|
+
return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx("a", {
|
|
81
|
+
href: id === void 0 ? void 0 : `#${id}`,
|
|
82
|
+
className: "nz-form-summary-link",
|
|
83
|
+
"data-slot": "form-summary-link",
|
|
84
|
+
onClick: (event) => focusControl(event, name),
|
|
85
|
+
children: message
|
|
86
|
+
}) }, name);
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
})
|
|
90
|
+
}), children] })
|
|
91
|
+
};
|
|
92
|
+
return /* @__PURE__ */ jsx(FormScope, {
|
|
93
|
+
value: shown,
|
|
94
|
+
children: renderElement("form", render, {}, props)
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
/** The control a Field `name` names: the first of a radio group. */
|
|
98
|
+
function controlOf(form, name) {
|
|
99
|
+
const item = form.elements.namedItem(name);
|
|
100
|
+
const element = item instanceof RadioNodeList ? item[0] : item;
|
|
101
|
+
return element instanceof HTMLElement ? element : void 0;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The form's first control that presents an error (`aria-invalid="true"`), in tree order: through
|
|
105
|
+
* the error prop, a Form error or a native message. Not a disabled one, nor an unfocusable root.
|
|
106
|
+
*/
|
|
107
|
+
function firstInvalid(form) {
|
|
108
|
+
for (const element of form.querySelectorAll("[aria-invalid=\"true\"]")) if (element.tabIndex >= 0 && !element.matches(":disabled")) return element;
|
|
109
|
+
}
|
|
110
|
+
/** A summary link focuses its control, which scrolls it into view, and leaves the URL as it is. */
|
|
111
|
+
function focusControl(event, name) {
|
|
112
|
+
const form = event.currentTarget.closest("form");
|
|
113
|
+
const control = form === null ? void 0 : controlOf(form, name);
|
|
114
|
+
if (control === void 0) return;
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
control.focus();
|
|
117
|
+
}
|
|
118
|
+
/** Two controls in page order; a missing one comes last. */
|
|
119
|
+
function order(a, b) {
|
|
120
|
+
if (a === void 0 || b === void 0) return a === b ? 0 : a === void 0 ? 1 : -1;
|
|
121
|
+
return a.compareDocumentPosition(b) & Node.DOCUMENT_POSITION_FOLLOWING ? -1 : 1;
|
|
122
|
+
}
|
|
123
|
+
function same(a, b) {
|
|
124
|
+
return a.length === b.length && a.every(([name, id], i) => b[i]?.[0] === name && b[i]?.[1] === id);
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { Form };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { RenderProp } from "../contracts/render.js";
|
|
2
|
+
import { AlertTone } from "../alert/alert.js";
|
|
3
|
+
import { ComponentPropsWithRef, ReactElement, ReactNode } from "react";
|
|
4
|
+
//#region src/form/form.d.ts
|
|
5
|
+
/** Alert's tones. `critical` is a `role="alert"` container; the others are `role="status"`. */
|
|
6
|
+
export type FormMessageTone = AlertTone;
|
|
7
|
+
export interface FormMessageState {
|
|
8
|
+
tone: FormMessageTone;
|
|
9
|
+
}
|
|
10
|
+
export interface FormMessageProps extends Omit<ComponentPropsWithRef<"div">, "title" | "role"> {
|
|
11
|
+
/**
|
|
12
|
+
* `critical` for a failure the user must act on (network, permission, conflict): `role="alert"`.
|
|
13
|
+
* `success`, `info` and `warning` are `role="status"`, read when the reader is idle.
|
|
14
|
+
* @default 'critical'
|
|
15
|
+
*/
|
|
16
|
+
tone?: FormMessageTone;
|
|
17
|
+
/** One line above the message, as Alert's `title`. */
|
|
18
|
+
title?: ReactNode;
|
|
19
|
+
/** Decorative tone glyph, as Alert's `icon`; the text carries the meaning. */
|
|
20
|
+
icon?: ReactNode;
|
|
21
|
+
/** A control under the message, for example `<Button size="sm">Retry</Button>`. */
|
|
22
|
+
action?: ReactNode;
|
|
23
|
+
/** Composition of the live container. */
|
|
24
|
+
render?: RenderProp<FormMessageState>;
|
|
25
|
+
/**
|
|
26
|
+
* The message. `null`, `false` and `''` render nothing inside the container, which stays in the
|
|
27
|
+
* page so the next message is announced: render FormMessage always, and change only this.
|
|
28
|
+
*/
|
|
29
|
+
children?: ReactNode;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The form-level message: a live container that is always rendered, with an Alert inside it while
|
|
33
|
+
* there is a message. Field errors belong to each Field (`error`, or Form's `errors`), not here.
|
|
34
|
+
*/
|
|
35
|
+
export declare function FormMessage({ tone, title, icon, action, render, className, children, ...rest }: FormMessageProps): ReactElement;
|
|
36
|
+
//#endregion
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { cx } from "../_internal/cx.js";
|
|
2
|
+
import { renderElement } from "../contracts/render.js";
|
|
3
|
+
import { Alert } from "../alert/alert.js";
|
|
4
|
+
import { presented } from "../_internal/field.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/form/form.tsx
|
|
7
|
+
/**
|
|
8
|
+
* The form-level message: a live container that is always rendered, with an Alert inside it while
|
|
9
|
+
* there is a message. Field errors belong to each Field (`error`, or Form's `errors`), not here.
|
|
10
|
+
*/
|
|
11
|
+
function FormMessage({ tone = "critical", title, icon, action, render, className, children, ...rest }) {
|
|
12
|
+
const shown = presented(children) || presented(title);
|
|
13
|
+
return renderElement("div", render, { tone }, {
|
|
14
|
+
"data-slot": "form-message",
|
|
15
|
+
"data-tone": tone,
|
|
16
|
+
...rest,
|
|
17
|
+
className: cx("nz-form-message", className),
|
|
18
|
+
role: tone === "critical" ? "alert" : "status",
|
|
19
|
+
children: shown ? /* @__PURE__ */ jsx(Alert, {
|
|
20
|
+
tone,
|
|
21
|
+
title,
|
|
22
|
+
icon,
|
|
23
|
+
action,
|
|
24
|
+
children
|
|
25
|
+
}) : void 0
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { FormMessage };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Form, FormErrorValue, FormErrors, FormLabels, FormProps } from "./form.client.js";
|
|
2
|
+
import { SubmitButton, SubmitButtonProps } from "./submit-button.client.js";
|
|
3
|
+
import { FormMessage, FormMessageProps, FormMessageState, FormMessageTone } from "./form.js";
|
|
4
|
+
export { Form, type FormErrorValue, type FormErrors, type FormLabels, FormMessage, type FormMessageProps, type FormMessageState, type FormMessageTone, type FormProps, SubmitButton, type SubmitButtonProps };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ButtonVariant } from "../augment.js";
|
|
2
|
+
import { ButtonProps } from "../button/button.js";
|
|
3
|
+
import { ReactElement } from "react";
|
|
4
|
+
//#region src/form/submit-button.client.d.ts
|
|
5
|
+
export interface SubmitButtonProps extends Omit<ButtonProps, "type"> {
|
|
6
|
+
/**
|
|
7
|
+
* The form's main action, so `primary`; Button's other variants are accepted.
|
|
8
|
+
* @default 'primary'
|
|
9
|
+
*/
|
|
10
|
+
variant?: ButtonVariant;
|
|
11
|
+
/**
|
|
12
|
+
* Pending even when the form's action is not running, for example while a client handler awaits.
|
|
13
|
+
* The form's own status is read for you: only an action passed as a function (`<form action={fn}>`
|
|
14
|
+
* or Form's) reports one, never a URL.
|
|
15
|
+
* @default false
|
|
16
|
+
*/
|
|
17
|
+
pending?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export declare function SubmitButton({ variant, pending, labels: labelsProp, ...rest }: SubmitButtonProps): ReactElement;
|
|
20
|
+
//#endregion
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useLabels } from "../config/config.client.js";
|
|
3
|
+
import { Button } from "../button/button.js";
|
|
4
|
+
import { jsx } from "react/jsx-runtime";
|
|
5
|
+
import { useFormStatus } from "react-dom";
|
|
6
|
+
//#region src/form/submit-button.client.tsx
|
|
7
|
+
function SubmitButton({ variant = "primary", pending = false, labels: labelsProp, ...rest }) {
|
|
8
|
+
const status = useFormStatus();
|
|
9
|
+
const labels = useLabels("button", labelsProp);
|
|
10
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
11
|
+
...rest,
|
|
12
|
+
...labels === void 0 ? {} : { labels },
|
|
13
|
+
variant,
|
|
14
|
+
type: "submit",
|
|
15
|
+
pending: pending || status.pending
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { SubmitButton };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { RenderProp } from "../contracts/render.js";
|
|
2
|
+
import { LayoutGap } from "../stack/stack.js";
|
|
3
|
+
import { ComponentPropsWithRef, ReactElement } from "react";
|
|
4
|
+
//#region src/grid/grid.d.ts
|
|
5
|
+
/** Columns an item spans, or `'full'` for the whole row. Clamped to the columns available. */
|
|
6
|
+
export type GridSpan = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | "full";
|
|
7
|
+
/**
|
|
8
|
+
* A span per breakpoint: `base` is mobile first, `sm` applies from 40rem (`--nz-sm`) and `lg` from
|
|
9
|
+
* 80rem (`--nz-lg`, provisional). An absent breakpoint keeps the one below it.
|
|
10
|
+
*/
|
|
11
|
+
export interface GridResponsiveSpan {
|
|
12
|
+
base?: GridSpan;
|
|
13
|
+
sm?: GridSpan;
|
|
14
|
+
lg?: GridSpan;
|
|
15
|
+
}
|
|
16
|
+
export interface GridState {
|
|
17
|
+
gap: LayoutGap | undefined;
|
|
18
|
+
}
|
|
19
|
+
export interface GridProps extends ComponentPropsWithRef<"div"> {
|
|
20
|
+
/**
|
|
21
|
+
* Space between tracks, as a `--nz-space-*` key. Absent, the responsive gutter
|
|
22
|
+
* (`--nz-grid-gutter`: 16, 20, 24 px).
|
|
23
|
+
*/
|
|
24
|
+
gap?: LayoutGap;
|
|
25
|
+
render?: RenderProp<GridState>;
|
|
26
|
+
}
|
|
27
|
+
export interface GridItemState {
|
|
28
|
+
span: GridSpan | GridResponsiveSpan | undefined;
|
|
29
|
+
}
|
|
30
|
+
export interface GridItemProps extends ComponentPropsWithRef<"div"> {
|
|
31
|
+
/** @default 1 */
|
|
32
|
+
span?: GridSpan | GridResponsiveSpan;
|
|
33
|
+
render?: RenderProp<GridItemState>;
|
|
34
|
+
}
|
|
35
|
+
/** The page grid: `--nz-grid-columns` columns (4, 8, 12 by viewport). Items snap to spans. */
|
|
36
|
+
export declare function Grid({ gap, render, className, ...rest }: GridProps): ReactElement;
|
|
37
|
+
export declare function GridItem({ span, render, className, ...rest }: GridItemProps): ReactElement;
|
|
38
|
+
//#endregion
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { cx } from "../_internal/cx.js";
|
|
2
|
+
import { renderElement } from "../contracts/render.js";
|
|
3
|
+
//#region src/grid/grid.tsx
|
|
4
|
+
/** The page grid: `--nz-grid-columns` columns (4, 8, 12 by viewport). Items snap to spans. */
|
|
5
|
+
function Grid({ gap, render, className, ...rest }) {
|
|
6
|
+
return renderElement("div", render, { gap }, {
|
|
7
|
+
"data-slot": "grid",
|
|
8
|
+
"data-gap": gap,
|
|
9
|
+
...rest,
|
|
10
|
+
className: cx("nz-grid", className)
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
function GridItem({ span, render, className, ...rest }) {
|
|
14
|
+
const spans = typeof span === "object" ? span : span === void 0 ? {} : { base: span };
|
|
15
|
+
return renderElement("div", render, { span }, {
|
|
16
|
+
"data-slot": "grid-item",
|
|
17
|
+
"data-span": attr(spans.base),
|
|
18
|
+
"data-span-sm": attr(spans.sm),
|
|
19
|
+
"data-span-lg": attr(spans.lg),
|
|
20
|
+
...rest,
|
|
21
|
+
className: cx("nz-grid-item", className)
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
function attr(span) {
|
|
25
|
+
return span === void 0 ? void 0 : String(span);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { Grid, GridItem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Grid, GridItem } from "./grid.js";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { RenderProp } from "../contracts/render.js";
|
|
2
|
+
import { TextTone } from "../text/text.js";
|
|
3
|
+
import { ComponentPropsWithRef, ReactElement } from "react";
|
|
4
|
+
//#region src/heading/heading.d.ts
|
|
5
|
+
/** The document outline level: `<h1>` to `<h6>`. */
|
|
6
|
+
export type HeadingLevel = 1 | 2 | 3 | 4 | 5 | 6;
|
|
7
|
+
/** The Figma display and heading text styles. */
|
|
8
|
+
export type HeadingVariant = "display-l" | "display-m" | "heading-h1" | "heading-h2" | "heading-h3" | "heading-h4";
|
|
9
|
+
export interface HeadingState {
|
|
10
|
+
level: HeadingLevel;
|
|
11
|
+
variant: HeadingVariant;
|
|
12
|
+
tone: TextTone | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface HeadingProps extends ComponentPropsWithRef<"h2"> {
|
|
15
|
+
/** Required: the outline level decides the element, never the look. */
|
|
16
|
+
level: HeadingLevel;
|
|
17
|
+
/**
|
|
18
|
+
* The text style, independent of `level` (a page title can be an `<h1>` drawn as Heading/H3).
|
|
19
|
+
* @default the style named after the level, and `heading-h4` for levels 5 and 6 (Figma has no H5 or H6)
|
|
20
|
+
*/
|
|
21
|
+
variant?: HeadingVariant;
|
|
22
|
+
/**
|
|
23
|
+
* A `text/*` colour. Absent, the colour is inherited from the surface. Deprecated value:
|
|
24
|
+
* `'accent'`, which paints `--nz-text-brand`; use `'brand'` (M42; removal deferred to 1.0).
|
|
25
|
+
*/
|
|
26
|
+
tone?: TextTone;
|
|
27
|
+
render?: RenderProp<HeadingState>;
|
|
28
|
+
}
|
|
29
|
+
export declare function Heading({ level, variant, tone, render, className, ...rest }: HeadingProps): ReactElement;
|
|
30
|
+
//#endregion
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { cx } from "../_internal/cx.js";
|
|
2
|
+
import { renderElement } from "../contracts/render.js";
|
|
3
|
+
//#region src/heading/heading.tsx
|
|
4
|
+
const VARIANT_OF_LEVEL = {
|
|
5
|
+
1: "heading-h1",
|
|
6
|
+
2: "heading-h2",
|
|
7
|
+
3: "heading-h3",
|
|
8
|
+
4: "heading-h4",
|
|
9
|
+
5: "heading-h4",
|
|
10
|
+
6: "heading-h4"
|
|
11
|
+
};
|
|
12
|
+
function Heading({ level, variant = VARIANT_OF_LEVEL[level], tone, render, className, ...rest }) {
|
|
13
|
+
return renderElement(`h${level}`, render, {
|
|
14
|
+
level,
|
|
15
|
+
variant,
|
|
16
|
+
tone
|
|
17
|
+
}, {
|
|
18
|
+
"data-slot": "heading",
|
|
19
|
+
"data-variant": variant,
|
|
20
|
+
"data-tone": tone,
|
|
21
|
+
...rest,
|
|
22
|
+
className: cx("nz-heading", className)
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
//#endregion
|
|
26
|
+
export { Heading };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Heading } from "./heading.js";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/i18n/format-label.d.ts
|
|
2
|
+
/** The CLDR plural categories `Intl.PluralRules` can select. */
|
|
3
|
+
export type PluralCategory = "zero" | "one" | "two" | "few" | "many" | "other";
|
|
4
|
+
/**
|
|
5
|
+
* A label with one template per CLDR plural category of its locale, `other` required. A locale
|
|
6
|
+
* lists exactly the categories `Intl.PluralRules` has for it (en-US: `one`, `other`; pl: `one`,
|
|
7
|
+
* `few`, `many`, `other`). Exact-number keys (`'=0'`) are not supported.
|
|
8
|
+
*/
|
|
9
|
+
export type PluralLabel = {
|
|
10
|
+
other: string;
|
|
11
|
+
} & Partial<Record<Exclude<PluralCategory, "other">, string>>;
|
|
12
|
+
/** The values a label's placeholders read: `{count}` reads `count`. */
|
|
13
|
+
export type LabelValues = Readonly<Record<string, string | number>>;
|
|
14
|
+
/**
|
|
15
|
+
* Fills a label. A `PluralLabel` picks its template by `values.count`, through
|
|
16
|
+
* `new Intl.PluralRules(locale).select(values.count)` (`other` when the category is missing or
|
|
17
|
+
* `count` is not a number); a plain string is used as is. Each `{name}` placeholder is replaced by
|
|
18
|
+
* `values.name`: a number formatted with `Intl.NumberFormat(locale)`, a string as written. A
|
|
19
|
+
* placeholder with no value stays as written: `formatLabel('+{count}', { count: 1200 })` is
|
|
20
|
+
* `'+1,200'`.
|
|
21
|
+
* @param locale BCP 47 tag for the plural rules and the numbers. @default 'en-US'
|
|
22
|
+
*/
|
|
23
|
+
export declare function formatLabel(template: string | PluralLabel, values?: LabelValues, locale?: string): string;
|
|
24
|
+
//#endregion
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
//#region src/i18n/format-label.ts
|
|
2
|
+
/**
|
|
3
|
+
* Fills a label. A `PluralLabel` picks its template by `values.count`, through
|
|
4
|
+
* `new Intl.PluralRules(locale).select(values.count)` (`other` when the category is missing or
|
|
5
|
+
* `count` is not a number); a plain string is used as is. Each `{name}` placeholder is replaced by
|
|
6
|
+
* `values.name`: a number formatted with `Intl.NumberFormat(locale)`, a string as written. A
|
|
7
|
+
* placeholder with no value stays as written: `formatLabel('+{count}', { count: 1200 })` is
|
|
8
|
+
* `'+1,200'`.
|
|
9
|
+
* @param locale BCP 47 tag for the plural rules and the numbers. @default 'en-US'
|
|
10
|
+
*/
|
|
11
|
+
function formatLabel(template, values = {}, locale = "en-US") {
|
|
12
|
+
const { count } = values;
|
|
13
|
+
return (typeof template === "string" ? template : (typeof count === "number" ? template[new Intl.PluralRules(locale).select(count)] : void 0) ?? template.other).replace(/\{(\w+)\}/g, (placeholder, name) => {
|
|
14
|
+
const value = Object.hasOwn(values, name) ? values[name] : void 0;
|
|
15
|
+
return typeof value === "number" ? new Intl.NumberFormat(locale).format(value) : value ?? placeholder;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { formatLabel };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { formatLabel } from "./format-label.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { IconButtonStaticProps } from "./icon-button.contract.js";
|
|
2
|
+
import { ReactElement } from "react";
|
|
3
|
+
//#region src/icon-button/icon-button-static.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* A server-safe IconButton with no tooltip: the same `<button>`, classes and CSS as
|
|
6
|
+
* `<IconButton tooltip={false}>`, from a module that imports no client code.
|
|
7
|
+
*
|
|
8
|
+
* Use it only where visible text already names the action for sighted users (a column header, a
|
|
9
|
+
* labelled row) and the page should ship no JavaScript for the button: a table row action that is a
|
|
10
|
+
* link (`render={<a href="/orders/42/edit" />}`) under a header that says what it does, a submit
|
|
11
|
+
* button in a Server Action form (`type="submit"` inside `<form action={deleteProduct}>`) beside its
|
|
12
|
+
* label. Under Turbopack and `next dev`, importing `IconButton` ships its tooltip code even with
|
|
13
|
+
* `tooltip={false}` (about 20 KB gzip in production); `IconButtonStatic` ships none.
|
|
14
|
+
*
|
|
15
|
+
* An icon-only toolbar needs `IconButton`'s tooltip, so a sighted user can read what each glyph does
|
|
16
|
+
* (Figma: "Icon-only buttons have an aria-label and a Tooltip").
|
|
17
|
+
*
|
|
18
|
+
* `aria-label` is always required. You may also pass `aria-labelledby` pointing at visible text; it
|
|
19
|
+
* then names the button, with `aria-label` as the fallback. There is no `tooltip`, no `shortcut`
|
|
20
|
+
* (pass `aria-keyshortcuts` yourself, for example `"Meta+B Control+B"`) and no `label`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function IconButtonStatic({ "aria-label": ariaLabel, label: _label, tooltip: _tooltip, shortcut: _shortcut, ...props }: IconButtonStaticProps): ReactElement;
|
|
23
|
+
//#endregion
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { cx } from "../_internal/cx.js";
|
|
2
|
+
import { mergeProps } from "../contracts/merge-props.js";
|
|
3
|
+
import { renderElement } from "../contracts/render.js";
|
|
4
|
+
import { SpinnerGlyph } from "../_internal/glyphs.js";
|
|
5
|
+
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
//#region src/icon-button/icon-button-static.tsx
|
|
7
|
+
/**
|
|
8
|
+
* A server-safe IconButton with no tooltip: the same `<button>`, classes and CSS as
|
|
9
|
+
* `<IconButton tooltip={false}>`, from a module that imports no client code.
|
|
10
|
+
*
|
|
11
|
+
* Use it only where visible text already names the action for sighted users (a column header, a
|
|
12
|
+
* labelled row) and the page should ship no JavaScript for the button: a table row action that is a
|
|
13
|
+
* link (`render={<a href="/orders/42/edit" />}`) under a header that says what it does, a submit
|
|
14
|
+
* button in a Server Action form (`type="submit"` inside `<form action={deleteProduct}>`) beside its
|
|
15
|
+
* label. Under Turbopack and `next dev`, importing `IconButton` ships its tooltip code even with
|
|
16
|
+
* `tooltip={false}` (about 20 KB gzip in production); `IconButtonStatic` ships none.
|
|
17
|
+
*
|
|
18
|
+
* An icon-only toolbar needs `IconButton`'s tooltip, so a sighted user can read what each glyph does
|
|
19
|
+
* (Figma: "Icon-only buttons have an aria-label and a Tooltip").
|
|
20
|
+
*
|
|
21
|
+
* `aria-label` is always required. You may also pass `aria-labelledby` pointing at visible text; it
|
|
22
|
+
* then names the button, with `aria-label` as the fallback. There is no `tooltip`, no `shortcut`
|
|
23
|
+
* (pass `aria-keyshortcuts` yourself, for example `"Meta+B Control+B"`) and no `label`.
|
|
24
|
+
*/
|
|
25
|
+
function IconButtonStatic({ "aria-label": ariaLabel, label: _label, tooltip: _tooltip, shortcut: _shortcut, ...props }) {
|
|
26
|
+
warnUnnamed(ariaLabel, props["aria-labelledby"], "IconButtonStatic", "aria-label");
|
|
27
|
+
return iconButtonElement({
|
|
28
|
+
...props,
|
|
29
|
+
label: ariaLabel
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Renders the button. `trigger` holds the Tooltip trigger's props (handlers and ref) on IconButton's
|
|
34
|
+
* client path; the consumer's handlers run before them, as everywhere (§8.2).
|
|
35
|
+
*/
|
|
36
|
+
function iconButtonElement({ label, icon, variant = "secondary", size = "md", pressed, pending = false, pendingIndicator, disabled = false, type, render, className, ...rest }, trigger) {
|
|
37
|
+
const native = render === void 0;
|
|
38
|
+
const props = trigger === void 0 ? rest : mergeProps(trigger, rest);
|
|
39
|
+
return renderElement("button", render, {
|
|
40
|
+
variant,
|
|
41
|
+
size,
|
|
42
|
+
pending,
|
|
43
|
+
disabled,
|
|
44
|
+
pressed
|
|
45
|
+
}, {
|
|
46
|
+
"data-slot": "icon-button",
|
|
47
|
+
"data-variant": variant,
|
|
48
|
+
"data-size": size,
|
|
49
|
+
"data-pending": pending ? "" : void 0,
|
|
50
|
+
"data-disabled": disabled ? "" : void 0,
|
|
51
|
+
...props,
|
|
52
|
+
className: cx("nz-icon-button nz-hit-target", className),
|
|
53
|
+
type: native ? pending ? "button" : type ?? "button" : void 0,
|
|
54
|
+
disabled: native && disabled && !pending ? true : void 0,
|
|
55
|
+
"aria-label": label,
|
|
56
|
+
"aria-pressed": pressed,
|
|
57
|
+
"aria-disabled": pending || !native && disabled ? true : void 0,
|
|
58
|
+
onClick: pending && props["onClick"] !== void 0 ? swallow : props["onClick"],
|
|
59
|
+
children: /* @__PURE__ */ jsx("span", {
|
|
60
|
+
className: "nz-icon-button-icon",
|
|
61
|
+
"data-slot": "icon-button-icon",
|
|
62
|
+
"aria-hidden": "true",
|
|
63
|
+
children: pending ? pendingIndicator ?? /* @__PURE__ */ jsx(SpinnerGlyph, {}) : icon
|
|
64
|
+
})
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
function swallow(event) {
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Development builds warn about a button nothing names; bundlers strip it from production. `prop` is
|
|
72
|
+
* the prop that names it (`label` on IconButton, `aria-label` on IconButtonStatic).
|
|
73
|
+
*/
|
|
74
|
+
function warnUnnamed(name, labelledBy, component = "IconButton", prop = "label") {
|
|
75
|
+
if ((name ?? "").trim() !== "" || (labelledBy ?? "").trim() !== "") return;
|
|
76
|
+
let development = false;
|
|
77
|
+
try {
|
|
78
|
+
development = process.env.NODE_ENV !== "production";
|
|
79
|
+
} catch {}
|
|
80
|
+
if (development) console.warn(`Nizivo ${component}: \`${prop}\` is empty, so the button has no accessible name. Pass the action in words, for example ${prop}="Delete product".`);
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { IconButtonStatic, iconButtonElement, warnUnnamed };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { iconButtonElement } from "./icon-button-static.js";
|
|
3
|
+
import { TooltipPopup, TooltipRoot, TooltipTrigger } from "../tooltip/tooltip.client.js";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/icon-button/icon-button.client.tsx
|
|
6
|
+
function IconButtonTooltip({ tooltip: { side, align, delay }, shortcut, ...button }) {
|
|
7
|
+
return /* @__PURE__ */ jsxs(TooltipRoot, {
|
|
8
|
+
disabled: button.disabled === true,
|
|
9
|
+
...delay === void 0 ? {} : { delay },
|
|
10
|
+
children: [/* @__PURE__ */ jsx(TooltipTrigger, { render: (props) => iconButtonElement(button, triggerProps(props)) }), /* @__PURE__ */ jsx(TooltipPopup, {
|
|
11
|
+
...side === void 0 ? {} : { side },
|
|
12
|
+
...align === void 0 ? {} : { align },
|
|
13
|
+
...shortcut === void 0 ? {} : { shortcut },
|
|
14
|
+
children: button.label
|
|
15
|
+
})]
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Keeps the trigger's handlers and ref. Drops what would make the DOM differ from the server path:
|
|
20
|
+
* `nz-tooltip-trigger`, its slot, `data-open` and the `tabIndex` that makes any element focusable (a
|
|
21
|
+
* button or link already is; a consumer's own `tabIndex` still applies). Drops `aria-describedby` too:
|
|
22
|
+
* the tooltip repeats the accessible name, so describing the button by it would say the label twice.
|
|
23
|
+
*/
|
|
24
|
+
function triggerProps(props) {
|
|
25
|
+
const { className: _class, "data-slot": _slot, "data-open": _open, "aria-describedby": _described, type: _type, tabIndex: _tabIndex, ...kept } = props;
|
|
26
|
+
return kept;
|
|
27
|
+
}
|
|
28
|
+
//#endregion
|
|
29
|
+
export { IconButtonTooltip };
|