@igne-agency/react-web-ui 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +200 -2
- package/dist/assets/spinner.js +28 -0
- package/dist/base.css +171 -0
- package/dist/components/accordion/accordion.css +93 -0
- package/dist/components/accordion/accordion.d.ts +46 -0
- package/dist/components/accordion/accordion.js +184 -0
- package/dist/components/accordion/accordion.module.js +16 -0
- package/dist/components/accordion/index.d.ts +1 -0
- package/dist/components/accordion/index.js +1 -0
- package/dist/components/active-filters/active-filter-describers.d.ts +62 -0
- package/dist/components/active-filters/active-filter-describers.js +48 -0
- package/dist/components/active-filters/active-filters.d.ts +27 -0
- package/dist/components/active-filters/active-filters.js +96 -0
- package/dist/components/active-filters/index.d.ts +2 -0
- package/dist/components/active-filters/index.js +3 -0
- package/dist/components/attachment-tile/attachment-preview.d.ts +33 -0
- package/dist/components/attachment-tile/attachment-preview.js +181 -0
- package/dist/components/attachment-tile/attachment-tile.css +92 -0
- package/dist/components/attachment-tile/attachment-tile.d.ts +51 -0
- package/dist/components/attachment-tile/attachment-tile.js +126 -0
- package/dist/components/attachment-tile/attachment-tile.module.js +20 -0
- package/dist/components/attachment-tile/index.d.ts +2 -0
- package/dist/components/attachment-tile/index.js +3 -0
- package/dist/components/avatar/avatar.css +48 -0
- package/dist/components/avatar/avatar.d.ts +19 -0
- package/dist/components/avatar/avatar.js +98 -0
- package/dist/components/avatar/avatar.module.js +10 -0
- package/dist/components/avatar/index.d.ts +1 -0
- package/dist/components/avatar/index.js +1 -0
- package/dist/components/avatar-group/avatar-group-context.d.ts +15 -0
- package/dist/components/avatar-group/avatar-group-context.js +14 -0
- package/dist/components/avatar-group/avatar-group.css +62 -0
- package/dist/components/avatar-group/avatar-group.d.ts +96 -0
- package/dist/components/avatar-group/avatar-group.js +519 -0
- package/dist/components/avatar-group/avatar-group.module.js +20 -0
- package/dist/components/avatar-group/index.d.ts +1 -0
- package/dist/components/avatar-group/index.js +1 -0
- package/dist/components/badge/badge.css +101 -0
- package/dist/components/badge/badge.d.ts +17 -0
- package/dist/components/badge/badge.js +61 -0
- package/dist/components/badge/badge.module.js +4 -0
- package/dist/components/badge/index.d.ts +1 -0
- package/dist/components/badge/index.js +1 -0
- package/dist/components/breadcrumbs/breadcrumbs.css +57 -0
- package/dist/components/breadcrumbs/breadcrumbs.d.ts +105 -0
- package/dist/components/breadcrumbs/breadcrumbs.js +710 -0
- package/dist/components/breadcrumbs/breadcrumbs.module.js +20 -0
- package/dist/components/breadcrumbs/index.d.ts +2 -0
- package/dist/components/breadcrumbs/index.js +3 -0
- package/dist/components/breadcrumbs/use-fold.d.ts +34 -0
- package/dist/components/breadcrumbs/use-fold.js +73 -0
- package/dist/components/button/button-attributes.d.ts +23 -0
- package/dist/components/button/button-attributes.js +17 -0
- package/dist/components/button/button.css +111 -0
- package/dist/components/button/button.d.ts +47 -0
- package/dist/components/button/button.js +210 -0
- package/dist/components/button/button.module.js +4 -0
- package/dist/components/button/close-button.d.ts +14 -0
- package/dist/components/button/close-button.js +30 -0
- package/dist/components/button/index.d.ts +1 -0
- package/dist/components/button/index.js +1 -0
- package/dist/components/checkbox-field/checkbox-field.d.ts +21 -0
- package/dist/components/checkbox-field/checkbox-field.js +181 -0
- package/dist/components/checkbox-field/checkbox-glyph.d.ts +12 -0
- package/dist/components/checkbox-field/checkbox-glyph.js +38 -0
- package/dist/components/checkbox-field/checkbox.css +128 -0
- package/dist/components/checkbox-field/checkbox.d.ts +14 -0
- package/dist/components/checkbox-field/checkbox.js +91 -0
- package/dist/components/checkbox-field/checkbox.module.js +14 -0
- package/dist/components/checkbox-field/index.d.ts +4 -0
- package/dist/components/checkbox-field/index.js +5 -0
- package/dist/components/checkbox-field/tsf-checkbox-field.d.ts +14 -0
- package/dist/components/checkbox-field/tsf-checkbox-field.js +40 -0
- package/dist/components/checkbox-group-field/checkbox-group-field.d.ts +33 -0
- package/dist/components/checkbox-group-field/checkbox-group-field.js +128 -0
- package/dist/components/checkbox-group-field/checkbox-group.css +31 -0
- package/dist/components/checkbox-group-field/checkbox-group.d.ts +38 -0
- package/dist/components/checkbox-group-field/checkbox-group.js +102 -0
- package/dist/components/checkbox-group-field/checkbox-group.module.js +8 -0
- package/dist/components/checkbox-group-field/index.d.ts +3 -0
- package/dist/components/checkbox-group-field/index.js +4 -0
- package/dist/components/checkbox-group-field/tsf-checkbox-group-field.d.ts +15 -0
- package/dist/components/checkbox-group-field/tsf-checkbox-group-field.js +41 -0
- package/dist/components/collapsible/collapsible.css +88 -0
- package/dist/components/collapsible/collapsible.d.ts +33 -0
- package/dist/components/collapsible/collapsible.js +146 -0
- package/dist/components/collapsible/collapsible.module.js +14 -0
- package/dist/components/collapsible/index.d.ts +1 -0
- package/dist/components/collapsible/index.js +1 -0
- package/dist/components/combobox-field/combobox-field.d.ts +66 -0
- package/dist/components/combobox-field/combobox-field.js +527 -0
- package/dist/components/combobox-field/combobox-items.d.ts +80 -0
- package/dist/components/combobox-field/combobox-items.js +27 -0
- package/dist/components/combobox-field/combobox-popup-body.d.ts +34 -0
- package/dist/components/combobox-field/combobox-popup-body.js +142 -0
- package/dist/components/combobox-field/combobox.css +535 -0
- package/dist/components/combobox-field/combobox.d.ts +105 -0
- package/dist/components/combobox-field/combobox.js +642 -0
- package/dist/components/combobox-field/combobox.module.js +46 -0
- package/dist/components/combobox-field/index.d.ts +7 -0
- package/dist/components/combobox-field/index.js +4 -0
- package/dist/components/combobox-field/item-lookups.d.ts +18 -0
- package/dist/components/combobox-field/item-lookups.js +8 -0
- package/dist/components/combobox-field/react-query.d.ts +15 -0
- package/dist/components/combobox-field/react-query.js +78 -0
- package/dist/components/combobox-field/selection.d.ts +50 -0
- package/dist/components/combobox-field/selection.js +38 -0
- package/dist/components/combobox-field/tsf-combobox-field.d.ts +33 -0
- package/dist/components/combobox-field/tsf-combobox-field.js +88 -0
- package/dist/components/combobox-field/value-state-view.css +21 -0
- package/dist/components/combobox-field/value-state-view.d.ts +35 -0
- package/dist/components/combobox-field/value-state-view.js +107 -0
- package/dist/components/combobox-field/value-state-view.module.js +10 -0
- package/dist/components/combobox-field/value-state.d.ts +49 -0
- package/dist/components/combobox-field/value-state.js +38 -0
- package/dist/components/composer/composer-attachments.d.ts +31 -0
- package/dist/components/composer/composer-attachments.js +158 -0
- package/dist/components/composer/composer-editor.css +104 -0
- package/dist/components/composer/composer-editor.d.ts +15 -0
- package/dist/components/composer/composer-editor.js +165 -0
- package/dist/components/composer/composer-editor.module.js +14 -0
- package/dist/components/composer/composer-mentions.d.ts +10 -0
- package/dist/components/composer/composer-mentions.js +294 -0
- package/dist/components/composer/composer.context.d.ts +56 -0
- package/dist/components/composer/composer.context.js +14 -0
- package/dist/components/composer/composer.css +81 -0
- package/dist/components/composer/composer.d.ts +77 -0
- package/dist/components/composer/composer.handle.d.ts +31 -0
- package/dist/components/composer/composer.handle.js +41 -0
- package/dist/components/composer/composer.js +428 -0
- package/dist/components/composer/composer.module.js +14 -0
- package/dist/components/composer/editor-behavior.d.ts +2 -0
- package/dist/components/composer/editor-behavior.js +99 -0
- package/dist/components/composer/index.d.ts +8 -0
- package/dist/components/composer/index.js +3 -0
- package/dist/components/composer/mention-node.d.ts +44 -0
- package/dist/components/composer/mention-node.js +71 -0
- package/dist/components/composer/mention-sources.d.ts +14 -0
- package/dist/components/composer/mention-text.css +14 -0
- package/dist/components/composer/mention-text.d.ts +66 -0
- package/dist/components/composer/mention-text.js +95 -0
- package/dist/components/composer/mention-text.module.js +4 -0
- package/dist/components/confirm-dialog/confirm-dialog.css +68 -0
- package/dist/components/confirm-dialog/confirm-dialog.d.ts +75 -0
- package/dist/components/confirm-dialog/confirm-dialog.js +399 -0
- package/dist/components/confirm-dialog/confirm-dialog.module.js +14 -0
- package/dist/components/confirm-dialog/index.d.ts +1 -0
- package/dist/components/confirm-dialog/index.js +1 -0
- package/dist/components/conversation/conversation.context.d.ts +9 -0
- package/dist/components/conversation/conversation.context.js +4 -0
- package/dist/components/conversation/conversation.css +143 -0
- package/dist/components/conversation/conversation.d.ts +126 -0
- package/dist/components/conversation/conversation.js +761 -0
- package/dist/components/conversation/conversation.module.js +34 -0
- package/dist/components/conversation/group-messages.d.ts +34 -0
- package/dist/components/conversation/group-messages.js +64 -0
- package/dist/components/conversation/index.d.ts +4 -0
- package/dist/components/conversation/index.js +3 -0
- package/dist/components/conversation/moment.d.ts +11 -0
- package/dist/components/conversation/moment.js +15 -0
- package/dist/components/date-field/date-field.d.ts +45 -0
- package/dist/components/date-field/date-field.js +162 -0
- package/dist/components/date-field/date-input.d.ts +46 -0
- package/dist/components/date-field/date-input.js +109 -0
- package/dist/components/date-field/index.d.ts +4 -0
- package/dist/components/date-field/index.js +4 -0
- package/dist/components/date-field/tsf-date-field.d.ts +14 -0
- package/dist/components/date-field/tsf-date-field.js +40 -0
- package/dist/components/date-range-field/date-range-field.d.ts +53 -0
- package/dist/components/date-range-field/date-range-field.js +167 -0
- package/dist/components/date-range-field/date-range-input.d.ts +51 -0
- package/dist/components/date-range-field/date-range-input.js +109 -0
- package/dist/components/date-range-field/index.d.ts +4 -0
- package/dist/components/date-range-field/index.js +5 -0
- package/dist/components/date-range-field/tsf-date-range-field.d.ts +15 -0
- package/dist/components/date-range-field/tsf-date-range-field.js +58 -0
- package/dist/components/detail-list/detail-list.css +32 -0
- package/dist/components/detail-list/detail-list.d.ts +41 -0
- package/dist/components/detail-list/detail-list.js +163 -0
- package/dist/components/detail-list/detail-list.module.js +14 -0
- package/dist/components/detail-list/index.d.ts +1 -0
- package/dist/components/detail-list/index.js +1 -0
- package/dist/components/dialog/dialog.css +78 -0
- package/dist/components/dialog/dialog.d.ts +59 -0
- package/dist/components/dialog/dialog.js +245 -0
- package/dist/components/dialog/dialog.module.js +16 -0
- package/dist/components/dialog/index.d.ts +1 -0
- package/dist/components/dialog/index.js +1 -0
- package/dist/components/divider/divider.css +16 -0
- package/dist/components/divider/divider.d.ts +13 -0
- package/dist/components/divider/divider.js +47 -0
- package/dist/components/divider/divider.module.js +10 -0
- package/dist/components/divider/index.d.ts +1 -0
- package/dist/components/divider/index.js +1 -0
- package/dist/components/drawer/drawer.css +168 -0
- package/dist/components/drawer/drawer.d.ts +65 -0
- package/dist/components/drawer/drawer.js +219 -0
- package/dist/components/drawer/drawer.module.js +16 -0
- package/dist/components/drawer/index.d.ts +1 -0
- package/dist/components/drawer/index.js +1 -0
- package/dist/components/email-field/email-field.d.ts +11 -0
- package/dist/components/email-field/email-field.js +45 -0
- package/dist/components/email-field/index.d.ts +2 -0
- package/dist/components/email-field/index.js +3 -0
- package/dist/components/email-field/tsf-email-field.d.ts +13 -0
- package/dist/components/email-field/tsf-email-field.js +14 -0
- package/dist/components/empty-message/empty-message.d.ts +16 -0
- package/dist/components/empty-message/empty-message.js +31 -0
- package/dist/components/empty-message/index.d.ts +1 -0
- package/dist/components/empty-message/index.js +1 -0
- package/dist/components/error-boundary/error-boundary.d.ts +43 -0
- package/dist/components/error-boundary/error-boundary.js +60 -0
- package/dist/components/error-boundary/index.d.ts +1 -0
- package/dist/components/error-boundary/index.js +1 -0
- package/dist/components/error-message/error-message.d.ts +15 -0
- package/dist/components/error-message/error-message.js +30 -0
- package/dist/components/error-message/index.d.ts +1 -0
- package/dist/components/error-message/index.js +1 -0
- package/dist/components/error-text/error-cascade.d.ts +32 -0
- package/dist/components/error-text/error-cascade.js +49 -0
- package/dist/components/error-text/error-text.css +27 -0
- package/dist/components/error-text/error-text.d.ts +22 -0
- package/dist/components/error-text/error-text.js +139 -0
- package/dist/components/error-text/error-text.module.js +11 -0
- package/dist/components/error-text/index.d.ts +1 -0
- package/dist/components/error-text/index.js +1 -0
- package/dist/components/field/choice-option.d.ts +11 -0
- package/dist/components/field/field-state.d.ts +51 -0
- package/dist/components/field/field-state.js +28 -0
- package/dist/components/field/field.css +50 -0
- package/dist/components/field/field.d.ts +183 -0
- package/dist/components/field/field.js +434 -0
- package/dist/components/field/field.module.js +20 -0
- package/dist/components/field/fieldset.d.ts +22 -0
- package/dist/components/field/fieldset.js +130 -0
- package/dist/components/field/hidden-input.d.ts +8 -0
- package/dist/components/field/hidden-input.js +12 -0
- package/dist/components/field/index.d.ts +6 -0
- package/dist/components/field/index.js +6 -0
- package/dist/components/field/input-parts.d.ts +49 -0
- package/dist/components/field/input-parts.js +94 -0
- package/dist/components/field/options-load.d.ts +54 -0
- package/dist/components/field/options-load.js +38 -0
- package/dist/components/field/rim-focus.d.ts +10 -0
- package/dist/components/field/rim-focus.js +23 -0
- package/dist/components/field/use-field-focus.d.ts +37 -0
- package/dist/components/field/use-field-focus.js +71 -0
- package/dist/components/field/use-field-state.d.ts +32 -0
- package/dist/components/field/use-field-state.js +77 -0
- package/dist/components/field-placeholder/field-placeholder.css +22 -0
- package/dist/components/field-placeholder/field-placeholder.d.ts +10 -0
- package/dist/components/field-placeholder/field-placeholder.js +54 -0
- package/dist/components/field-placeholder/field-placeholder.module.js +12 -0
- package/dist/components/field-placeholder/index.d.ts +1 -0
- package/dist/components/field-placeholder/index.js +1 -0
- package/dist/components/file-field/file-field.css +101 -0
- package/dist/components/file-field/file-field.d.ts +59 -0
- package/dist/components/file-field/file-field.js +296 -0
- package/dist/components/file-field/file-field.module.js +10 -0
- package/dist/components/file-field/file-input.d.ts +85 -0
- package/dist/components/file-field/file-input.js +334 -0
- package/dist/components/file-field/file-size.d.ts +21 -0
- package/dist/components/file-field/file-size.js +18 -0
- package/dist/components/file-field/file-type.d.ts +21 -0
- package/dist/components/file-field/file-type.js +28 -0
- package/dist/components/file-field/index.d.ts +3 -0
- package/dist/components/file-field/index.js +4 -0
- package/dist/components/file-field/tsf-file-field.d.ts +14 -0
- package/dist/components/file-field/tsf-file-field.js +48 -0
- package/dist/components/filter-bar/filter-bar.css +34 -0
- package/dist/components/filter-bar/filter-bar.d.ts +87 -0
- package/dist/components/filter-bar/filter-bar.js +311 -0
- package/dist/components/filter-bar/filter-bar.module.js +14 -0
- package/dist/components/filter-bar/index.d.ts +2 -0
- package/dist/components/filter-bar/index.js +3 -0
- package/dist/components/filter-bar/use-filter-view.d.ts +86 -0
- package/dist/components/filter-bar/use-filter-view.js +219 -0
- package/dist/components/form/first-invalid.d.ts +10 -0
- package/dist/components/form/first-invalid.js +31 -0
- package/dist/components/form/form-context.d.ts +23 -0
- package/dist/components/form/form-context.js +28 -0
- package/dist/components/form/form.css +14 -0
- package/dist/components/form/form.d.ts +68 -0
- package/dist/components/form/form.js +317 -0
- package/dist/components/form/form.module.js +8 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +3 -0
- package/dist/components/icon/icon.css +9 -0
- package/dist/components/icon/icon.d.ts +31 -0
- package/dist/components/icon/icon.js +61 -0
- package/dist/components/icon/icon.module.js +4 -0
- package/dist/components/icon/index.d.ts +1 -0
- package/dist/components/icon/index.js +1 -0
- package/dist/components/link/index.d.ts +1 -0
- package/dist/components/link/index.js +1 -0
- package/dist/components/link/link.css +18 -0
- package/dist/components/link/link.d.ts +11 -0
- package/dist/components/link/link.js +45 -0
- package/dist/components/link/link.module.js +4 -0
- package/dist/components/link-button/index.d.ts +1 -0
- package/dist/components/link-button/index.js +1 -0
- package/dist/components/link-button/link-button.d.ts +23 -0
- package/dist/components/link-button/link-button.js +80 -0
- package/dist/components/loading-message/index.d.ts +1 -0
- package/dist/components/loading-message/index.js +1 -0
- package/dist/components/loading-message/loading-message.d.ts +22 -0
- package/dist/components/loading-message/loading-message.js +55 -0
- package/dist/components/locale-provider/index.d.ts +1 -0
- package/dist/components/locale-provider/index.js +1 -0
- package/dist/components/locale-provider/locale-provider.d.ts +22 -0
- package/dist/components/locale-provider/locale-provider.js +50 -0
- package/dist/components/menu/index.d.ts +1 -0
- package/dist/components/menu/index.js +1 -0
- package/dist/components/menu/menu.css +122 -0
- package/dist/components/menu/menu.d.ts +78 -0
- package/dist/components/menu/menu.js +382 -0
- package/dist/components/menu/menu.module.js +20 -0
- package/dist/components/nav/index.d.ts +3 -0
- package/dist/components/nav/index.js +3 -0
- package/dist/components/nav/nav-context.d.ts +17 -0
- package/dist/components/nav/nav-context.js +5 -0
- package/dist/components/nav/nav-item-view.d.ts +63 -0
- package/dist/components/nav/nav-item-view.js +243 -0
- package/dist/components/nav/nav.css +310 -0
- package/dist/components/nav/nav.d.ts +87 -0
- package/dist/components/nav/nav.js +481 -0
- package/dist/components/nav/nav.module.js +32 -0
- package/dist/components/number-field/index.d.ts +4 -0
- package/dist/components/number-field/index.js +5 -0
- package/dist/components/number-field/number-field-formats.d.ts +24 -0
- package/dist/components/number-field/number-field-formats.js +43 -0
- package/dist/components/number-field/number-field.css +116 -0
- package/dist/components/number-field/number-field.d.ts +34 -0
- package/dist/components/number-field/number-field.js +168 -0
- package/dist/components/number-field/number-field.module.js +16 -0
- package/dist/components/number-field/number-input.d.ts +76 -0
- package/dist/components/number-field/number-input.js +383 -0
- package/dist/components/number-field/tsf-number-field.d.ts +14 -0
- package/dist/components/number-field/tsf-number-field.js +34 -0
- package/dist/components/otp-field/index.d.ts +3 -0
- package/dist/components/otp-field/index.js +4 -0
- package/dist/components/otp-field/otp-field.css +97 -0
- package/dist/components/otp-field/otp-field.d.ts +22 -0
- package/dist/components/otp-field/otp-field.js +91 -0
- package/dist/components/otp-field/otp-field.module.js +12 -0
- package/dist/components/otp-field/otp-input-context.d.ts +27 -0
- package/dist/components/otp-field/otp-input-context.js +15 -0
- package/dist/components/otp-field/otp-input.d.ts +76 -0
- package/dist/components/otp-field/otp-input.js +341 -0
- package/dist/components/otp-field/tsf-otp-field.d.ts +14 -0
- package/dist/components/otp-field/tsf-otp-field.js +34 -0
- package/dist/components/pagination/index.d.ts +1 -0
- package/dist/components/pagination/index.js +1 -0
- package/dist/components/pagination/pagination-context.d.ts +23 -0
- package/dist/components/pagination/pagination-context.js +14 -0
- package/dist/components/pagination/pagination.css +24 -0
- package/dist/components/pagination/pagination.d.ts +60 -0
- package/dist/components/pagination/pagination.js +341 -0
- package/dist/components/pagination/pagination.module.js +12 -0
- package/dist/components/password-field/index.d.ts +4 -0
- package/dist/components/password-field/index.js +4 -0
- package/dist/components/password-field/password-field.css +66 -0
- package/dist/components/password-field/password-field.d.ts +44 -0
- package/dist/components/password-field/password-field.js +227 -0
- package/dist/components/password-field/password-field.module.js +20 -0
- package/dist/components/password-field/password-strength.d.ts +27 -0
- package/dist/components/password-field/password-strength.js +124 -0
- package/dist/components/password-field/tsf-password-field.d.ts +14 -0
- package/dist/components/password-field/tsf-password-field.js +34 -0
- package/dist/components/phone-field/index.d.ts +2 -0
- package/dist/components/phone-field/index.js +3 -0
- package/dist/components/phone-field/phone-field.d.ts +14 -0
- package/dist/components/phone-field/phone-field.js +29 -0
- package/dist/components/phone-field/tsf-phone-field.d.ts +14 -0
- package/dist/components/phone-field/tsf-phone-field.js +14 -0
- package/dist/components/photo-field/index.d.ts +3 -0
- package/dist/components/photo-field/index.js +4 -0
- package/dist/components/photo-field/photo-field.d.ts +29 -0
- package/dist/components/photo-field/photo-field.js +183 -0
- package/dist/components/photo-field/photo-input.css +113 -0
- package/dist/components/photo-field/photo-input.d.ts +63 -0
- package/dist/components/photo-field/photo-input.js +327 -0
- package/dist/components/photo-field/photo-input.module.js +18 -0
- package/dist/components/photo-field/tsf-photo-field.d.ts +19 -0
- package/dist/components/photo-field/tsf-photo-field.js +56 -0
- package/dist/components/popover/index.d.ts +1 -0
- package/dist/components/popover/index.js +1 -0
- package/dist/components/popover/popover.css +120 -0
- package/dist/components/popover/popover.d.ts +72 -0
- package/dist/components/popover/popover.js +434 -0
- package/dist/components/popover/popover.module.js +34 -0
- package/dist/components/radio-group-field/index.d.ts +3 -0
- package/dist/components/radio-group-field/index.js +4 -0
- package/dist/components/radio-group-field/radio-group-field.d.ts +26 -0
- package/dist/components/radio-group-field/radio-group-field.js +128 -0
- package/dist/components/radio-group-field/radio-group.css +116 -0
- package/dist/components/radio-group-field/radio-group.d.ts +38 -0
- package/dist/components/radio-group-field/radio-group.js +158 -0
- package/dist/components/radio-group-field/radio-group.module.js +12 -0
- package/dist/components/radio-group-field/tsf-radio-group-field.d.ts +15 -0
- package/dist/components/radio-group-field/tsf-radio-group-field.js +41 -0
- package/dist/components/search-field/index.d.ts +2 -0
- package/dist/components/search-field/index.js +3 -0
- package/dist/components/search-field/search-field.d.ts +17 -0
- package/dist/components/search-field/search-field.js +45 -0
- package/dist/components/search-field/tsf-search-field.d.ts +14 -0
- package/dist/components/search-field/tsf-search-field.js +14 -0
- package/dist/components/segmented-control-field/index.d.ts +3 -0
- package/dist/components/segmented-control-field/index.js +4 -0
- package/dist/components/segmented-control-field/segmented-control-field.d.ts +32 -0
- package/dist/components/segmented-control-field/segmented-control-field.js +166 -0
- package/dist/components/segmented-control-field/segmented-control.css +203 -0
- package/dist/components/segmented-control-field/segmented-control.d.ts +58 -0
- package/dist/components/segmented-control-field/segmented-control.js +209 -0
- package/dist/components/segmented-control-field/segmented-control.module.js +12 -0
- package/dist/components/segmented-control-field/tsf-segmented-control-field.d.ts +15 -0
- package/dist/components/segmented-control-field/tsf-segmented-control-field.js +41 -0
- package/dist/components/select-field/index.d.ts +3 -0
- package/dist/components/select-field/index.js +4 -0
- package/dist/components/select-field/select-context.d.ts +20 -0
- package/dist/components/select-field/select-context.js +15 -0
- package/dist/components/select-field/select-field.d.ts +32 -0
- package/dist/components/select-field/select-field.js +312 -0
- package/dist/components/select-field/select.css +233 -0
- package/dist/components/select-field/select.d.ts +78 -0
- package/dist/components/select-field/select.js +529 -0
- package/dist/components/select-field/select.module.js +30 -0
- package/dist/components/select-field/tsf-select-field.d.ts +15 -0
- package/dist/components/select-field/tsf-select-field.js +41 -0
- package/dist/components/skeleton/index.d.ts +1 -0
- package/dist/components/skeleton/index.js +1 -0
- package/dist/components/skeleton/skeleton.css +16 -0
- package/dist/components/skeleton/skeleton.d.ts +13 -0
- package/dist/components/skeleton/skeleton.js +34 -0
- package/dist/components/skeleton/skeleton.module.js +9 -0
- package/dist/components/spinner/index.d.ts +1 -0
- package/dist/components/spinner/index.js +1 -0
- package/dist/components/spinner/spinner.css +7 -0
- package/dist/components/spinner/spinner.d.ts +15 -0
- package/dist/components/spinner/spinner.js +50 -0
- package/dist/components/spinner/spinner.module.js +4 -0
- package/dist/components/stale/index.d.ts +1 -0
- package/dist/components/stale/index.js +1 -0
- package/dist/components/stale/stale.css +60 -0
- package/dist/components/stale/stale.d.ts +68 -0
- package/dist/components/stale/stale.js +231 -0
- package/dist/components/stale/stale.module.js +16 -0
- package/dist/components/status-message/index.d.ts +1 -0
- package/dist/components/status-message/index.js +1 -0
- package/dist/components/status-message/status-message.css +122 -0
- package/dist/components/status-message/status-message.d.ts +72 -0
- package/dist/components/status-message/status-message.js +182 -0
- package/dist/components/status-message/status-message.module.js +16 -0
- package/dist/components/status-message/status-preset.d.ts +26 -0
- package/dist/components/status-message/status-preset.js +64 -0
- package/dist/components/switch-field/index.d.ts +3 -0
- package/dist/components/switch-field/index.js +4 -0
- package/dist/components/switch-field/switch-field.d.ts +23 -0
- package/dist/components/switch-field/switch-field.js +142 -0
- package/dist/components/switch-field/switch.css +145 -0
- package/dist/components/switch-field/switch.d.ts +35 -0
- package/dist/components/switch-field/switch.js +207 -0
- package/dist/components/switch-field/switch.module.js +12 -0
- package/dist/components/switch-field/tsf-switch-field.d.ts +14 -0
- package/dist/components/switch-field/tsf-switch-field.js +40 -0
- package/dist/components/tabs/index.d.ts +1 -0
- package/dist/components/tabs/index.js +1 -0
- package/dist/components/tabs/tabs.css +122 -0
- package/dist/components/tabs/tabs.d.ts +57 -0
- package/dist/components/tabs/tabs.js +194 -0
- package/dist/components/tabs/tabs.module.js +18 -0
- package/dist/components/tag/index.d.ts +1 -0
- package/dist/components/tag/index.js +1 -0
- package/dist/components/tag/tag.css +120 -0
- package/dist/components/tag/tag.d.ts +36 -0
- package/dist/components/tag/tag.js +124 -0
- package/dist/components/tag/tag.module.js +10 -0
- package/dist/components/tag-group/index.d.ts +1 -0
- package/dist/components/tag-group/index.js +1 -0
- package/dist/components/tag-group/tag-group.css +155 -0
- package/dist/components/tag-group/tag-group.d.ts +53 -0
- package/dist/components/tag-group/tag-group.js +182 -0
- package/dist/components/tag-group/tag-group.module.js +12 -0
- package/dist/components/text-field/connect-text-preset.d.ts +13 -0
- package/dist/components/text-field/connect-text-preset.js +34 -0
- package/dist/components/text-field/index.d.ts +5 -0
- package/dist/components/text-field/index.js +5 -0
- package/dist/components/text-field/text-field.css +170 -0
- package/dist/components/text-field/text-field.d.ts +57 -0
- package/dist/components/text-field/text-field.js +247 -0
- package/dist/components/text-field/text-field.module.js +22 -0
- package/dist/components/text-field/text-input-context.d.ts +28 -0
- package/dist/components/text-field/text-input-context.js +16 -0
- package/dist/components/text-field/text-input.d.ts +79 -0
- package/dist/components/text-field/text-input.js +588 -0
- package/dist/components/text-field/text-preset.d.ts +7 -0
- package/dist/components/text-field/tsf-text-field.d.ts +14 -0
- package/dist/components/text-field/tsf-text-field.js +34 -0
- package/dist/components/textarea-field/index.d.ts +3 -0
- package/dist/components/textarea-field/index.js +4 -0
- package/dist/components/textarea-field/textarea-field.css +12 -0
- package/dist/components/textarea-field/textarea-field.d.ts +19 -0
- package/dist/components/textarea-field/textarea-field.js +168 -0
- package/dist/components/textarea-field/textarea-field.module.js +8 -0
- package/dist/components/textarea-field/textarea.d.ts +19 -0
- package/dist/components/textarea-field/textarea.js +108 -0
- package/dist/components/textarea-field/tsf-textarea-field.d.ts +14 -0
- package/dist/components/textarea-field/tsf-textarea-field.js +34 -0
- package/dist/components/textarea-field/use-autosize.d.ts +11 -0
- package/dist/components/textarea-field/use-autosize.js +65 -0
- package/dist/components/time-field/index.d.ts +3 -0
- package/dist/components/time-field/index.js +4 -0
- package/dist/components/time-field/time-field.d.ts +25 -0
- package/dist/components/time-field/time-field.js +115 -0
- package/dist/components/time-field/time-input.d.ts +30 -0
- package/dist/components/time-field/time-input.js +66 -0
- package/dist/components/time-field/tsf-time-field.d.ts +14 -0
- package/dist/components/time-field/tsf-time-field.js +40 -0
- package/dist/components/time-zone-provider/index.d.ts +1 -0
- package/dist/components/time-zone-provider/index.js +1 -0
- package/dist/components/time-zone-provider/time-zone-provider.d.ts +22 -0
- package/dist/components/time-zone-provider/time-zone-provider.js +39 -0
- package/dist/components/toast/index.d.ts +2 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/toast-provider.css +99 -0
- package/dist/components/toast/toast-provider.d.ts +18 -0
- package/dist/components/toast/toast-provider.js +203 -0
- package/dist/components/toast/toast-provider.module.js +24 -0
- package/dist/components/toast/toast.d.ts +79 -0
- package/dist/components/toast/toast.js +68 -0
- package/dist/components/toggle-group-field/index.d.ts +3 -0
- package/dist/components/toggle-group-field/index.js +4 -0
- package/dist/components/toggle-group-field/toggle-group-field.d.ts +32 -0
- package/dist/components/toggle-group-field/toggle-group-field.js +158 -0
- package/dist/components/toggle-group-field/toggle-group.css +148 -0
- package/dist/components/toggle-group-field/toggle-group.d.ts +44 -0
- package/dist/components/toggle-group-field/toggle-group.js +156 -0
- package/dist/components/toggle-group-field/toggle-group.module.js +8 -0
- package/dist/components/toggle-group-field/tsf-toggle-group-field.d.ts +15 -0
- package/dist/components/toggle-group-field/tsf-toggle-group-field.js +41 -0
- package/dist/components/tooltip/index.d.ts +1 -0
- package/dist/components/tooltip/index.js +1 -0
- package/dist/components/tooltip/tooltip.css +22 -0
- package/dist/components/tooltip/tooltip.d.ts +46 -0
- package/dist/components/tooltip/tooltip.js +175 -0
- package/dist/components/tooltip/tooltip.module.js +4 -0
- package/dist/data-table/data-table-content.d.ts +27 -0
- package/dist/data-table/data-table-content.js +311 -0
- package/dist/data-table/data-table-context.d.ts +33 -0
- package/dist/data-table/data-table-context.js +31 -0
- package/dist/data-table/data-table-selection.d.ts +42 -0
- package/dist/data-table/data-table-selection.js +299 -0
- package/dist/data-table/data-table.css +515 -0
- package/dist/data-table/data-table.d.ts +93 -0
- package/dist/data-table/data-table.js +215 -0
- package/dist/data-table/data-table.module.js +68 -0
- package/dist/data-table/index.d.ts +6 -0
- package/dist/data-table/index.js +5 -0
- package/dist/data-table/resolve-view.d.ts +31 -0
- package/dist/data-table/resolve-view.js +37 -0
- package/dist/data-table/table-features.d.ts +69 -0
- package/dist/data-table/table-features.js +41 -0
- package/dist/data-table/use-sticky-offsets.d.ts +21 -0
- package/dist/data-table/use-sticky-offsets.js +86 -0
- package/dist/data-view/index.d.ts +1 -0
- package/dist/data-view/index.js +1 -0
- package/dist/data-view/use-data-view.d.ts +83 -0
- package/dist/data-view/use-data-view.js +135 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +132 -0
- package/dist/lib/calendar/calendar-navigation.d.ts +19 -0
- package/dist/lib/calendar/calendar-navigation.js +216 -0
- package/dist/lib/calendar/calendar-state.d.ts +19 -0
- package/dist/lib/calendar/calendar-state.js +33 -0
- package/dist/lib/calendar/calendar-year.d.ts +20 -0
- package/dist/lib/calendar/calendar-year.js +342 -0
- package/dist/lib/calendar/temporal-value.d.ts +84 -0
- package/dist/lib/calendar/temporal-value.js +105 -0
- package/dist/lib/calendar/temporal.css +596 -0
- package/dist/lib/calendar/temporal.d.ts +134 -0
- package/dist/lib/calendar/temporal.js +783 -0
- package/dist/lib/calendar/temporal.module.js +80 -0
- package/dist/lib/format-bytes.d.ts +10 -0
- package/dist/lib/format-bytes.js +22 -0
- package/dist/lib/forms/context.d.ts +32 -0
- package/dist/lib/forms/context.js +33 -0
- package/dist/lib/forms/create-app-form.d.ts +24 -0
- package/dist/lib/forms/create-app-form.js +36 -0
- package/dist/lib/forms/errors.d.ts +23 -0
- package/dist/lib/forms/errors.js +25 -0
- package/dist/lib/forms/failed-submit.d.ts +16 -0
- package/dist/lib/forms/failed-submit.js +44 -0
- package/dist/lib/forms/index.d.ts +3 -0
- package/dist/lib/forms/index.js +4 -0
- package/dist/lib/forms/use-connected-field.d.ts +27 -0
- package/dist/lib/forms/use-connected-field.js +48 -0
- package/dist/lib/hooks/index.d.ts +5 -0
- package/dist/lib/hooks/index.js +6 -0
- package/dist/lib/hooks/use-busy-phase.d.ts +31 -0
- package/dist/lib/hooks/use-busy-phase.js +75 -0
- package/dist/lib/hooks/use-media-query.d.ts +8 -0
- package/dist/lib/hooks/use-media-query.js +34 -0
- package/dist/lib/hooks/use-presence.d.ts +25 -0
- package/dist/lib/hooks/use-presence.js +155 -0
- package/dist/lib/hooks/use-row-selection.d.ts +65 -0
- package/dist/lib/hooks/use-row-selection.js +136 -0
- package/dist/lib/hooks/use-theme.d.ts +28 -0
- package/dist/lib/hooks/use-theme.js +88 -0
- package/dist/lib/iso-zoned.d.ts +9 -0
- package/dist/lib/iso-zoned.js +19 -0
- package/dist/lib/password-strength/password-strength.d.ts +38 -0
- package/dist/lib/password-strength/password-strength.js +72 -0
- package/dist/lib/popup-edge-padding.d.ts +20 -0
- package/dist/lib/popup-edge-padding.js +41 -0
- package/dist/lib/sliding-indicator/index.d.ts +1 -0
- package/dist/lib/sliding-indicator/use-sliding-indicator.d.ts +27 -0
- package/dist/lib/sliding-indicator/use-sliding-indicator.js +84 -0
- package/dist/lib/storage.d.ts +21 -0
- package/dist/lib/storage.js +0 -0
- package/dist/lib/table-storage.d.ts +43 -0
- package/dist/lib/table-storage.js +62 -0
- package/dist/lib/text-length.d.ts +10 -0
- package/dist/lib/text-length.js +15 -0
- package/dist/lib/tone.d.ts +14 -0
- package/dist/lib/tone.js +0 -0
- package/dist/lib/unsaved-changes/before-unload.d.ts +8 -0
- package/dist/lib/unsaved-changes/before-unload.js +37 -0
- package/dist/lib/unsaved-changes/index.d.ts +4 -0
- package/dist/lib/unsaved-changes/index.js +5 -0
- package/dist/lib/unsaved-changes/leave-guard.d.ts +80 -0
- package/dist/lib/unsaved-changes/leave-guard.js +170 -0
- package/dist/lib/unsaved-changes/policy.d.ts +24 -0
- package/dist/lib/unsaved-changes/policy.js +17 -0
- package/dist/lib/unsaved-changes/registry.d.ts +36 -0
- package/dist/lib/unsaved-changes/registry.js +78 -0
- package/dist/lib/unsaved-changes/tanstack-router.d.ts +12 -0
- package/dist/lib/unsaved-changes/tanstack-router.js +50 -0
- package/dist/lib/use-infinite-scroll.d.ts +31 -0
- package/dist/lib/use-infinite-scroll.js +78 -0
- package/dist/lib/use-intent.d.ts +17 -0
- package/dist/lib/use-intent.js +77 -0
- package/dist/lib/use-required-context.d.ts +9 -0
- package/dist/lib/use-required-context.js +15 -0
- package/dist/terrazzo/index.d.ts +39 -0
- package/dist/terrazzo/index.js +93 -0
- package/dist/tokens.css +1102 -0
- package/dist/vendor/@material-design-icons/svg/outlined/add.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/arrow_downward.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/arrow_forward.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/arrow_upward.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/attach_file.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/block.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/calendar_today.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/check.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/check_circle.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/chevron_left.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/chevron_right.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/close.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/content_copy.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/date_range.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/description.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/download.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/error.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/error_outline.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/expand_less.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/expand_more.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/filter_alt.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/filter_alt_off.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/first_page.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/info.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/keyboard_arrow_down.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/last_page.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/mail.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/more_horiz.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/photo_camera.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/remove.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/restart_alt.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/restore.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/search.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/unfold_more.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/upload_file.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/visibility.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/visibility_off.js +12 -0
- package/dist/vendor/@material-design-icons/svg/outlined/warning_amber.js +12 -0
- package/package.json +452 -5
- package/tokens/dark.tokens.json +329 -0
- package/tokens/kit.resolver.json +38 -0
- package/tokens/ref.tokens.json +1436 -0
- package/tokens/sys.tokens.json +1267 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type RefCallback } from "react";
|
|
2
|
+
/** What {@link useSlidingIndicator} measures and where it writes. */
|
|
3
|
+
export type SlidingIndicatorOptions = Readonly<{
|
|
4
|
+
/** Matches the active item inside the indicator's parent, such as `"[data-pressed]"`. */
|
|
5
|
+
active: string;
|
|
6
|
+
/** The custom-property prefix the indicator's styles read. @default "--active-item" */
|
|
7
|
+
prefix?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Which element carries the custom properties: the indicator, or its parent,
|
|
10
|
+
* where the indicator and its siblings inherit them. @default "indicator"
|
|
11
|
+
*/
|
|
12
|
+
publishOn?: "indicator" | "parent";
|
|
13
|
+
}>;
|
|
14
|
+
/**
|
|
15
|
+
* Moves a sliding indicator onto the active item of its parent, which must be
|
|
16
|
+
* positioned. Writes `<prefix>-left`, `-top`, `-width` and `-height` on the
|
|
17
|
+
* indicator (or on its parent, with `publishOn: "parent"`), sets `data-empty`
|
|
18
|
+
* on the indicator while nothing is active and `data-jump` when it arrives from
|
|
19
|
+
* nothing, and re-measures whenever the parent resizes or anything inside it
|
|
20
|
+
* changes. It starts tracking whenever the indicator mounts. Style it with the
|
|
21
|
+
* `sliding-indicator.scss` mixins.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* const ref = useSlidingIndicator<HTMLSpanElement>({ active: '[aria-current="page"]' });
|
|
25
|
+
* <span ref={ref} aria-hidden="true" className={style.indicator} />
|
|
26
|
+
*/
|
|
27
|
+
export declare const useSlidingIndicator: <TElement extends HTMLElement>({ active, prefix, publishOn, }: SlidingIndicatorOptions) => RefCallback<TElement>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
// src/lib/sliding-indicator/use-sliding-indicator.ts
|
|
3
|
+
var offsetWithin = (element, container) => {
|
|
4
|
+
let left = 0;
|
|
5
|
+
let top = 0;
|
|
6
|
+
let node = element;
|
|
7
|
+
while (node instanceof HTMLElement && node !== container) {
|
|
8
|
+
left += node.offsetLeft;
|
|
9
|
+
top += node.offsetTop;
|
|
10
|
+
node = node.offsetParent;
|
|
11
|
+
}
|
|
12
|
+
return {
|
|
13
|
+
left,
|
|
14
|
+
top
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
var publish = (carrier, property, value) => {
|
|
18
|
+
if (carrier.style.getPropertyValue(property) !== value) carrier.style.setProperty(property, value);
|
|
19
|
+
};
|
|
20
|
+
var track = (indicator, active, prefix, publishOn) => {
|
|
21
|
+
const container = indicator.parentElement;
|
|
22
|
+
if (container === null) return () => void 0;
|
|
23
|
+
const carrier = publishOn === "parent" ? container : indicator;
|
|
24
|
+
let wasActive = false;
|
|
25
|
+
const measure = () => {
|
|
26
|
+
const target = container.querySelector(active);
|
|
27
|
+
indicator.toggleAttribute("data-empty", target === null);
|
|
28
|
+
if (target === null) {
|
|
29
|
+
wasActive = false;
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
indicator.toggleAttribute("data-jump", !wasActive);
|
|
33
|
+
wasActive = true;
|
|
34
|
+
const { left, top } = offsetWithin(target, container);
|
|
35
|
+
publish(carrier, `${prefix}-left`, `${left}px`);
|
|
36
|
+
publish(carrier, `${prefix}-top`, `${top}px`);
|
|
37
|
+
publish(carrier, `${prefix}-width`, `${target.offsetWidth}px`);
|
|
38
|
+
publish(carrier, `${prefix}-height`, `${target.offsetHeight}px`);
|
|
39
|
+
};
|
|
40
|
+
measure();
|
|
41
|
+
const resizes = new ResizeObserver(measure);
|
|
42
|
+
resizes.observe(container);
|
|
43
|
+
const mutations = new MutationObserver((records) => {
|
|
44
|
+
if (records.some((record) => !indicator.contains(record.target))) measure();
|
|
45
|
+
});
|
|
46
|
+
mutations.observe(container, {
|
|
47
|
+
attributes: true,
|
|
48
|
+
childList: true,
|
|
49
|
+
subtree: true
|
|
50
|
+
});
|
|
51
|
+
return () => {
|
|
52
|
+
resizes.disconnect();
|
|
53
|
+
mutations.disconnect();
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Moves a sliding indicator onto the active item of its parent, which must be
|
|
58
|
+
* positioned. Writes `<prefix>-left`, `-top`, `-width` and `-height` on the
|
|
59
|
+
* indicator (or on its parent, with `publishOn: "parent"`), sets `data-empty`
|
|
60
|
+
* on the indicator while nothing is active and `data-jump` when it arrives from
|
|
61
|
+
* nothing, and re-measures whenever the parent resizes or anything inside it
|
|
62
|
+
* changes. It starts tracking whenever the indicator mounts. Style it with the
|
|
63
|
+
* `sliding-indicator.scss` mixins.
|
|
64
|
+
*
|
|
65
|
+
* @example
|
|
66
|
+
* const ref = useSlidingIndicator<HTMLSpanElement>({ active: '[aria-current="page"]' });
|
|
67
|
+
* <span ref={ref} aria-hidden="true" className={style.indicator} />
|
|
68
|
+
*/
|
|
69
|
+
var useSlidingIndicator = (t0) => {
|
|
70
|
+
const $ = c(4);
|
|
71
|
+
const { active, prefix: t1, publishOn: t2 } = t0;
|
|
72
|
+
const prefix = t1 === void 0 ? "--active-item" : t1;
|
|
73
|
+
const publishOn = t2 === void 0 ? "indicator" : t2;
|
|
74
|
+
let t3;
|
|
75
|
+
if ($[0] !== active || $[1] !== prefix || $[2] !== publishOn) {
|
|
76
|
+
t3 = (indicator) => indicator === null ? void 0 : track(indicator, active, prefix, publishOn);
|
|
77
|
+
$[0] = active;
|
|
78
|
+
$[1] = prefix;
|
|
79
|
+
$[2] = publishOn;
|
|
80
|
+
$[3] = t3;
|
|
81
|
+
} else t3 = $[3];
|
|
82
|
+
return t3;
|
|
83
|
+
};
|
|
84
|
+
export { useSlidingIndicator };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A synchronous key-value store the app hands the kit for anything it
|
|
3
|
+
* persists. It is synchronous so a preference can be read during the first
|
|
4
|
+
* render. It owns serialisation and swallows access errors: a read that fails
|
|
5
|
+
* reports `undefined`, and a write or remove that fails is dropped.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const { preference } = useTheme({ storage: localStorageAdapter, key: "theme" });
|
|
9
|
+
*/
|
|
10
|
+
export type StorageAdapter = Readonly<{
|
|
11
|
+
/** The value stored under `key`, or `undefined` when there is none. */
|
|
12
|
+
read: (key: string) => unknown;
|
|
13
|
+
write: (key: string, value: unknown) => void;
|
|
14
|
+
remove: (key: string) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Calls `listener` whenever the value under `key` may have changed, in this
|
|
17
|
+
* tab or another, writes through this adapter included. Returns the
|
|
18
|
+
* unsubscribe.
|
|
19
|
+
*/
|
|
20
|
+
subscribe: (key: string, listener: () => void) => () => void;
|
|
21
|
+
}>;
|
|
File without changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { StandardSchemaV1 } from "@tanstack/react-form";
|
|
2
|
+
import type { StorageAdapter } from "./storage.ts";
|
|
3
|
+
/** One persisted value, checked by its validator on every read and write. */
|
|
4
|
+
export type StoredValue<T> = Readonly<{
|
|
5
|
+
/**
|
|
6
|
+
* The stored value, or the fallback when nothing is stored or the stored
|
|
7
|
+
* value no longer passes the validator.
|
|
8
|
+
*/
|
|
9
|
+
read: () => T;
|
|
10
|
+
/** Stores `value`. Throws, storing nothing, when it fails the validator. */
|
|
11
|
+
write: (value: T) => void;
|
|
12
|
+
/** Forgets the stored value, so the next read returns the fallback. */
|
|
13
|
+
clear: () => void;
|
|
14
|
+
/** Calls `listener` whenever the value may have changed. Returns the unsubscribe. */
|
|
15
|
+
subscribe: (listener: () => void) => () => void;
|
|
16
|
+
}>;
|
|
17
|
+
/** What a stored value is checked against, and what it reads as when nothing valid is stored. */
|
|
18
|
+
export type StoredValueShape<T> = Readonly<{
|
|
19
|
+
/** A synchronous Standard Schema validator; an asynchronous result counts as a failure. */
|
|
20
|
+
schema: StandardSchemaV1<unknown, T>;
|
|
21
|
+
fallback: T;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* A value one table instance remembers across reloads, stored in `storage`
|
|
25
|
+
* under its `tableId` and `name`.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const filters = tableStoredValue(
|
|
29
|
+
* "declarations",
|
|
30
|
+
* "filters",
|
|
31
|
+
* { schema: z.object({ status: z.array(z.string()) }), fallback: { status: [] } },
|
|
32
|
+
* localStorageAdapter,
|
|
33
|
+
* );
|
|
34
|
+
*/
|
|
35
|
+
export declare const tableStoredValue: <T>(tableId: string, name: string, { schema, fallback }: StoredValueShape<T>, storage: StorageAdapter) => StoredValue<T>;
|
|
36
|
+
/**
|
|
37
|
+
* The page size a table remembers: one of its `options`, or `fallback` when
|
|
38
|
+
* none is stored.
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* storedPageSize("nza-rates", [10, 25, 50, 100], 10, localStorageAdapter).read(); // 50, or 10
|
|
42
|
+
*/
|
|
43
|
+
export declare const storedPageSize: (tableId: string, options: readonly number[], fallback: number, storage: StorageAdapter) => StoredValue<number>;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// src/lib/table-storage.ts
|
|
2
|
+
var check = (schema, value) => {
|
|
3
|
+
const result = schema["~standard"].validate(value);
|
|
4
|
+
if (result instanceof Promise) return {
|
|
5
|
+
ok: false,
|
|
6
|
+
reason: "the validator is asynchronous"
|
|
7
|
+
};
|
|
8
|
+
return result.issues === void 0 ? {
|
|
9
|
+
ok: true,
|
|
10
|
+
value: result.value
|
|
11
|
+
} : {
|
|
12
|
+
ok: false,
|
|
13
|
+
reason: result.issues.map((issue) => issue.message).join("; ")
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* A value one table instance remembers across reloads, stored in `storage`
|
|
18
|
+
* under its `tableId` and `name`.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const filters = tableStoredValue(
|
|
22
|
+
* "declarations",
|
|
23
|
+
* "filters",
|
|
24
|
+
* { schema: z.object({ status: z.array(z.string()) }), fallback: { status: [] } },
|
|
25
|
+
* localStorageAdapter,
|
|
26
|
+
* );
|
|
27
|
+
*/
|
|
28
|
+
var tableStoredValue = (tableId, name, { schema, fallback }, storage) => {
|
|
29
|
+
const key = `table:${tableId}:${name}`;
|
|
30
|
+
return {
|
|
31
|
+
read: () => {
|
|
32
|
+
const stored = check(schema, storage.read(key));
|
|
33
|
+
return stored.ok ? stored.value : fallback;
|
|
34
|
+
},
|
|
35
|
+
write: (value) => {
|
|
36
|
+
const checked = check(schema, value);
|
|
37
|
+
if (!checked.ok) throw new Error(`Refusing to store ${key}: ${checked.reason}`);
|
|
38
|
+
storage.write(key, checked.value);
|
|
39
|
+
},
|
|
40
|
+
clear: () => {
|
|
41
|
+
storage.remove(key);
|
|
42
|
+
},
|
|
43
|
+
subscribe: (listener) => storage.subscribe(key, listener)
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
var pageSizeSchema = (options) => ({ "~standard": {
|
|
47
|
+
version: 1,
|
|
48
|
+
vendor: "react-web-ui",
|
|
49
|
+
validate: (value) => typeof value === "number" && options.includes(value) ? { value } : { issues: [{ message: `expected one of ${options.join(", ")}` }] }
|
|
50
|
+
} });
|
|
51
|
+
/**
|
|
52
|
+
* The page size a table remembers: one of its `options`, or `fallback` when
|
|
53
|
+
* none is stored.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* storedPageSize("nza-rates", [10, 25, 50, 100], 10, localStorageAdapter).read(); // 50, or 10
|
|
57
|
+
*/
|
|
58
|
+
var storedPageSize = (tableId, options, fallback, storage) => tableStoredValue(tableId, "page-size", {
|
|
59
|
+
schema: pageSizeSchema(options),
|
|
60
|
+
fallback
|
|
61
|
+
}, storage);
|
|
62
|
+
export { storedPageSize, tableStoredValue };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** How a `length / maxLength` counter reads against its maximum. */
|
|
2
|
+
export type LengthTone = "normal" | "warning" | "error";
|
|
3
|
+
/**
|
|
4
|
+
* The tone a length counter shows: `warning` from 90% of the maximum, `error`
|
|
5
|
+
* past it.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* lengthTone(1900, 2000); // "warning"
|
|
9
|
+
*/
|
|
10
|
+
export declare const lengthTone: (length: number, maxLength: number) => LengthTone;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// src/lib/text-length.ts
|
|
2
|
+
var WARNING_RATIO = .9;
|
|
3
|
+
/**
|
|
4
|
+
* The tone a length counter shows: `warning` from 90% of the maximum, `error`
|
|
5
|
+
* past it.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* lengthTone(1900, 2000); // "warning"
|
|
9
|
+
*/
|
|
10
|
+
var lengthTone = (length, maxLength) => {
|
|
11
|
+
const ratio = length / maxLength;
|
|
12
|
+
if (ratio > 1) return "error";
|
|
13
|
+
return ratio >= WARNING_RATIO ? "warning" : "normal";
|
|
14
|
+
};
|
|
15
|
+
export { lengthTone };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A status colour role, shared by every leaf that carries one.
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* const tone: Tone = "warning";
|
|
6
|
+
*/
|
|
7
|
+
export type Tone = "neutral" | "info" | "success" | "warning" | "error";
|
|
8
|
+
/**
|
|
9
|
+
* How a toned leaf fills: a tint, the tone's ink as a fill, or an outline.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <Badge tone="info" variant="solid">3</Badge>
|
|
13
|
+
*/
|
|
14
|
+
export type ToneVariant = "subtle" | "solid" | "outline";
|
package/dist/lib/tone.js
ADDED
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { c } from "react/compiler-runtime";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
// src/lib/unsaved-changes/before-unload.ts
|
|
4
|
+
var holdUnload = (event) => {
|
|
5
|
+
event.preventDefault();
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Asks the browser to confirm a reload, a close or a navigation away from the
|
|
9
|
+
* app while `when`.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* useBeforeUnload(form.state.isDirty);
|
|
13
|
+
*/
|
|
14
|
+
var useBeforeUnload = (when) => {
|
|
15
|
+
const $ = c(3);
|
|
16
|
+
let t0;
|
|
17
|
+
let t1;
|
|
18
|
+
if ($[0] !== when) {
|
|
19
|
+
t0 = () => {
|
|
20
|
+
if (!when) return;
|
|
21
|
+
window.addEventListener("beforeunload", holdUnload);
|
|
22
|
+
return _temp;
|
|
23
|
+
};
|
|
24
|
+
t1 = [when];
|
|
25
|
+
$[0] = when;
|
|
26
|
+
$[1] = t0;
|
|
27
|
+
$[2] = t1;
|
|
28
|
+
} else {
|
|
29
|
+
t0 = $[1];
|
|
30
|
+
t1 = $[2];
|
|
31
|
+
}
|
|
32
|
+
useEffect(t0, t1);
|
|
33
|
+
};
|
|
34
|
+
function _temp() {
|
|
35
|
+
return window.removeEventListener("beforeunload", holdUnload);
|
|
36
|
+
}
|
|
37
|
+
export { useBeforeUnload };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { useBeforeUnload } from "./before-unload.ts";
|
|
2
|
+
export { type LeaveGuard, LeaveGuardDialog, type LeaveGuardDialogProps, useLeaveGuard, } from "./leave-guard.tsx";
|
|
3
|
+
export { type LeaveGuardPolicy, never, whenDirty, } from "./policy.ts";
|
|
4
|
+
export { useReportUnsavedChanges, useUnsavedChanges, } from "./registry.ts";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { useBeforeUnload } from "./before-unload.js";
|
|
2
|
+
import { LeaveGuardDialog, useLeaveGuard } from "./leave-guard.js";
|
|
3
|
+
import { never, whenDirty } from "./policy.js";
|
|
4
|
+
import { useReportUnsavedChanges, useUnsavedChanges } from "./registry.js";
|
|
5
|
+
export { LeaveGuardDialog, never, useBeforeUnload, useLeaveGuard, useReportUnsavedChanges, useUnsavedChanges, whenDirty };
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import { type ConfirmDialogProps } from "../../components/confirm-dialog/confirm-dialog.tsx";
|
|
3
|
+
/** A guard against leaving: whether it blocks, the leave it holds, and the answers to it. */
|
|
4
|
+
export type LeaveGuard = Readonly<{
|
|
5
|
+
/** Whether leaving is blocked now: `when`, except while a leave that was agreed to goes through. */
|
|
6
|
+
blocking: boolean;
|
|
7
|
+
/** Whether a held leave is waiting for an answer. */
|
|
8
|
+
asking: boolean;
|
|
9
|
+
/** Hands the guard a leave that was blocked, with what lets it through. */
|
|
10
|
+
hold: (proceed: () => void) => void;
|
|
11
|
+
/** Agrees to the held leave, which goes through once the question has gone. */
|
|
12
|
+
agree: () => void;
|
|
13
|
+
/** Lets the held leave through if it was agreed to, and otherwise stays. */
|
|
14
|
+
settle: () => void;
|
|
15
|
+
}>;
|
|
16
|
+
/** A held leave's two answers. */
|
|
17
|
+
export type HeldLeave = Readonly<{
|
|
18
|
+
proceed: () => void;
|
|
19
|
+
stay: () => void;
|
|
20
|
+
}>;
|
|
21
|
+
/** A guard's state before it knows which leave it answers for. */
|
|
22
|
+
export type LeaveGuardCore = Readonly<{
|
|
23
|
+
blocking: boolean;
|
|
24
|
+
/** The leave handed to `hold`, if any. */
|
|
25
|
+
held: HeldLeave | undefined;
|
|
26
|
+
hold: (proceed: () => void) => void;
|
|
27
|
+
agree: () => void;
|
|
28
|
+
/** Answers `leave` as agreed, and forgets the held one. */
|
|
29
|
+
settle: (leave: HeldLeave | undefined) => void;
|
|
30
|
+
}>;
|
|
31
|
+
/**
|
|
32
|
+
* The state every leave guard shares. `when` defaults to whether anything
|
|
33
|
+
* reports unsaved changes.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* const guard = leaveGuardOf(useLeaveGuardCore(isDirty));
|
|
37
|
+
*/
|
|
38
|
+
export declare const useLeaveGuardCore: (when: boolean | undefined) => LeaveGuardCore;
|
|
39
|
+
/**
|
|
40
|
+
* The guard over `core`, answering for `routed` — a leave a router holds — or
|
|
41
|
+
* else the one handed to `hold`.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* const guard = leaveGuardOf(core, blocker.status === "blocked" ? { proceed: blocker.proceed, stay: blocker.reset } : undefined);
|
|
45
|
+
*/
|
|
46
|
+
export declare const leaveGuardOf: (core: LeaveGuardCore, routed?: HeldLeave) => LeaveGuard;
|
|
47
|
+
/**
|
|
48
|
+
* Guards against leaving while `when`, such as a form with unsaved changes,
|
|
49
|
+
* without knowing the router: the browser asks before a reload or a close, and
|
|
50
|
+
* whatever blocks an in-app leave hands it to `hold`. `when` defaults to
|
|
51
|
+
* whether anything reports unsaved changes, which every `Form.Root` does.
|
|
52
|
+
* `@igne-agency/react-web-ui/unsaved-changes/tanstack-router` wires it to
|
|
53
|
+
* TanStack Router.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* const guard = useLeaveGuard();
|
|
57
|
+
* const close = () => (guard.blocking ? guard.hold(() => setOpen(false)) : setOpen(false));
|
|
58
|
+
* <LeaveGuardDialog guard={guard} title="Discard your changes?" confirmLabel="Discard" cancelLabel="Keep editing" />
|
|
59
|
+
*/
|
|
60
|
+
export declare const useLeaveGuard: (when?: boolean) => LeaveGuard;
|
|
61
|
+
/**
|
|
62
|
+
* What a `LeaveGuardDialog` takes: the guard it answers for and the question's
|
|
63
|
+
* copy. `tone` defaults to `"danger"`, since leaving loses the changes.
|
|
64
|
+
*/
|
|
65
|
+
export type LeaveGuardDialogProps = Pick<ConfirmDialogProps, "title" | "description" | "confirmLabel" | "cancelLabel" | "tone"> & Readonly<{
|
|
66
|
+
guard: LeaveGuard;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* The question a guarded page asks when it is left: a `ConfirmDialog` that
|
|
70
|
+
* lets the held leave through or stays.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* <LeaveGuardDialog
|
|
74
|
+
* guard={guard}
|
|
75
|
+
* title="Discard your changes?"
|
|
76
|
+
* confirmLabel="Discard"
|
|
77
|
+
* cancelLabel="Keep editing"
|
|
78
|
+
* />
|
|
79
|
+
*/
|
|
80
|
+
export declare const LeaveGuardDialog: ({ guard, tone, ...copy }: LeaveGuardDialogProps) => ReactNode;
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { ConfirmDialog } from "../../components/confirm-dialog/confirm-dialog.js";
|
|
2
|
+
import { useBeforeUnload } from "./before-unload.js";
|
|
3
|
+
import { useUnsavedChanges } from "./registry.js";
|
|
4
|
+
import { c } from "react/compiler-runtime";
|
|
5
|
+
import { useRef, useState } from "react";
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
// src/lib/unsaved-changes/leave-guard.tsx
|
|
8
|
+
var STAY = () => void 0;
|
|
9
|
+
/**
|
|
10
|
+
* The state every leave guard shares. `when` defaults to whether anything
|
|
11
|
+
* reports unsaved changes.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const guard = leaveGuardOf(useLeaveGuardCore(isDirty));
|
|
15
|
+
*/
|
|
16
|
+
var useLeaveGuardCore = (when) => {
|
|
17
|
+
const $ = c(6);
|
|
18
|
+
const unsaved = useUnsavedChanges();
|
|
19
|
+
const guarding = when ?? unsaved;
|
|
20
|
+
const [held, setHeld] = useState(void 0);
|
|
21
|
+
const [leaving, setLeaving] = useState(false);
|
|
22
|
+
const agreed = useRef(false);
|
|
23
|
+
if (leaving && !guarding) setLeaving(false);
|
|
24
|
+
const t0 = guarding && !leaving;
|
|
25
|
+
let t1;
|
|
26
|
+
let t2;
|
|
27
|
+
let t3;
|
|
28
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
29
|
+
t1 = (proceed) => {
|
|
30
|
+
agreed.current = false;
|
|
31
|
+
setHeld({
|
|
32
|
+
proceed,
|
|
33
|
+
stay: STAY
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
t2 = () => {
|
|
37
|
+
agreed.current = true;
|
|
38
|
+
};
|
|
39
|
+
t3 = (leave) => {
|
|
40
|
+
const proceeding = agreed.current;
|
|
41
|
+
agreed.current = false;
|
|
42
|
+
setHeld(void 0);
|
|
43
|
+
if (leave === void 0) return;
|
|
44
|
+
if (proceeding) {
|
|
45
|
+
setLeaving(true);
|
|
46
|
+
leave.proceed();
|
|
47
|
+
} else leave.stay();
|
|
48
|
+
};
|
|
49
|
+
$[0] = t1;
|
|
50
|
+
$[1] = t2;
|
|
51
|
+
$[2] = t3;
|
|
52
|
+
} else {
|
|
53
|
+
t1 = $[0];
|
|
54
|
+
t2 = $[1];
|
|
55
|
+
t3 = $[2];
|
|
56
|
+
}
|
|
57
|
+
let t4;
|
|
58
|
+
if ($[3] !== held || $[4] !== t0) {
|
|
59
|
+
t4 = {
|
|
60
|
+
blocking: t0,
|
|
61
|
+
held,
|
|
62
|
+
hold: t1,
|
|
63
|
+
agree: t2,
|
|
64
|
+
settle: t3
|
|
65
|
+
};
|
|
66
|
+
$[3] = held;
|
|
67
|
+
$[4] = t0;
|
|
68
|
+
$[5] = t4;
|
|
69
|
+
} else t4 = $[5];
|
|
70
|
+
return t4;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* The guard over `core`, answering for `routed` — a leave a router holds — or
|
|
74
|
+
* else the one handed to `hold`.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const guard = leaveGuardOf(core, blocker.status === "blocked" ? { proceed: blocker.proceed, stay: blocker.reset } : undefined);
|
|
78
|
+
*/
|
|
79
|
+
var leaveGuardOf = (core, routed) => {
|
|
80
|
+
const leave = routed ?? core.held;
|
|
81
|
+
return {
|
|
82
|
+
blocking: core.blocking,
|
|
83
|
+
asking: leave !== void 0,
|
|
84
|
+
hold: core.hold,
|
|
85
|
+
agree: core.agree,
|
|
86
|
+
settle: () => core.settle(leave)
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Guards against leaving while `when`, such as a form with unsaved changes,
|
|
91
|
+
* without knowing the router: the browser asks before a reload or a close, and
|
|
92
|
+
* whatever blocks an in-app leave hands it to `hold`. `when` defaults to
|
|
93
|
+
* whether anything reports unsaved changes, which every `Form.Root` does.
|
|
94
|
+
* `@igne-agency/react-web-ui/unsaved-changes/tanstack-router` wires it to
|
|
95
|
+
* TanStack Router.
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* const guard = useLeaveGuard();
|
|
99
|
+
* const close = () => (guard.blocking ? guard.hold(() => setOpen(false)) : setOpen(false));
|
|
100
|
+
* <LeaveGuardDialog guard={guard} title="Discard your changes?" confirmLabel="Discard" cancelLabel="Keep editing" />
|
|
101
|
+
*/
|
|
102
|
+
var useLeaveGuard = (when) => {
|
|
103
|
+
const $ = c(2);
|
|
104
|
+
const t0 = useLeaveGuardCore(when);
|
|
105
|
+
let t1;
|
|
106
|
+
if ($[0] !== t0) {
|
|
107
|
+
t1 = leaveGuardOf(t0);
|
|
108
|
+
$[0] = t0;
|
|
109
|
+
$[1] = t1;
|
|
110
|
+
} else t1 = $[1];
|
|
111
|
+
const guard = t1;
|
|
112
|
+
useBeforeUnload(guard.blocking);
|
|
113
|
+
return guard;
|
|
114
|
+
};
|
|
115
|
+
/**
|
|
116
|
+
* The question a guarded page asks when it is left: a `ConfirmDialog` that
|
|
117
|
+
* lets the held leave through or stays.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* <LeaveGuardDialog
|
|
121
|
+
* guard={guard}
|
|
122
|
+
* title="Discard your changes?"
|
|
123
|
+
* confirmLabel="Discard"
|
|
124
|
+
* cancelLabel="Keep editing"
|
|
125
|
+
* />
|
|
126
|
+
*/
|
|
127
|
+
var LeaveGuardDialog = (t0) => {
|
|
128
|
+
const $ = c(12);
|
|
129
|
+
let copy;
|
|
130
|
+
let guard;
|
|
131
|
+
let t1;
|
|
132
|
+
if ($[0] !== t0) {
|
|
133
|
+
({guard, tone: t1, ...copy} = t0);
|
|
134
|
+
$[0] = t0;
|
|
135
|
+
$[1] = copy;
|
|
136
|
+
$[2] = guard;
|
|
137
|
+
$[3] = t1;
|
|
138
|
+
} else {
|
|
139
|
+
copy = $[1];
|
|
140
|
+
guard = $[2];
|
|
141
|
+
t1 = $[3];
|
|
142
|
+
}
|
|
143
|
+
const tone = t1 === void 0 ? "danger" : t1;
|
|
144
|
+
let t2;
|
|
145
|
+
if ($[4] !== guard) {
|
|
146
|
+
t2 = (open) => {
|
|
147
|
+
if (!open) guard.settle();
|
|
148
|
+
};
|
|
149
|
+
$[4] = guard;
|
|
150
|
+
$[5] = t2;
|
|
151
|
+
} else t2 = $[5];
|
|
152
|
+
let t3;
|
|
153
|
+
if ($[6] !== copy || $[7] !== guard.agree || $[8] !== guard.asking || $[9] !== t2 || $[10] !== tone) {
|
|
154
|
+
t3 = /* @__PURE__ */ jsx(ConfirmDialog, {
|
|
155
|
+
...copy,
|
|
156
|
+
open: guard.asking,
|
|
157
|
+
onOpenChange: t2,
|
|
158
|
+
onConfirm: guard.agree,
|
|
159
|
+
tone
|
|
160
|
+
});
|
|
161
|
+
$[6] = copy;
|
|
162
|
+
$[7] = guard.agree;
|
|
163
|
+
$[8] = guard.asking;
|
|
164
|
+
$[9] = t2;
|
|
165
|
+
$[10] = tone;
|
|
166
|
+
$[11] = t3;
|
|
167
|
+
} else t3 = $[11];
|
|
168
|
+
return t3;
|
|
169
|
+
};
|
|
170
|
+
export { LeaveGuardDialog, leaveGuardOf, useLeaveGuard, useLeaveGuardCore };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { AnyFormState } from "@tanstack/react-form";
|
|
2
|
+
/**
|
|
3
|
+
* Decides from a form's live state whether leaving would lose unsaved
|
|
4
|
+
* changes. `Form.Root` reports into the leave guards while it returns true.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* const policy: LeaveGuardPolicy = state => state.isDirty && !state.isSubmitted;
|
|
8
|
+
*/
|
|
9
|
+
export type LeaveGuardPolicy = (state: AnyFormState) => boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Guards while the form's values were edited away from their defaults and are
|
|
12
|
+
* not being submitted. The default for `Form.Root`.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* <Form.Root form={form} leaveGuard={whenDirty}>…</Form.Root>
|
|
16
|
+
*/
|
|
17
|
+
export declare const whenDirty: LeaveGuardPolicy;
|
|
18
|
+
/**
|
|
19
|
+
* Never guards, for a form whose edits need not survive leaving.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* <Form.Root form={form} leaveGuard={never}>…</Form.Root>
|
|
23
|
+
*/
|
|
24
|
+
export declare const never: LeaveGuardPolicy;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// src/lib/unsaved-changes/policy.ts
|
|
2
|
+
/**
|
|
3
|
+
* Guards while the form's values were edited away from their defaults and are
|
|
4
|
+
* not being submitted. The default for `Form.Root`.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* <Form.Root form={form} leaveGuard={whenDirty}>…</Form.Root>
|
|
8
|
+
*/
|
|
9
|
+
var whenDirty = (state) => state.isDirty && !state.isDefaultValue && !state.isSubmitting;
|
|
10
|
+
/**
|
|
11
|
+
* Never guards, for a form whose edits need not survive leaving.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* <Form.Root form={form} leaveGuard={never}>…</Form.Root>
|
|
15
|
+
*/
|
|
16
|
+
var never = () => false;
|
|
17
|
+
export { never, whenDirty };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/** A record of what has unsaved changes right now, which a leave guard reads. */
|
|
2
|
+
export type UnsavedChangesRegistry = Readonly<{
|
|
3
|
+
/** Records one source of unsaved changes, until the returned function is called. */
|
|
4
|
+
register: () => () => void;
|
|
5
|
+
/** Whether any source has unsaved changes. */
|
|
6
|
+
hasUnsavedChanges: () => boolean;
|
|
7
|
+
/** Calls `listener` whenever that answer may have changed, until the returned function is called. */
|
|
8
|
+
subscribe: (listener: () => void) => () => void;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Creates an empty registry of unsaved changes.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const registry = createUnsavedChangesRegistry();
|
|
15
|
+
* const unregister = registry.register();
|
|
16
|
+
* registry.hasUnsavedChanges(); // true
|
|
17
|
+
* unregister();
|
|
18
|
+
* registry.hasUnsavedChanges(); // false
|
|
19
|
+
*/
|
|
20
|
+
export declare const createUnsavedChangesRegistry: () => UnsavedChangesRegistry;
|
|
21
|
+
/**
|
|
22
|
+
* Reports unsaved changes to the page's leave guards while `dirty`, and stops
|
|
23
|
+
* once it is not or the caller unmounts. `Form.Root` reports its form.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* useReportUnsavedChanges(editor.isDirty);
|
|
27
|
+
*/
|
|
28
|
+
export declare const useReportUnsavedChanges: (dirty: boolean) => void;
|
|
29
|
+
/**
|
|
30
|
+
* Whether anything on the page reports unsaved changes, such as a `Form.Root`
|
|
31
|
+
* whose form was edited and not submitted.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const unsaved = useUnsavedChanges();
|
|
35
|
+
*/
|
|
36
|
+
export declare const useUnsavedChanges: () => boolean;
|