@k8ordo/ui 2.3.1 → 4.0.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/README.md +75 -183
- package/dist/catalog/icon-map.d.mts +108 -0
- package/dist/catalog/icon-map.mjs +212 -0
- package/dist/catalog/icon-names.d.mts +1 -0
- package/dist/catalog/icon-names.mjs +108 -0
- package/dist/catalog/index.d.mts +1289 -0
- package/dist/catalog/index.mjs +419 -0
- package/dist/catalog/render.css +34 -0
- package/dist/catalog/render.d.mts +72 -0
- package/dist/catalog/render.mjs +631 -0
- package/dist/catalog/render.module.mjs +11 -0
- package/dist/{integrations/_shared → catalog}/schemas.d.mts +550 -307
- package/dist/{integrations/_shared → catalog}/schemas.mjs +191 -184
- package/dist/catalog/to-tree.d.mts +4 -0
- package/dist/catalog/to-tree.mjs +17 -0
- package/dist/components/_internal/checked-values.d.mts +1 -0
- package/dist/components/_internal/checked-values.mjs +5 -0
- package/dist/components/_internal/field-message.css +25 -0
- package/dist/components/_internal/field-message.d.mts +10 -0
- package/dist/components/_internal/field-message.mjs +22 -0
- package/dist/components/_internal/field-message.module.mjs +9 -0
- package/dist/components/_internal/focus-ring.css +1 -1
- package/dist/components/_internal/high-contrast.css +1 -0
- package/dist/components/{observers/in-view → _internal}/in-view.mjs +1 -1
- package/dist/components/{observers/resize → _internal}/resize.mjs +1 -1
- package/dist/components/ai/_internal/attachment-preview.mjs +3 -3
- package/dist/components/ai/_internal/collapsible.mjs +2 -2
- package/dist/components/ai/attachment/attachment.d.mts +1 -1
- package/dist/components/ai/attachment/index.d.mts +1 -1
- package/dist/components/ai/conversation/conversation.mjs +4 -4
- package/dist/components/ai/index.d.mts +2 -2
- package/dist/components/ai/message/index.d.mts +2 -2
- package/dist/components/ai/message/message.d.mts +2 -2
- package/dist/components/ai/message/message.mjs +14 -12
- package/dist/components/ai/prompt-input/prompt-input.mjs +5 -5
- package/dist/components/ai/reasoning/reasoning.mjs +1 -1
- package/dist/components/ai/source/index.d.mts +2 -2
- package/dist/components/ai/source/source.d.mts +2 -2
- package/dist/components/ai/source/source.mjs +2 -2
- package/dist/components/ai/tool-invocation/approval-bar.mjs +11 -22
- package/dist/components/ai/tool-invocation/tool-invocation.d.mts +2 -2
- package/dist/components/ai/tool-invocation/tool-invocation.mjs +2 -1
- package/dist/components/buttons/button/button.css +1 -1
- package/dist/components/buttons/button/button.d.mts +34 -37
- package/dist/components/buttons/button/button.mjs +37 -24
- package/dist/components/buttons/button/button.module.mjs +0 -1
- package/dist/components/buttons/button/index.d.mts +2 -2
- package/dist/components/buttons/copy-button/copy-button.mjs +6 -4
- package/dist/components/buttons/icon-button/icon-button.css +3 -3
- package/dist/components/buttons/icon-button/icon-button.d.mts +37 -43
- package/dist/components/buttons/icon-button/icon-button.mjs +73 -63
- package/dist/components/buttons/icon-button/icon-button.module.mjs +2 -2
- package/dist/components/buttons/icon-button/index.d.mts +2 -2
- package/dist/components/buttons/toolbar/toolbar.css +5 -1
- package/dist/components/buttons/toolbar/toolbar.mjs +1 -1
- package/dist/components/data-display/accordion/accordion-button.d.mts +4 -1
- package/dist/components/data-display/accordion/accordion-button.mjs +5 -5
- package/dist/components/data-display/accordion/index.d.mts +3 -3
- package/dist/components/data-display/card/card-action.d.mts +6 -0
- package/dist/components/data-display/card/card-action.mjs +21 -0
- package/dist/components/data-display/card/card.css +24 -0
- package/dist/components/data-display/card/card.d.mts +26 -3
- package/dist/components/data-display/card/card.mjs +46 -6
- package/dist/components/data-display/card/card.module.mjs +4 -1
- package/dist/components/data-display/card/index.d.mts +2 -2
- package/dist/components/data-display/carousel/carousel.mjs +3 -3
- package/dist/components/data-display/code/code.css +4 -0
- package/dist/components/data-display/code-block/code-block.mjs +1 -1
- package/dist/components/data-display/data-table/data-table.css +0 -3
- package/dist/components/data-display/data-table/data-table.mjs +25 -26
- package/dist/components/data-display/tree/tree.d.mts +1 -1
- package/dist/components/data-display/tree/tree.mjs +7 -6
- package/dist/components/feedback/alert/alert.d.mts +2 -7
- package/dist/components/feedback/alert/alert.mjs +12 -11
- package/dist/components/feedback/alert/index.d.mts +2 -2
- package/dist/components/feedback/callout/callout.mjs +3 -3
- package/dist/components/feedback/progress/progress.mjs +1 -1
- package/dist/components/feedback/toast/context.d.mts +4 -5
- package/dist/components/feedback/toast/index.d.mts +2 -2
- package/dist/components/feedback/toast/provider.d.mts +7 -2
- package/dist/components/feedback/toast/provider.mjs +7 -2
- package/dist/components/feedback/toast/toast.d.mts +2 -3
- package/dist/components/form/autocomplete/autocomplete.d.mts +2 -2
- package/dist/components/form/autocomplete/autocomplete.mjs +15 -12
- package/dist/components/form/calendar/calendar.mjs +4 -6
- package/dist/components/form/checkbox/checkbox.d.mts +3 -1
- package/dist/components/form/checkbox/checkbox.mjs +45 -45
- package/dist/components/form/checkbox-card/checkbox-card.d.mts +3 -2
- package/dist/components/form/checkbox-card/checkbox-card.mjs +13 -6
- package/dist/components/form/checkbox-group/checkbox-group.d.mts +15 -20
- package/dist/components/form/checkbox-group/checkbox-group.mjs +18 -26
- package/dist/components/form/checkbox-group/index.d.mts +2 -34
- package/dist/components/form/checkbox-group/index.mjs +1 -8
- package/dist/components/form/color-picker/color-picker.css +3 -5
- package/dist/components/form/color-picker/color-picker.d.mts +0 -1
- package/dist/components/form/color-picker/color-picker.mjs +4 -4
- package/dist/components/form/combobox/combobox.d.mts +0 -1
- package/dist/components/form/combobox/combobox.mjs +9 -8
- package/dist/components/form/date-picker/date-picker.css +0 -5
- package/dist/components/form/date-picker/date-picker.mjs +22 -23
- package/dist/components/form/file-field/file-field.d.mts +6 -3
- package/dist/components/form/file-field/file-field.mjs +42 -19
- package/dist/components/form/file-field/index.d.mts +4 -1
- package/dist/components/form/form/form.mjs +0 -1
- package/dist/components/form/form-control/form-control.css +0 -15
- package/dist/components/form/form-control/form-control.d.mts +3 -4
- package/dist/components/form/form-control/form-control.mjs +44 -46
- package/dist/components/form/form-control/form-control.module.mjs +0 -3
- package/dist/components/form/number-field/number-field.d.mts +2 -2
- package/dist/components/form/number-field/number-field.mjs +13 -52
- package/dist/components/form/password-input/password-input.mjs +3 -2
- package/dist/components/form/radio/radio.mjs +4 -2
- package/dist/components/form/radio-card/radio-card.mjs +9 -2
- package/dist/components/form/range-slider/range-slider.d.mts +4 -2
- package/dist/components/form/range-slider/range-slider.mjs +2 -4
- package/dist/components/form/select/select.css +6 -4
- package/dist/components/form/select/select.d.mts +5 -0
- package/dist/components/form/select/select.mjs +10 -7
- package/dist/components/form/slider/slider.d.mts +2 -2
- package/dist/components/form/slider/slider.mjs +3 -6
- package/dist/components/form/switch/switch.d.mts +3 -0
- package/dist/components/form/switch/switch.mjs +43 -31
- package/dist/components/form/text-field/index.d.mts +2 -2
- package/dist/components/form/text-field/text-field.css +4 -0
- package/dist/components/form/text-field/text-field.d.mts +1 -1
- package/dist/components/form/textarea/textarea.d.mts +0 -1
- package/dist/components/form/textarea/textarea.mjs +1 -1
- package/dist/components/icons/alert.d.mts +6 -0
- package/dist/components/icons/alert.mjs +17 -0
- package/dist/components/icons/{vertical-writing.d.mts → arrow-down.d.mts} +1 -1
- package/dist/components/icons/arrow-down.mjs +8 -0
- package/dist/components/icons/arrow-left.d.mts +3 -0
- package/dist/components/icons/arrow-left.mjs +8 -0
- package/dist/components/icons/arrow-right.d.mts +3 -0
- package/dist/components/icons/arrow-right.mjs +8 -0
- package/dist/components/icons/{twitter.d.mts → arrow-up.d.mts} +1 -1
- package/dist/components/icons/arrow-up.mjs +8 -0
- package/dist/components/icons/base.d.mts +0 -1
- package/dist/components/icons/base.mjs +1 -2
- package/dist/components/icons/{qiita.d.mts → bell.d.mts} +1 -1
- package/dist/components/icons/bell.mjs +8 -0
- package/dist/components/icons/{github-mark.d.mts → blend.d.mts} +1 -1
- package/dist/components/icons/blend.mjs +16 -0
- package/dist/components/icons/book-text.d.mts +3 -0
- package/dist/components/icons/book-text.mjs +8 -0
- package/dist/components/icons/bookmark.d.mts +3 -0
- package/dist/components/icons/bookmark.mjs +8 -0
- package/dist/components/icons/bot-message.d.mts +3 -0
- package/dist/components/icons/bot-message.mjs +8 -0
- package/dist/components/icons/bot.d.mts +3 -0
- package/dist/components/icons/bot.mjs +14 -0
- package/dist/components/icons/calendar.d.mts +3 -0
- package/dist/components/icons/calendar.mjs +14 -0
- package/dist/components/icons/check.d.mts +3 -0
- package/dist/components/icons/check.mjs +8 -0
- package/dist/components/icons/chevron-down.d.mts +3 -0
- package/dist/components/icons/chevron-down.mjs +8 -0
- package/dist/components/icons/chevron-left.d.mts +3 -0
- package/dist/components/icons/chevron-left.mjs +8 -0
- package/dist/components/icons/chevron-right.d.mts +3 -0
- package/dist/components/icons/chevron-right.mjs +8 -0
- package/dist/components/icons/chevron-up.d.mts +3 -0
- package/dist/components/icons/chevron-up.mjs +8 -0
- package/dist/components/icons/chevron.d.mts +6 -0
- package/dist/components/icons/chevron.mjs +17 -0
- package/dist/components/icons/chevrons-up-down.d.mts +3 -0
- package/dist/components/icons/chevrons-up-down.mjs +8 -0
- package/dist/components/icons/circle-alert.d.mts +3 -0
- package/dist/components/icons/circle-alert.mjs +12 -0
- package/dist/components/icons/circle-check.d.mts +3 -0
- package/dist/components/icons/circle-check.mjs +12 -0
- package/dist/components/icons/circle-help.d.mts +3 -0
- package/dist/components/icons/circle-help.mjs +12 -0
- package/dist/components/icons/circle-x.d.mts +3 -0
- package/dist/components/icons/circle-x.mjs +12 -0
- package/dist/components/icons/clipboard-check.d.mts +3 -0
- package/dist/components/icons/clipboard-check.mjs +18 -0
- package/dist/components/icons/clock.d.mts +3 -0
- package/dist/components/icons/clock.mjs +12 -0
- package/dist/components/icons/code.d.mts +3 -0
- package/dist/components/icons/code.mjs +8 -0
- package/dist/components/icons/color-scale.mjs +18 -30
- package/dist/components/icons/contrast.d.mts +3 -0
- package/dist/components/icons/contrast.mjs +15 -0
- package/dist/components/icons/copy.d.mts +3 -0
- package/dist/components/icons/copy.mjs +14 -0
- package/dist/components/icons/download.d.mts +3 -0
- package/dist/components/icons/download.mjs +8 -0
- package/dist/components/icons/ellipsis-vertical.d.mts +3 -0
- package/dist/components/icons/ellipsis-vertical.mjs +27 -0
- package/dist/components/icons/ellipsis.d.mts +3 -0
- package/dist/components/icons/ellipsis.mjs +27 -0
- package/dist/components/icons/external-link.d.mts +3 -0
- package/dist/components/icons/external-link.mjs +8 -0
- package/dist/components/icons/eye-closed.d.mts +3 -0
- package/dist/components/icons/eye-closed.mjs +8 -0
- package/dist/components/icons/eye.d.mts +3 -0
- package/dist/components/icons/eye.mjs +12 -0
- package/dist/components/icons/file-text.d.mts +3 -0
- package/dist/components/icons/file-text.mjs +12 -0
- package/dist/components/icons/file.d.mts +3 -0
- package/dist/components/icons/file.mjs +8 -0
- package/dist/components/icons/filter.d.mts +3 -0
- package/dist/components/icons/filter.mjs +8 -0
- package/dist/components/icons/flask.d.mts +3 -0
- package/dist/components/icons/flask.mjs +8 -0
- package/dist/components/icons/folder-open.d.mts +3 -0
- package/dist/components/icons/folder-open.mjs +8 -0
- package/dist/components/icons/folder.d.mts +3 -0
- package/dist/components/icons/folder.mjs +8 -0
- package/dist/components/icons/git-fork.d.mts +3 -0
- package/dist/components/icons/git-fork.mjs +25 -0
- package/dist/components/icons/git-pull-request.d.mts +3 -0
- package/dist/components/icons/git-pull-request.mjs +20 -0
- package/dist/components/icons/globe.d.mts +3 -0
- package/dist/components/icons/globe.mjs +12 -0
- package/dist/components/icons/grid.d.mts +3 -0
- package/dist/components/icons/grid.mjs +37 -0
- package/dist/components/icons/grip-vertical.d.mts +3 -0
- package/dist/components/icons/grip-vertical.mjs +45 -0
- package/dist/components/icons/heart.d.mts +3 -0
- package/dist/components/icons/heart.mjs +8 -0
- package/dist/components/icons/history.d.mts +3 -0
- package/dist/components/icons/history.mjs +8 -0
- package/dist/components/icons/home.d.mts +3 -0
- package/dist/components/icons/home.mjs +8 -0
- package/dist/components/icons/image.d.mts +3 -0
- package/dist/components/icons/image.mjs +22 -0
- package/dist/components/icons/index.d.mts +107 -9
- package/dist/components/icons/index.mjs +107 -8
- package/dist/components/icons/info.d.mts +3 -0
- package/dist/components/icons/info.mjs +12 -0
- package/dist/components/icons/lightbulb.d.mts +3 -0
- package/dist/components/icons/lightbulb.mjs +8 -0
- package/dist/components/icons/line-icon.d.mts +3 -0
- package/dist/components/icons/line-icon.mjs +17 -0
- package/dist/components/icons/link.d.mts +3 -0
- package/dist/components/icons/link.mjs +11 -0
- package/dist/components/icons/list.d.mts +3 -0
- package/dist/components/icons/list.mjs +8 -0
- package/dist/components/icons/lock-open.d.mts +3 -0
- package/dist/components/icons/lock-open.mjs +14 -0
- package/dist/components/icons/lock.d.mts +3 -0
- package/dist/components/icons/lock.mjs +14 -0
- package/dist/components/icons/log-in.d.mts +3 -0
- package/dist/components/icons/log-in.mjs +8 -0
- package/dist/components/icons/log-out.d.mts +3 -0
- package/dist/components/icons/log-out.mjs +8 -0
- package/dist/components/icons/mail.d.mts +3 -0
- package/dist/components/icons/mail.mjs +14 -0
- package/dist/components/icons/map-pin.d.mts +3 -0
- package/dist/components/icons/map-pin.mjs +12 -0
- package/dist/components/icons/maximize.d.mts +3 -0
- package/dist/components/icons/maximize.mjs +8 -0
- package/dist/components/icons/menu.d.mts +3 -0
- package/dist/components/icons/menu.mjs +8 -0
- package/dist/components/icons/message-circle.d.mts +3 -0
- package/dist/components/icons/message-circle.mjs +8 -0
- package/dist/components/icons/minimize.d.mts +3 -0
- package/dist/components/icons/minimize.mjs +8 -0
- package/dist/components/icons/minus.d.mts +3 -0
- package/dist/components/icons/minus.mjs +8 -0
- package/dist/components/icons/monitor.d.mts +3 -0
- package/dist/components/icons/monitor.mjs +14 -0
- package/dist/components/icons/moon.d.mts +3 -0
- package/dist/components/icons/moon.mjs +8 -0
- package/dist/components/icons/package.d.mts +3 -0
- package/dist/components/icons/package.mjs +8 -0
- package/dist/components/icons/paint-bucket.d.mts +3 -0
- package/dist/components/icons/paint-bucket.mjs +8 -0
- package/dist/components/icons/palette.d.mts +3 -0
- package/dist/components/icons/palette.mjs +8 -0
- package/dist/components/icons/panel-left.d.mts +3 -0
- package/dist/components/icons/panel-left.mjs +14 -0
- package/dist/components/icons/paperclip.d.mts +3 -0
- package/dist/components/icons/paperclip.mjs +11 -0
- package/dist/components/icons/pause.d.mts +3 -0
- package/dist/components/icons/pause.mjs +20 -0
- package/dist/components/icons/pencil.d.mts +3 -0
- package/dist/components/icons/pencil.mjs +8 -0
- package/dist/components/icons/pin.d.mts +3 -0
- package/dist/components/icons/pin.mjs +11 -0
- package/dist/components/icons/play.d.mts +3 -0
- package/dist/components/icons/play.mjs +8 -0
- package/dist/components/icons/plus.d.mts +3 -0
- package/dist/components/icons/plus.mjs +8 -0
- package/dist/components/icons/presentation.d.mts +3 -0
- package/dist/components/icons/presentation.mjs +8 -0
- package/dist/components/icons/redo.d.mts +3 -0
- package/dist/components/icons/redo.mjs +8 -0
- package/dist/components/icons/refresh.d.mts +3 -0
- package/dist/components/icons/refresh.mjs +8 -0
- package/dist/components/icons/rocket.d.mts +3 -0
- package/dist/components/icons/rocket.mjs +19 -0
- package/dist/components/icons/rss.d.mts +3 -0
- package/dist/components/icons/rss.mjs +13 -0
- package/dist/components/icons/search.d.mts +3 -0
- package/dist/components/icons/search.mjs +12 -0
- package/dist/components/icons/send.d.mts +3 -0
- package/dist/components/icons/send.mjs +8 -0
- package/dist/components/icons/settings.d.mts +3 -0
- package/dist/components/icons/settings.mjs +12 -0
- package/dist/components/icons/share.d.mts +3 -0
- package/dist/components/icons/share.mjs +25 -0
- package/dist/components/icons/shield-check.d.mts +3 -0
- package/dist/components/icons/shield-check.mjs +8 -0
- package/dist/components/icons/smile.d.mts +3 -0
- package/dist/components/icons/smile.mjs +12 -0
- package/dist/components/icons/sparkles.d.mts +3 -0
- package/dist/components/icons/sparkles.mjs +8 -0
- package/dist/components/icons/square.d.mts +3 -0
- package/dist/components/icons/square.mjs +14 -0
- package/dist/components/icons/squircle.d.mts +3 -0
- package/dist/components/icons/squircle.mjs +8 -0
- package/dist/components/icons/star.d.mts +3 -0
- package/dist/components/icons/star.mjs +8 -0
- package/dist/components/icons/sun.d.mts +3 -0
- package/dist/components/icons/sun.mjs +12 -0
- package/dist/components/icons/table.d.mts +3 -0
- package/dist/components/icons/table.mjs +14 -0
- package/dist/components/icons/tag.d.mts +3 -0
- package/dist/components/icons/tag.mjs +8 -0
- package/dist/components/icons/text-horizontal.d.mts +3 -0
- package/dist/components/icons/text-horizontal.mjs +8 -0
- package/dist/components/icons/text-vertical.d.mts +3 -0
- package/dist/components/icons/text-vertical.mjs +8 -0
- package/dist/components/icons/thumbs-down.d.mts +3 -0
- package/dist/components/icons/thumbs-down.mjs +8 -0
- package/dist/components/icons/thumbs-up.d.mts +3 -0
- package/dist/components/icons/thumbs-up.mjs +8 -0
- package/dist/components/icons/trash.d.mts +3 -0
- package/dist/components/icons/trash.mjs +8 -0
- package/dist/components/icons/triangle-alert.d.mts +3 -0
- package/dist/components/icons/triangle-alert.mjs +8 -0
- package/dist/components/icons/undo.d.mts +3 -0
- package/dist/components/icons/undo.mjs +8 -0
- package/dist/components/icons/upload.d.mts +3 -0
- package/dist/components/icons/upload.mjs +8 -0
- package/dist/components/icons/user.d.mts +3 -0
- package/dist/components/icons/user.mjs +12 -0
- package/dist/components/icons/users.d.mts +3 -0
- package/dist/components/icons/users.mjs +12 -0
- package/dist/components/icons/x.d.mts +3 -0
- package/dist/components/icons/x.mjs +8 -0
- package/dist/components/index.d.mts +58 -76
- package/dist/components/index.mjs +13 -27
- package/dist/components/layout/resizable-panels/resizable-panels.mjs +3 -3
- package/dist/components/navigation/anchor/anchor.css +3 -3
- package/dist/components/navigation/anchor/anchor.mjs +20 -7
- package/dist/components/navigation/anchor/anchor.module.mjs +1 -1
- package/dist/components/navigation/breadcrumb/breadcrumb.d.mts +6 -4
- package/dist/components/navigation/breadcrumb/breadcrumb.mjs +3 -2
- package/dist/components/navigation/pagination/pagination.d.mts +2 -2
- package/dist/components/navigation/pagination/pagination.mjs +3 -3
- package/dist/components/navigation/side-nav/side-nav.mjs +1 -1
- package/dist/components/navigation/stepper/stepper.mjs +3 -3
- package/dist/components/navigation/tabs/index.d.mts +10 -5
- package/dist/components/navigation/tabs/tabs.d.mts +11 -6
- package/dist/components/navigation/tabs/tabs.mjs +24 -27
- package/dist/components/overlays/_internal/modal-header.css +38 -0
- package/dist/components/overlays/_internal/modal-header.d.mts +7 -0
- package/dist/components/overlays/_internal/modal-header.mjs +32 -0
- package/dist/components/overlays/_internal/modal-header.module.mjs +10 -0
- package/dist/components/overlays/command-palette/command-palette.d.mts +2 -2
- package/dist/components/overlays/command-palette/command-palette.mjs +9 -8
- package/dist/components/overlays/context-menu/context-menu.mjs +3 -3
- package/dist/components/overlays/context-menu/index.d.mts +27 -2
- package/dist/components/overlays/dialog/dialog.css +3 -21
- package/dist/components/overlays/dialog/dialog.d.mts +20 -9
- package/dist/components/overlays/dialog/dialog.mjs +35 -73
- package/dist/components/overlays/dialog/dialog.module.mjs +1 -3
- package/dist/components/overlays/dialog/index.d.mts +2 -15
- package/dist/components/overlays/dialog/index.mjs +1 -8
- package/dist/components/overlays/drawer/drawer.css +4 -26
- package/dist/components/overlays/drawer/drawer.d.mts +7 -2
- package/dist/components/overlays/drawer/drawer.mjs +24 -37
- package/dist/components/overlays/drawer/drawer.module.mjs +2 -6
- package/dist/components/overlays/dropdown-menu/dropdown-menu.d.mts +35 -5
- package/dist/components/overlays/dropdown-menu/dropdown-menu.mjs +30 -12
- package/dist/components/overlays/dropdown-menu/hooks.d.mts +1 -1
- package/dist/components/overlays/dropdown-menu/hooks.mjs +1 -1
- package/dist/components/overlays/dropdown-menu/index.d.mts +34 -4
- package/dist/components/overlays/dropdown-menu/shared.css +1 -0
- package/dist/components/overlays/dropdown-menu/sub-menu.mjs +4 -4
- package/dist/components/overlays/list-box/hooks.mjs +2 -2
- package/dist/components/overlays/list-box/index.d.mts +2 -25
- package/dist/components/overlays/list-box/index.mjs +1 -9
- package/dist/components/overlays/list-box/list-box.d.mts +11 -16
- package/dist/components/overlays/list-box/list-box.mjs +24 -16
- package/dist/components/overlays/modal/modal.d.mts +8 -7
- package/dist/components/overlays/modal/modal.mjs +23 -32
- package/dist/components/overlays/popover/anchor-positioning.d.mts +3 -16
- package/dist/components/overlays/popover/anchor-positioning.mjs +14 -6
- package/dist/components/overlays/popover/hooks.d.mts +0 -2
- package/dist/components/overlays/popover/hooks.mjs +0 -2
- package/dist/components/overlays/popover/index.d.mts +19 -2
- package/dist/components/overlays/popover/index.mjs +7 -2
- package/dist/components/overlays/popover/popover.css +6 -0
- package/dist/components/overlays/popover/popover.d.mts +15 -2
- package/dist/components/overlays/popover/popover.mjs +28 -13
- package/dist/components/overlays/popover/popover.module.mjs +2 -1
- package/dist/components/overlays/tooltip/bridge.css +1 -1
- package/dist/components/overlays/tooltip/tooltip.mjs +5 -5
- package/dist/helpers/index.mjs +1 -1
- package/dist/i18n/en.mjs +1 -2
- package/dist/i18n/index.d.mts +3 -4
- package/dist/i18n/index.mjs +1 -2
- package/dist/i18n/ja.mjs +1 -2
- package/dist/i18n/messages.d.mts +2 -4
- package/dist/i18n/usage.d.mts +2 -1
- package/dist/i18n/usage.mjs +3 -3
- package/dist/index.d.mts +30 -45
- package/dist/index.mjs +4 -18
- package/dist/internal/iso-date.mjs +1 -1
- package/dist/styles/index.css +79 -231
- package/dist/styles/tailwind.css +1 -4
- package/dist/styles/tokens.css +281 -0
- package/dist/styles/tokens.d.mts +1 -1
- package/dist/styles/tokens.mjs +1 -1
- package/dist/types/index.d.mts +2 -2
- package/dist/types/variables.d.mts +4 -2
- package/docs/GUIDE.md +145 -69
- package/docs/llms.txt +38 -11
- package/docs/props.generated.json +1414 -645
- package/docs/references/ai-chat.md +94 -44
- package/docs/references/color.md +15 -15
- package/docs/references/components.md +636 -504
- package/docs/references/generative-ui.md +378 -187
- package/docs/references/interaction-design.md +6 -5
- package/docs/references/spatial-design.md +8 -8
- package/docs/references/types.md +22 -25
- package/package.json +43 -73
- package/dist/components/ai/_internal/icons.d.mts +0 -6
- package/dist/components/ai/_internal/icons.mjs +0 -13
- package/dist/components/form/date-field/date-field.css +0 -31
- package/dist/components/form/date-field/date-field.d.mts +0 -7
- package/dist/components/form/date-field/date-field.mjs +0 -19
- package/dist/components/form/date-field/date-field.module.mjs +0 -4
- package/dist/components/form/date-field/index.d.mts +0 -2
- package/dist/components/form/date-field/index.mjs +0 -1
- package/dist/components/icons/browsers.d.mts +0 -6
- package/dist/components/icons/browsers.mjs +0 -890
- package/dist/components/icons/github-mark.mjs +0 -18
- package/dist/components/icons/logo.css +0 -17
- package/dist/components/icons/logo.d.mts +0 -4
- package/dist/components/icons/logo.mjs +0 -29
- package/dist/components/icons/logo.module.mjs +0 -8
- package/dist/components/icons/lucide-imports.d.mts +0 -67
- package/dist/components/icons/lucide-imports.mjs +0 -67
- package/dist/components/icons/lucide.d.mts +0 -67
- package/dist/components/icons/lucide.mjs +0 -255
- package/dist/components/icons/qiita.mjs +0 -27
- package/dist/components/icons/twitter.css +0 -9
- package/dist/components/icons/twitter.mjs +0 -20
- package/dist/components/icons/twitter.module.mjs +0 -4
- package/dist/components/icons/vertical-writing.mjs +0 -25
- package/dist/components/observers/in-view/index.d.mts +0 -2
- package/dist/components/observers/in-view/index.mjs +0 -1
- package/dist/components/observers/resize/index.d.mts +0 -2
- package/dist/components/observers/resize/index.mjs +0 -1
- package/dist/components/overlays/_internal/modal-dialog-context.d.mts +0 -11
- package/dist/components/overlays/_internal/modal-dialog-context.mjs +0 -12
- package/dist/components/providers/index.d.mts +0 -3
- package/dist/components/providers/index.mjs +0 -3
- package/dist/components/providers/portal-root.d.mts +0 -8
- package/dist/components/providers/portal-root.mjs +0 -11
- package/dist/components/providers/ui-provider.d.mts +0 -2
- package/dist/components/providers/ui-provider.mjs +0 -6
- package/dist/integrations/_shared/openui-defs.d.mts +0 -15
- package/dist/integrations/_shared/openui-defs.mjs +0 -230
- package/dist/integrations/_shared/renderers.css +0 -50
- package/dist/integrations/_shared/renderers.d.mts +0 -88
- package/dist/integrations/_shared/renderers.mjs +0 -936
- package/dist/integrations/_shared/renderers.module.mjs +0 -13
- package/dist/integrations/ai-sdk/index.d.mts +0 -3
- package/dist/integrations/ai-sdk/index.mjs +0 -1
- package/dist/integrations/ai-sdk/map-parts.d.mts +0 -44
- package/dist/integrations/ai-sdk/map-parts.mjs +0 -56
- package/dist/integrations/json-render/catalog.d.mts +0 -1155
- package/dist/integrations/json-render/catalog.mjs +0 -373
- package/dist/integrations/json-render/registry.d.mts +0 -26
- package/dist/integrations/json-render/registry.mjs +0 -192
- package/dist/integrations/openui/form-views.d.mts +0 -24
- package/dist/integrations/openui/form-views.mjs +0 -89
- package/dist/integrations/openui/library.d.mts +0 -202
- package/dist/integrations/openui/library.mjs +0 -83
- package/dist/integrations/openui/prompt.d.mts +0 -2
- package/dist/integrations/openui/prompt.mjs +0 -18
- /package/dist/components/{observers → _internal}/fragment-instance.d.mts +0 -0
- /package/dist/components/{observers/in-view → _internal}/in-view.d.mts +0 -0
- /package/dist/components/{observers/resize → _internal}/resize.d.mts +0 -0
|
@@ -6,67 +6,75 @@
|
|
|
6
6
|
// The stylesheet (required). In a Tailwind CSS 4 project, a CSS file
|
|
7
7
|
// imports 'tailwindcss' and then '@k8ordo/ui/tailwind.css' instead
|
|
8
8
|
import '@k8ordo/ui/styles.css';
|
|
9
|
-
// The provider (once, at the app root)
|
|
10
|
-
import {
|
|
9
|
+
// The provider for toasts (once, at the app root, when you use useToast)
|
|
10
|
+
import { ToastProvider } from '@k8ordo/ui';
|
|
11
11
|
// Components (all from the root entry)
|
|
12
12
|
import { Button, Card, TextField } from '@k8ordo/ui';
|
|
13
|
-
//
|
|
13
|
+
// And CodeBlock, which highlights on the server and has its own entry
|
|
14
14
|
import { CodeBlock } from '@k8ordo/ui/code-block';
|
|
15
|
+
// Except the icons, which have their own entry
|
|
16
|
+
import { CheckIcon } from '@k8ordo/ui/icons';
|
|
15
17
|
```
|
|
16
18
|
|
|
17
19
|
Every component can be rendered from a Server Component, compound ones
|
|
18
|
-
included: `
|
|
20
|
+
included: `Tabs.Root`, `Accordion.Item`, `Popover.Trigger`, and the rest are
|
|
19
21
|
composed outside the client modules, so the parts resolve on the server. Only
|
|
20
22
|
the interactive parts carry `'use client'`.
|
|
21
23
|
|
|
24
|
+
What a Server Component cannot do is pass a client part a function other
|
|
25
|
+
than a Server Action. A part whose required prop is a function — the
|
|
26
|
+
`renderItem` of `Popover.Trigger`, `Tooltip.Trigger`, `ContextMenu.Trigger`,
|
|
27
|
+
`Toolbar.Item`, and `FileField.Trigger`, `DataTable`'s `getRowId` and a
|
|
28
|
+
column's `cell` — is rendered from a Client Component, as is any part given
|
|
29
|
+
`onChange` or another handler. `FormControl` and `Form` are not client
|
|
30
|
+
modules: a Server Component renders them with `renderInput` and with a Server
|
|
31
|
+
Action as `action`, and only the fields inside are client parts.
|
|
32
|
+
|
|
22
33
|
## Render props
|
|
23
34
|
|
|
24
35
|
Two different contracts are spelled `render*`, and mixing them up is the usual
|
|
25
36
|
source of surprise.
|
|
26
37
|
|
|
27
|
-
**Replacing the element** — `
|
|
28
|
-
`
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
navigate. The examples below name them `_disabled` / `_type` so the discarded
|
|
43
|
-
bindings pass a `no-unused-vars` rule.
|
|
44
|
-
- `disabled` is only the `disabled` you passed. While an action is pending (see
|
|
45
|
-
[Button](#button)), the bag carries `aria-disabled` and `aria-busy` but
|
|
46
|
-
`disabled` stays `false`, so the pressed element keeps focus; the supplied
|
|
47
|
-
`onClick` is what ignores presses meanwhile.
|
|
48
|
-
- Spreading onto a real `<button>` is exact, but write `type` on the element
|
|
49
|
-
anyway: the `button-has-type` lint rule cannot see a `type` that arrives
|
|
50
|
-
through a spread.
|
|
51
|
-
|
|
52
|
-
The link components own less, so their bags are smaller:
|
|
53
|
-
|
|
54
|
-
- `Anchor` hands back `href`, `className`, `children` (with the new-tab icon on
|
|
55
|
-
an external link), `target` / `rel` on an external link, and every other
|
|
38
|
+
**Replacing the element** — `renderAnchor` on `Button` and `IconButton` (with
|
|
39
|
+
`href`), `Anchor`, `Breadcrumb.Link`, `SideNav.Link`, `DropdownMenu.Item` /
|
|
40
|
+
`ContextMenu.Item` (with `href`), and `Card` (with `href`). The component computes
|
|
41
|
+
everything and hands back the exact props it would have put on its own `<a>`,
|
|
42
|
+
so substituting a framework `<Link>` loses nothing. Spread the bag onto whatever
|
|
43
|
+
you render.
|
|
44
|
+
|
|
45
|
+
- `Button` and `IconButton` hand back `href`, `className`, the composed
|
|
46
|
+
`children` (icons included), `ref`, `onClick`, `aria-disabled`, and every
|
|
47
|
+
anchor attribute the caller passed. `IconButton` adds `aria-label` and the
|
|
48
|
+
tooltip's handlers, chained with any the caller passed. While `disabled`, the
|
|
49
|
+
supplied `onClick` calls `preventDefault()`, so the link does not navigate.
|
|
50
|
+
- `Anchor` hands back `href`, `className`, `children` (with the new-tab icon
|
|
51
|
+
and the visually hidden new-tab wording on an external link), `target` /
|
|
52
|
+
`rel` on an external link, and every other
|
|
56
53
|
anchor attribute the caller passed, plus `kind` (`'internal'` |
|
|
57
54
|
`'external'`). `kind` is not an attribute: destructure it away before
|
|
58
55
|
spreading, or use it to choose between a framework `<Link>` and a plain `<a>`.
|
|
59
56
|
There is no `ref` and no disabled state.
|
|
60
|
-
- `Breadcrumb.Link` hands back `href`, `className`,
|
|
61
|
-
|
|
62
|
-
`<span aria-current="page"
|
|
57
|
+
- `Breadcrumb.Link` hands back `href`, `className`, `children`, and every other
|
|
58
|
+
anchor attribute the caller passed. A `current` link renders
|
|
59
|
+
`<span aria-current="page">`, without those attributes, and does not call
|
|
60
|
+
`renderAnchor`.
|
|
63
61
|
- `SideNav.Link` hands back `href`, `className`, `children`, `aria-current`
|
|
64
62
|
(`'page'` on the current link), and every other anchor attribute the caller
|
|
65
63
|
passed. A current link is still a link.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
`
|
|
69
|
-
|
|
64
|
+
- `DropdownMenu.Item` and `ContextMenu.Item` hand back `href`, `className`,
|
|
65
|
+
`children` (the `label`), `role` (`'menuitem'`), and the keyboard wiring
|
|
66
|
+
(`id`, `ref`, `tabIndex`, `onFocus`, `onClick`, `onKeyDown`). Spread all of
|
|
67
|
+
it: the wiring is what moves the arrow keys onto the item, closes the menu
|
|
68
|
+
when it is chosen, and lets Space choose it.
|
|
69
|
+
- `Card` hands back `href`, `className`, `aria-labelledby`, and `target` /
|
|
70
|
+
`rel` with `openInNewTab` (`CardRenderAnchorProps`). There are no
|
|
71
|
+
`children`: the link lies over the card's content and takes its name from
|
|
72
|
+
`aria-labelledby`, which with `openInNewTab` also points at the hidden
|
|
73
|
+
new-tab wording.
|
|
74
|
+
|
|
75
|
+
**Filling a slot** — `renderInput` on `FormControl`, and `renderItem` on
|
|
76
|
+
`Popover.Trigger`, `Tooltip.Trigger` and `FileField.Trigger`. Here the
|
|
77
|
+
component owns no element of its own. It computes wiring —
|
|
70
78
|
ids, ARIA relationships, open/close handlers — and you supply the element that
|
|
71
79
|
wiring belongs to. Those bags carry only the wiring, and they are required
|
|
72
80
|
rather than optional.
|
|
@@ -82,11 +90,12 @@ import { Button } from '@k8ordo/ui';
|
|
|
82
90
|
size="sm" | "md" | "lg"
|
|
83
91
|
color="primary" | "secondary" | "base"
|
|
84
92
|
variant="solid" | "outline" | "skeleton"
|
|
93
|
+
type="button" | "submit" | "reset"
|
|
85
94
|
fullWidth={false}
|
|
86
95
|
startIcon={<Icon />}
|
|
87
96
|
endIcon={<Icon />}
|
|
88
97
|
disabled={false}
|
|
89
|
-
|
|
98
|
+
action={async () => {}}
|
|
90
99
|
>
|
|
91
100
|
Button
|
|
92
101
|
</Button>
|
|
@@ -94,98 +103,103 @@ import { Button } from '@k8ordo/ui';
|
|
|
94
103
|
|
|
95
104
|
Props:
|
|
96
105
|
|
|
106
|
+
- `action`: `() => void | Promise<void>`
|
|
97
107
|
- `children`: `ReactNode`
|
|
98
108
|
- `color`: `'primary'` | `'secondary'` | `'base'` (default: `'primary'`)
|
|
109
|
+
- `disabled`: `boolean` (default: `false`)
|
|
99
110
|
- `endIcon`: `ReactNode`
|
|
100
111
|
- `fullWidth`: `boolean` (default: `false`)
|
|
101
|
-
- `
|
|
102
|
-
- `
|
|
103
|
-
- `renderItem`: `(props: ButtonRenderItemProps) => ReactNode`
|
|
112
|
+
- `href`: `T`
|
|
113
|
+
- `renderAnchor`: `(props: RenderAnchorProps<T>) => ReactNode`
|
|
104
114
|
- `size`: `'sm'` | `'md'` | `'lg'` (default: `'md'`)
|
|
105
115
|
- `startIcon`: `ReactNode`
|
|
106
|
-
- `type`: `'button'` | `'submit'` (default: `'button'`)
|
|
116
|
+
- `type`: `'button'` | `'submit'` | `'reset'` (default: `'button'`)
|
|
107
117
|
- `variant`: `'solid'` | `'outline'` | `'skeleton'` (default: `'solid'`)
|
|
108
|
-
- Other props are forwarded to `ComponentPropsWithRef<'button'>`, except `className` / `style`.
|
|
118
|
+
- Other props are forwarded to `ComponentPropsWithRef<'button'> | ComponentPropsWithRef<'a'>`, except `className` / `style` / `aria-disabled`.
|
|
109
119
|
|
|
110
|
-
`
|
|
120
|
+
`action` runs inside a transition. While the promise it returns is pending —
|
|
111
121
|
and, with `type="submit"`, while the form's action is pending — the button shows
|
|
112
122
|
a spinner, carries `aria-busy` and `aria-disabled`, and ignores presses,
|
|
113
123
|
including the implicit submission of pressing Enter in a field. It does not
|
|
114
124
|
become natively `disabled`: Chromium moves focus to `body` when the focused
|
|
115
125
|
element is disabled, so a keyboard user who pressed the button would lose their
|
|
116
126
|
place. The `disabled` you pass is native, and takes the button out of the tab
|
|
117
|
-
order.
|
|
118
|
-
|
|
119
|
-
`
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
127
|
+
order. A synchronous update a user may press again at once belongs in
|
|
128
|
+
`onClick`, since `action` ignores presses while its transition is pending. Only
|
|
129
|
+
`type="submit"` follows the form's pending state; `type="reset"` resets the
|
|
130
|
+
form it belongs to.
|
|
131
|
+
|
|
132
|
+
A skeleton `Button` shows its state in the text color. A toggle passes
|
|
133
|
+
`aria-pressed` and a link to the current page passes `aria-current`; the text
|
|
134
|
+
then takes the info color. The state lives in the ARIA attribute, so assistive
|
|
135
|
+
technology hears what the color shows. Inside a `Toolbar` the toolbar shows a
|
|
136
|
+
pressed item by its ground instead, and the text is `fg-base` (see
|
|
137
|
+
[Toolbar](#toolbar)). A solid or outline toggle has no pressed look of its own;
|
|
138
|
+
switch its `variant` or `color` with the state.
|
|
139
|
+
|
|
140
|
+
With `href`, `Button` renders an `<a>` with the same look. That form takes
|
|
141
|
+
anchor attributes (`target`, `rel`, `download`, `data-*`) and no `type` or
|
|
142
|
+
`action`. `disabled` sets `aria-disabled` and stops the click from navigating.
|
|
143
|
+
`renderAnchor` draws a link component of your own, such as Next.js's `<Link>`;
|
|
144
|
+
see [Render props](#render-props) for what it receives. The type of `href` is
|
|
145
|
+
kept in the bag, so a typed route stays typed.
|
|
146
|
+
|
|
147
|
+
```tsx
|
|
148
|
+
<Button color="base" href="/settings" variant="outline">
|
|
149
|
+
Settings
|
|
150
|
+
</Button>
|
|
124
151
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
color="base"
|
|
128
|
-
variant="outline"
|
|
129
|
-
renderItem={({ children, disabled: _disabled, type: _type, ...props }) => (
|
|
130
|
-
<a href="/page" {...props}>
|
|
131
|
-
{children}
|
|
132
|
-
</a>
|
|
133
|
-
)}
|
|
134
|
-
>
|
|
135
|
-
Link
|
|
152
|
+
<Button href="/settings" renderAnchor={(props) => <Link {...props} />}>
|
|
153
|
+
Settings
|
|
136
154
|
</Button>
|
|
137
155
|
```
|
|
138
156
|
|
|
139
157
|
### IconButton
|
|
140
158
|
|
|
141
|
-
An icon-only button.
|
|
159
|
+
An icon-only button. `variant` picks the ground: `skeleton` (the default) has
|
|
160
|
+
none, and `solid` fills it with the `color` family, as `Button` does. `label`
|
|
161
|
+
is the accessible name and the tooltip; the tooltip is not added as a
|
|
162
|
+
description, since it would repeat the name.
|
|
142
163
|
|
|
143
164
|
```tsx
|
|
144
165
|
import { IconButton } from '@k8ordo/ui';
|
|
145
166
|
|
|
146
|
-
<IconButton label="Close"
|
|
147
|
-
<
|
|
167
|
+
<IconButton label="Close" size="md">
|
|
168
|
+
<XIcon />
|
|
169
|
+
</IconButton>;
|
|
170
|
+
<IconButton color="primary" label="Send" variant="solid">
|
|
171
|
+
<SendIcon />
|
|
148
172
|
</IconButton>;
|
|
149
173
|
```
|
|
150
174
|
|
|
151
175
|
Props:
|
|
152
176
|
|
|
153
177
|
- `label`: `string` (required)
|
|
178
|
+
- `action`: `() => void | Promise<void>`
|
|
154
179
|
- `children`: `ReactNode`
|
|
155
|
-
- `color`: `'
|
|
156
|
-
- `
|
|
157
|
-
- `
|
|
180
|
+
- `color`: `'primary'` | `'secondary'` | `'base'` (default: `'primary'`)
|
|
181
|
+
- `disabled`: `boolean` (default: `false`)
|
|
182
|
+
- `href`: `T`
|
|
183
|
+
- `renderAnchor`: `(props: RenderAnchorProps<T>) => ReactNode`
|
|
158
184
|
- `size`: `'sm'` | `'md'` | `'lg'` (default: `'md'`)
|
|
159
185
|
- `tooltipDisabled`: `boolean` (default: `false`)
|
|
160
186
|
- `tooltipPlacement`: `Placement` (default: `'top'`)
|
|
161
|
-
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
`
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
`
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
renderItem={({
|
|
178
|
-
children,
|
|
179
|
-
disabled: _disabled,
|
|
180
|
-
triggerProps,
|
|
181
|
-
type: _type,
|
|
182
|
-
...props
|
|
183
|
-
}) => (
|
|
184
|
-
<a href="/contact" {...props} {...triggerProps}>
|
|
185
|
-
{children}
|
|
186
|
-
</a>
|
|
187
|
-
)}
|
|
188
|
-
>
|
|
187
|
+
- `type`: `'button'` | `'submit'` | `'reset'` (default: `'button'`)
|
|
188
|
+
- `variant`: `'solid'` | `'skeleton'` (default: `'skeleton'`)
|
|
189
|
+
- Other props are forwarded to `ComponentPropsWithRef<'button'> | ComponentPropsWithRef<'a'>`, except `className` / `style` / `aria-disabled`.
|
|
190
|
+
|
|
191
|
+
`action` keeps the button busy the way `Button`'s does — `aria-busy`,
|
|
192
|
+
`aria-disabled`, presses ignored, focus kept — without the spinner. `type`
|
|
193
|
+
takes `'button'`, `'submit'`, or `'reset'`, and only a submit button follows
|
|
194
|
+
the form's pending state.
|
|
195
|
+
|
|
196
|
+
With `href`, `IconButton` renders an `<a>`, named by `label` and with the same
|
|
197
|
+
tooltip. `renderAnchor` replaces that `<a>` under the same contract as
|
|
198
|
+
`Button`'s; the bag also carries `aria-label` and the tooltip's handlers and
|
|
199
|
+
`ref`, so spreading it keeps the tooltip.
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
<IconButton href="/contact" label="Mail">
|
|
189
203
|
<MailIcon />
|
|
190
204
|
</IconButton>
|
|
191
205
|
```
|
|
@@ -196,7 +210,7 @@ A button that copies text to the clipboard and shows that it did: its icon
|
|
|
196
210
|
turns into a check for two seconds (an error icon if the write fails), and a
|
|
197
211
|
live region beside it announces `copied` / `copyFailed` from the dictionary. The
|
|
198
212
|
button's name stays the same throughout. By default it is an outline `Button`
|
|
199
|
-
with its `label` as text; `iconOnly` makes it a
|
|
213
|
+
with its `label` as text; `iconOnly` makes it a skeleton `IconButton` whose
|
|
200
214
|
`label` is the tooltip.
|
|
201
215
|
|
|
202
216
|
```tsx
|
|
@@ -237,8 +251,10 @@ skipped. Tab leaves the toolbar, and coming back lands on the item last focused.
|
|
|
237
251
|
|
|
238
252
|
Each item is a slot: `Toolbar.Item`'s `renderItem` receives `ref`, `tabIndex`,
|
|
239
253
|
and `onFocus` (`ToolbarItemProps`) to spread onto a `Button`, an `IconButton`,
|
|
240
|
-
or any other button. A toggle item sets `aria-pressed`; the toolbar
|
|
241
|
-
pressed item
|
|
254
|
+
or any other button. A toggle item sets `aria-pressed`; the toolbar shows a
|
|
255
|
+
pressed item on the `bg-emphasize` ground with `fg-base` text (a disabled item
|
|
256
|
+
keeps its disabled text). The root needs a name (`aria-label` or
|
|
257
|
+
`aria-labelledby`).
|
|
242
258
|
Items are meant to be buttons: a control that uses the arrow keys itself (a text
|
|
243
259
|
field, a slider) would fight the toolbar for them.
|
|
244
260
|
|
|
@@ -317,9 +333,11 @@ Props (Breadcrumb.Link):
|
|
|
317
333
|
- `children`: `ReactNode`
|
|
318
334
|
- `current`: `boolean` (default: `false`)
|
|
319
335
|
- `renderAnchor`: `(props: RenderBreadcrumbAnchorProps<T>) => ReactNode` (default: `defaultRenderBreadcrumbAnchor`)
|
|
336
|
+
- Other props are forwarded to `AnchorHTMLAttributes<HTMLAnchorElement>`, except `className` / `style`.
|
|
320
337
|
|
|
321
|
-
`Breadcrumb.Link`
|
|
322
|
-
|
|
338
|
+
`Breadcrumb.Link` passes any other anchor attribute (`hrefLang`, `data-*`) to
|
|
339
|
+
the `<a>`, and its `renderAnchor` receives them with `href`, `className`, and
|
|
340
|
+
`children`; see [Render props](#render-props).
|
|
323
341
|
|
|
324
342
|
Props (Breadcrumb.Item):
|
|
325
343
|
|
|
@@ -340,12 +358,12 @@ Props:
|
|
|
340
358
|
- `currentPage`: `number` (required)
|
|
341
359
|
- `onChange`: `(page: number) => void` (required)
|
|
342
360
|
- `totalPages`: `number` (required)
|
|
343
|
-
- `aria-label`: `string`
|
|
344
361
|
- `disabled`: `boolean` (default: `false`)
|
|
362
|
+
- `label`: `string`
|
|
345
363
|
- `nextLabel`: `string`
|
|
346
364
|
- `prevLabel`: `string`
|
|
347
365
|
- `ref`: `Ref<HTMLElement>`
|
|
348
|
-
- Other props are forwarded to `HTMLAttributes<HTMLElement>`, except `className` / `style` / `children`.
|
|
366
|
+
- Other props are forwarded to `HTMLAttributes<HTMLElement>`, except `className` / `style` / `children` / `aria-label`.
|
|
349
367
|
|
|
350
368
|
### Stepper
|
|
351
369
|
|
|
@@ -509,12 +527,16 @@ Props:
|
|
|
509
527
|
|
|
510
528
|
### Tabs
|
|
511
529
|
|
|
512
|
-
Tab switching, as a compound component.
|
|
530
|
+
Tab switching, as a compound component. The tab that starts selected is
|
|
531
|
+
`defaultSelectedId`, required when the selection is not controlled; a
|
|
532
|
+
controlled one takes `selectedId` and `onChange`. Each `Tabs.Tab` and its
|
|
533
|
+
`Tabs.Panel` share an `id`, so map both from one list when the tabs come from
|
|
534
|
+
data.
|
|
513
535
|
|
|
514
536
|
```tsx
|
|
515
537
|
import { Tabs } from '@k8ordo/ui';
|
|
516
538
|
|
|
517
|
-
<Tabs.Root
|
|
539
|
+
<Tabs.Root defaultSelectedId="tab1">
|
|
518
540
|
<Tabs.List label="Tabs">
|
|
519
541
|
<Tabs.Tab id="tab1">Tab 1</Tabs.Tab>
|
|
520
542
|
<Tabs.Tab id="tab2">Tab 2</Tabs.Tab>
|
|
@@ -524,21 +546,23 @@ import { Tabs } from '@k8ordo/ui';
|
|
|
524
546
|
</Tabs.Root>;
|
|
525
547
|
```
|
|
526
548
|
|
|
527
|
-
|
|
549
|
+
The tab is marked selected at once, and the panels follow a deferred copy of
|
|
550
|
+
the selection (`useDeferredValue`): they cross-fade through React's
|
|
528
551
|
`<ViewTransition>` (off under `prefers-reduced-motion`), and a panel that
|
|
529
|
-
suspends keeps the current one on screen until it is ready.
|
|
552
|
+
suspends keeps the current one on screen until it is ready. Both hold however
|
|
553
|
+
the selection is set, by `useState` or by a store such as `@k8ordo/state`
|
|
554
|
+
whose updates are synchronous.
|
|
530
555
|
|
|
531
556
|
The keys follow the WAI-ARIA tabs pattern, and focusing a tab selects it.
|
|
532
|
-
`ArrowLeft` / `ArrowRight` move to the previous / next tab
|
|
533
|
-
ends, and swap under `dir="rtl"`; in vertical
|
|
534
|
-
vertical and `ArrowUp` / `ArrowDown` do the same.
|
|
535
|
-
first / last tab.
|
|
557
|
+
`ArrowLeft` / `ArrowRight` move to the previous / next tab in the order the
|
|
558
|
+
tabs appear, wrapping at the ends, and swap under `dir="rtl"`; in vertical
|
|
559
|
+
writing mode the list is vertical and `ArrowUp` / `ArrowDown` do the same.
|
|
560
|
+
`Home` / `End` go to the first / last tab.
|
|
536
561
|
|
|
537
562
|
Props (Tabs.Root):
|
|
538
563
|
|
|
539
|
-
- `ids`: `[string, ...string[]]` (required)
|
|
540
564
|
- `children`: `ReactNode`
|
|
541
|
-
- `defaultSelectedId`: `string`
|
|
565
|
+
- `defaultSelectedId`: `string`
|
|
542
566
|
- `onChange`: `(id: string) => void`
|
|
543
567
|
- `selectedId`: `string`
|
|
544
568
|
|
|
@@ -559,7 +583,14 @@ Props (Tabs.Tab):
|
|
|
559
583
|
|
|
560
584
|
### Anchor
|
|
561
585
|
|
|
562
|
-
A text link.
|
|
586
|
+
A text link. A link is external when its URL is an absolute `http:` / `https:`
|
|
587
|
+
URL or starts with `//` (or `/\`, which browsers read the same); a relative
|
|
588
|
+
path, a `?…`-only URL, and other schemes such as `mailto:` stay internal. An
|
|
589
|
+
external link, or one with `openInNewTab`, opens in a new tab with
|
|
590
|
+
`rel="noopener noreferrer"`, shows the new-tab icon, and says so to assistive
|
|
591
|
+
technology with visually hidden wording (`opensInNewTab`: "opens in a new
|
|
592
|
+
tab" in `en`, 「新しいタブで開きます」 in `ja`). The link stays inline, so a
|
|
593
|
+
long one wraps with the text around it.
|
|
563
594
|
|
|
564
595
|
```tsx
|
|
565
596
|
import { Anchor } from '@k8ordo/ui';
|
|
@@ -584,10 +615,39 @@ Props:
|
|
|
584
615
|
|
|
585
616
|
Form components are used together with `FormControl`'s `renderInput` pattern. Every form component except `FileField` supports both controlled and uncontrolled use; `FileField.Root` takes only `defaultValue` and keeps the selected files itself.
|
|
586
617
|
|
|
587
|
-
`ref` reaches the real element (`input` / `textarea` / `select` / `fieldset`). `FileField` uses a ref internally but composes it with yours, so the `ref` you pass still reaches the element. `Radio` (a group that renders several inputs) puts its `ref` on the radiogroup `<div>`, and `FormControl` (a wrapper) on its wrapper
|
|
618
|
+
`ref` reaches the real element (`input` / `textarea` / `select` / `fieldset`). `FileField` uses a ref internally but composes it with yours, so the `ref` you pass still reaches the element. `Radio` (a group that renders several inputs) puts its `ref` on the radiogroup `<div>`, and `FormControl` (a wrapper) on its wrapper `<div>`.
|
|
588
619
|
|
|
589
620
|
An uncontrolled field keeps its value in the DOM, so a form reset — `form.reset()`, a reset button, or React resetting the form after an action — puts it back to its `defaultValue`, and a `defaultValue` that changes after mount (the values a failed submission echoes back) is where the next reset goes. A value a component changes in code (a stepper, a chosen option, a removed file) is announced with an `input` event, so a form library listening on the `<form>` hears it like typing.
|
|
590
621
|
|
|
622
|
+
**A controlled field does not hear what was typed before hydration.** A
|
|
623
|
+
field in server-rendered HTML takes input before React attaches. React
|
|
624
|
+
keeps what the visitor typed in the element and calls no `onChange` for it,
|
|
625
|
+
so the state behind `value` stays at what the server rendered until the
|
|
626
|
+
next keystroke: a search box shows `rea` while the list below it is still
|
|
627
|
+
unfiltered. An uncontrolled field has no such gap, since its value is read
|
|
628
|
+
from the element. For a controlled one, compare the element with the state
|
|
629
|
+
when it attaches, through `ref`:
|
|
630
|
+
|
|
631
|
+
```tsx
|
|
632
|
+
const typedBeforeHydration =
|
|
633
|
+
(value: string, onTyped: (typed: string) => void) =>
|
|
634
|
+
(input: HTMLInputElement | null) => {
|
|
635
|
+
if (input !== null && input.value !== value) onTyped(input.value);
|
|
636
|
+
};
|
|
637
|
+
|
|
638
|
+
<TextField
|
|
639
|
+
onChange={(event) => setQuery(event.target.value)}
|
|
640
|
+
ref={typedBeforeHydration(query, setQuery)}
|
|
641
|
+
value={query}
|
|
642
|
+
/>;
|
|
643
|
+
```
|
|
644
|
+
|
|
645
|
+
This is React's behavior, the same for a plain `<input>`, and for a
|
|
646
|
+
checkbox's `checked` as for a text field's `value`. The components carry
|
|
647
|
+
no workaround of their own: React has a fix behind an experimental flag
|
|
648
|
+
(a change event replayed at hydration), and a second one here would call
|
|
649
|
+
`onChange` twice once it ships.
|
|
650
|
+
|
|
591
651
|
Every field takes the attributes `@k8ordo/form`'s `formFields` derives as they are — spread `field.input` after `FormControl`'s props. Its guide's "Working with @k8ordo/ui" section has one example per component.
|
|
592
652
|
|
|
593
653
|
### Form
|
|
@@ -639,15 +699,27 @@ Props:
|
|
|
639
699
|
- `disabled`: `boolean` (default: `false`)
|
|
640
700
|
- `errorText`: `string`
|
|
641
701
|
- `helpText`: `string`
|
|
642
|
-
- `
|
|
643
|
-
- `
|
|
644
|
-
- `ref`: `Ref<HTMLElement>`
|
|
702
|
+
- `labelAs`: `'label'` | `'group'` (default: `'label'`)
|
|
703
|
+
- `ref`: `Ref<HTMLDivElement>`
|
|
645
704
|
- `required`: `boolean` (default: `false`)
|
|
646
|
-
- Other props are forwarded to `HTMLAttributes<
|
|
705
|
+
- Other props are forwarded to `HTMLAttributes<HTMLDivElement>`, except `className` / `style` / `children`.
|
|
647
706
|
|
|
648
707
|
`renderInput` receives `{ id, 'aria-describedby', 'aria-labelledby', disabled, invalid, required }`.
|
|
649
708
|
|
|
650
|
-
The wrapper
|
|
709
|
+
The wrapper is a `<div>`, and `labelAs` picks the element that draws the label. `'label'` (the default) gives a `<label htmlFor>` pointing at the field. `'group'` gives a `<span id>` with the same look, the required mark included, for a component that is a group itself — `Radio`, `RadioCard`, `CheckboxGroup`, `CheckboxCard`, and `RangeSlider` — and names it through `aria-labelledby`. A `<label>` cannot label a group, and a `<fieldset>` around one would nest a second group with the same name, so `'group'` renders neither. `FileField` takes `'group'` too: what a person reaches is its trigger, a button named through `aria-labelledby`, and a button cannot be required. `ColorPicker`, `DatePicker`, `Combobox`, and `Autocomplete` put the `id` on a text input, so they keep `'label'`.
|
|
710
|
+
|
|
711
|
+
```tsx
|
|
712
|
+
<FormControl
|
|
713
|
+
label="Plan"
|
|
714
|
+
labelAs="group"
|
|
715
|
+
required
|
|
716
|
+
renderInput={(props) => <RadioCard {...props} options={plans} />}
|
|
717
|
+
/>
|
|
718
|
+
```
|
|
719
|
+
|
|
720
|
+
`required` draws the built-in `required` wording after the label and passes `required: true` to `renderInput`. With `'label'` the mark is `aria-hidden`: the field's own `required` already tells a screen reader, so the name stays the label alone. With `'group'` the mark is part of the name, since neither a `role="group"` nor `FileField`'s trigger button takes `aria-required`.
|
|
721
|
+
|
|
722
|
+
A non-empty `errorText` is what makes the field invalid: it is drawn under the field in place of `helpText`, describes the field instead, and `renderInput` receives `invalid: true`. There is no `invalid` prop to keep in step with it. To mark a field invalid without a message, pass `invalid` to the field itself inside `renderInput`.
|
|
651
723
|
|
|
652
724
|
### TextField
|
|
653
725
|
|
|
@@ -672,6 +744,25 @@ import { TextField } from '@k8ordo/ui';
|
|
|
672
744
|
`type` also accepts any string, so the `type` `@k8ordo/form` derives
|
|
673
745
|
(`email`, `url`, `date`, `time`, `datetime-local`, …) spreads as it is.
|
|
674
746
|
|
|
747
|
+
A date or time input (`date`, `time`, `datetime-local`, `month`, `week`) is the
|
|
748
|
+
browser's own `<input>`: the value is the native string (`YYYY-MM-DD` for a
|
|
749
|
+
date, `''` when empty), and the browser checks `min` / `max` / `required`
|
|
750
|
+
itself. Its digits are tabular, so they do not shift sideways as the value
|
|
751
|
+
changes. A field derived from `z.iso.date()` spreads with nothing taken out:
|
|
752
|
+
|
|
753
|
+
```tsx
|
|
754
|
+
import { FormControl, TextField } from '@k8ordo/ui';
|
|
755
|
+
|
|
756
|
+
const eventDate = form.field('eventDate'); // z.iso.date()
|
|
757
|
+
|
|
758
|
+
<FormControl
|
|
759
|
+
errorText={eventDate.error}
|
|
760
|
+
label="Date"
|
|
761
|
+
required={eventDate.required}
|
|
762
|
+
renderInput={(props) => <TextField {...props} {...eventDate.input} />}
|
|
763
|
+
/>;
|
|
764
|
+
```
|
|
765
|
+
|
|
675
766
|
Props:
|
|
676
767
|
|
|
677
768
|
- `children`: `ReactNode`
|
|
@@ -702,12 +793,10 @@ Props:
|
|
|
702
793
|
- `fullHeight`: `boolean` (default: `false`)
|
|
703
794
|
- `invalid`: `boolean` (default: `false`)
|
|
704
795
|
- `ref`: `Ref<HTMLTextAreaElement>`
|
|
705
|
-
- `type`: `string`
|
|
706
796
|
- Other props are forwarded to `TextareaHTMLAttributes<HTMLTextAreaElement>`, except `className` / `style`.
|
|
707
797
|
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
checked by the browser on a `<textarea>` either.
|
|
798
|
+
A `<textarea>` has no `type`, and the browser does not check a `pattern` on
|
|
799
|
+
one.
|
|
711
800
|
|
|
712
801
|
### NumberField
|
|
713
802
|
|
|
@@ -747,18 +836,23 @@ range. `required` reaches the input itself, so an empty required field fails
|
|
|
747
836
|
native validation.
|
|
748
837
|
|
|
749
838
|
The input is `type="text"` (so it can format to `precision` and step with the
|
|
750
|
-
arrow keys), which the browser does not range-check — so the field
|
|
751
|
-
value
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
839
|
+
arrow keys), which the browser does not range-check — so the field keeps the
|
|
840
|
+
value in range itself: leaving the field, or pressing Enter in it (not while an
|
|
841
|
+
IME is composing), clamps a value below `min` or above `max` into range, the
|
|
842
|
+
same commit either way. A form submitted with Enter therefore sends the clamped
|
|
843
|
+
value. The field sets no validity message of its own, so whatever reports an
|
|
844
|
+
out-of-range value — the server's schema, when JavaScript has not run — keeps
|
|
845
|
+
its own wording.
|
|
846
|
+
|
|
847
|
+
`min` and `max` are numbers. An uncontrolled `defaultValue` also takes a
|
|
848
|
+
string, and `step` takes `'any'`: `@k8ordo/form` derives numeric `min` /
|
|
849
|
+
`max`, a `step` of `'any'` unless the schema sets one, and echoes the
|
|
850
|
+
submitted text as a string `defaultValue`. `precision` defaults to the number
|
|
851
|
+
of decimals in `step`; with `step="any"` the value is not rounded.
|
|
759
852
|
|
|
760
853
|
A value the field writes itself — an arrow key, a stepper press, formatting on
|
|
761
|
-
blur — is announced with one `input` event, and `onChange` is still
|
|
854
|
+
blur or Enter — is announced with one `input` event, and `onChange` is still
|
|
855
|
+
called once.
|
|
762
856
|
|
|
763
857
|
A form reset — `form.reset()`, a reset button, or React resetting the form after
|
|
764
858
|
an action — puts an uncontrolled field back to `defaultValue` (or to empty) and
|
|
@@ -769,8 +863,8 @@ Props:
|
|
|
769
863
|
|
|
770
864
|
- `defaultValue`: `number` | `string`
|
|
771
865
|
- `invalid`: `boolean` (default: `false`)
|
|
772
|
-
- `max`: `number`
|
|
773
|
-
- `min`: `number`
|
|
866
|
+
- `max`: `number` (default: `Number.MAX_SAFE_INTEGER`)
|
|
867
|
+
- `min`: `number` (default: `Number.MIN_SAFE_INTEGER`)
|
|
774
868
|
- `onChange`: `(value: number | null) => void`
|
|
775
869
|
- `precision`: `number`
|
|
776
870
|
- `ref`: `Ref<HTMLInputElement>`
|
|
@@ -778,41 +872,12 @@ Props:
|
|
|
778
872
|
- `value`: `number` | `null`
|
|
779
873
|
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `type` / `role` / `className` / `style` / `children`.
|
|
780
874
|
|
|
781
|
-
### DateField
|
|
782
|
-
|
|
783
|
-
A native `<input type="date">` styled like `TextField`. The value is a
|
|
784
|
-
`YYYY-MM-DD` string (`''` when empty), and the browser checks `min` / `max` /
|
|
785
|
-
`required` itself. `onChange` is the native event, as with `TextField`.
|
|
786
|
-
|
|
787
|
-
It accepts what `@k8ordo/form` derives from `z.iso.date()` as is: spread the
|
|
788
|
-
field's `input` and nothing needs to be taken out. `type` is always `date`, so a
|
|
789
|
-
`type` in the spread does not replace it.
|
|
790
|
-
|
|
791
|
-
```tsx
|
|
792
|
-
import { DateField, FormControl } from '@k8ordo/ui';
|
|
793
|
-
|
|
794
|
-
const eventDate = form.field('eventDate'); // z.iso.date()
|
|
795
|
-
|
|
796
|
-
<FormControl
|
|
797
|
-
errorText={eventDate.error}
|
|
798
|
-
invalid={eventDate.invalid}
|
|
799
|
-
label="Date"
|
|
800
|
-
required={eventDate.required}
|
|
801
|
-
renderInput={(props) => <DateField {...props} {...eventDate.input} />}
|
|
802
|
-
/>;
|
|
803
|
-
```
|
|
804
|
-
|
|
805
|
-
Props:
|
|
806
|
-
|
|
807
|
-
- `invalid`: `boolean` (default: `false`)
|
|
808
|
-
- `ref`: `Ref<HTMLInputElement>`
|
|
809
|
-
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `className` / `style` / `type` / `children`.
|
|
810
|
-
|
|
811
875
|
### DatePicker
|
|
812
876
|
|
|
813
|
-
`
|
|
814
|
-
same native `<input type="date">`, so typing a date, `name`, `required`,
|
|
815
|
-
`min` / `max` all work as they do on `
|
|
877
|
+
A date `TextField` with a button that opens `Calendar` in a popover. The field
|
|
878
|
+
is the same native `<input type="date">`, so typing a date, `name`, `required`,
|
|
879
|
+
and `min` / `max` all work as they do on a `TextField` with `type="date"`, and
|
|
880
|
+
spreading a derived
|
|
816
881
|
`@k8ordo/form` field works the same way. `onChange` takes the value
|
|
817
882
|
(`YYYY-MM-DD`, `''` when cleared), not the event, because a date picked from the
|
|
818
883
|
calendar has no input event of its own.
|
|
@@ -858,8 +923,8 @@ Month and weekday names, and the first day of the week, follow the same locale
|
|
|
858
923
|
as the built-in wording (i18n, below). Today is marked with
|
|
859
924
|
`aria-current="date"` in the visitor's time zone, which only the browser knows,
|
|
860
925
|
so the calendar renders in the browser alone: the server writes an empty box of
|
|
861
|
-
the same size. It submits nothing; inside a form, use `DatePicker` or
|
|
862
|
-
`
|
|
926
|
+
the same size. It submits nothing; inside a form, use `DatePicker` or a
|
|
927
|
+
`TextField` with `type="date"`.
|
|
863
928
|
|
|
864
929
|
```tsx
|
|
865
930
|
import { Calendar } from '@k8ordo/ui';
|
|
@@ -930,13 +995,23 @@ Props:
|
|
|
930
995
|
- `options`: `readonly Option[]` (required)
|
|
931
996
|
- `children`: `ReactNode`
|
|
932
997
|
- `invalid`: `boolean` (default: `false`)
|
|
998
|
+
- `placeholder`: `string`
|
|
933
999
|
- `ref`: `Ref<HTMLSelectElement>`
|
|
934
1000
|
- Other props are forwarded to `SelectHTMLAttributes<HTMLSelectElement>`, except `className` / `style`.
|
|
935
1001
|
|
|
936
1002
|
React applies a `<select>`'s `defaultValue` only when it mounts; `Select` also
|
|
937
1003
|
applies a later one, so the next reset — React's after a form action included —
|
|
938
|
-
goes back to it.
|
|
939
|
-
|
|
1004
|
+
goes back to it.
|
|
1005
|
+
|
|
1006
|
+
`placeholder` puts an option whose `value` is `''` first, labelled with it. A
|
|
1007
|
+
`<select>` without such an option always has a choice selected, so `required`
|
|
1008
|
+
means something only with one: leaving the placeholder selected fails
|
|
1009
|
+
validation. It stays selectable, so an optional field can be set back to no
|
|
1010
|
+
choice; `@k8ordo/form`'s `parseForm` reads `''` as no choice either way.
|
|
1011
|
+
|
|
1012
|
+
```tsx
|
|
1013
|
+
<Select name="plan" options={plans} placeholder="Choose a plan" required />
|
|
1014
|
+
```
|
|
940
1015
|
|
|
941
1016
|
### Autocomplete
|
|
942
1017
|
|
|
@@ -973,11 +1048,11 @@ Props:
|
|
|
973
1048
|
|
|
974
1049
|
- `id`: `string` (required)
|
|
975
1050
|
- `options`: `readonly Option[]` (required)
|
|
976
|
-
- `defaultValue`: `string[]`
|
|
1051
|
+
- `defaultValue`: `readonly string[]`
|
|
977
1052
|
- `invalid`: `boolean` (default: `false`)
|
|
978
1053
|
- `onChange`: `(value: string[]) => void`
|
|
979
1054
|
- `ref`: `Ref<HTMLInputElement>`
|
|
980
|
-
- `value`: `string[]`
|
|
1055
|
+
- `value`: `readonly string[]`
|
|
981
1056
|
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `type` / `role` / `className` / `style` / `children` / `autoComplete` / `aria-autocomplete` / `aria-controls` / `aria-expanded` / `aria-activedescendant`.
|
|
982
1057
|
|
|
983
1058
|
### ColorPicker
|
|
@@ -1025,9 +1100,8 @@ Props:
|
|
|
1025
1100
|
- `onChange`: `(value: string) => void`
|
|
1026
1101
|
- `ref`: `Ref<HTMLInputElement>`
|
|
1027
1102
|
- `swatches`: `readonly ColorPickerSwatch[]`
|
|
1028
|
-
- `type`: `string`
|
|
1029
1103
|
- `value`: `string`
|
|
1030
|
-
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `className` / `style` / `children`.
|
|
1104
|
+
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `type` / `className` / `style` / `children`.
|
|
1031
1105
|
|
|
1032
1106
|
### Combobox
|
|
1033
1107
|
|
|
@@ -1043,7 +1117,8 @@ and move through it (`Alt+ArrowDown` opens it without entering it), `Escape`
|
|
|
1043
1117
|
closes it and, pressed again, drops what was typed. Keys pressed while an IME is
|
|
1044
1118
|
composing belong to the IME.
|
|
1045
1119
|
|
|
1046
|
-
Without `search`, typing filters `options` by label
|
|
1120
|
+
Without `search`, typing filters `options` by label, case-insensitively in the
|
|
1121
|
+
language of `@k8ordo/i18n`'s current locale. With `search`, typing
|
|
1047
1122
|
calls it for the options instead — each call gets a `signal` that aborts when
|
|
1048
1123
|
the text changes again, so pass it to `fetch` — and `options` becomes the list
|
|
1049
1124
|
shown before anything is typed and where the current value's label is looked
|
|
@@ -1080,15 +1155,14 @@ Props:
|
|
|
1080
1155
|
- `options`: `readonly Option[]`
|
|
1081
1156
|
- `ref`: `Ref<HTMLInputElement>`
|
|
1082
1157
|
- `search`: `ComboboxSearch`
|
|
1083
|
-
- `type`: `string`
|
|
1084
1158
|
- `value`: `string`
|
|
1085
|
-
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `role` / `className` / `style` / `children` / `autoComplete` / `aria-autocomplete` / `aria-controls` / `aria-expanded` / `aria-activedescendant`.
|
|
1159
|
+
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `type` / `role` / `className` / `style` / `children` / `autoComplete` / `aria-autocomplete` / `aria-controls` / `aria-expanded` / `aria-activedescendant`.
|
|
1086
1160
|
|
|
1087
1161
|
### Checkbox
|
|
1088
1162
|
|
|
1089
1163
|
The label is passed as the `label` prop, not as children. `onChange` is `(checked, event)`.
|
|
1090
1164
|
|
|
1091
|
-
`
|
|
1165
|
+
`value` is the input's native `value`: the string a checked box submits under its `name`. Without it the box submits the browser's default, `on`. It never sets the checked state — that is `checked` / `defaultChecked`. `@k8ordo/form` puts it in the `input` of a `z.stringbool()` field (the schema's spelling of `true`), so spreading that `input` is enough.
|
|
1092
1166
|
|
|
1093
1167
|
```tsx
|
|
1094
1168
|
import { Checkbox } from '@k8ordo/ui';
|
|
@@ -1100,7 +1174,23 @@ import { Checkbox } from '@k8ordo/ui';
|
|
|
1100
1174
|
<Checkbox defaultChecked label="I agree" />
|
|
1101
1175
|
|
|
1102
1176
|
// Submits inStock=true when checked, instead of inStock=on
|
|
1103
|
-
<Checkbox
|
|
1177
|
+
<Checkbox label="In stock only" name="inStock" value="true" />
|
|
1178
|
+
```
|
|
1179
|
+
|
|
1180
|
+
`Checkbox` carries its own label, so it is not wrapped in `FormControl`. It
|
|
1181
|
+
draws a field's message itself instead: `errorText` (or, when there is none,
|
|
1182
|
+
`helpText`) is drawn under the box the way `FormControl` draws it, and the
|
|
1183
|
+
input is described by it, after any `aria-describedby` you pass. A non-empty
|
|
1184
|
+
`errorText` also sets `aria-invalid` and the invalid look, as `invalid` does;
|
|
1185
|
+
`invalid` alone marks the box without a message. With `@k8ordo/form`, pass
|
|
1186
|
+
`errorText={field.error}`.
|
|
1187
|
+
|
|
1188
|
+
```tsx
|
|
1189
|
+
<Checkbox
|
|
1190
|
+
{...agree.input}
|
|
1191
|
+
errorText={agree.error}
|
|
1192
|
+
label="I agree to the terms"
|
|
1193
|
+
/>
|
|
1104
1194
|
```
|
|
1105
1195
|
|
|
1106
1196
|
`indeterminate` shows the mixed state — some of a set selected — and sets the
|
|
@@ -1113,71 +1203,71 @@ Props:
|
|
|
1113
1203
|
- `label`: `string` (required)
|
|
1114
1204
|
- `checked`: `boolean`
|
|
1115
1205
|
- `defaultChecked`: `boolean`
|
|
1206
|
+
- `errorText`: `string`
|
|
1207
|
+
- `helpText`: `string`
|
|
1116
1208
|
- `indeterminate`: `boolean` (default: `false`)
|
|
1117
1209
|
- `invalid`: `boolean` (default: `false`)
|
|
1118
|
-
- `itemValue`: `string`
|
|
1119
1210
|
- `labelHidden`: `boolean` (default: `false`)
|
|
1120
1211
|
- `onChange`: `(checked: boolean, event: ChangeEvent<HTMLInputElement>) => void`
|
|
1121
1212
|
- `ref`: `Ref<HTMLInputElement>`
|
|
1122
|
-
-
|
|
1213
|
+
- `value`: `string`
|
|
1214
|
+
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `type` / `className` / `style` / `children`.
|
|
1123
1215
|
|
|
1124
1216
|
### CheckboxGroup
|
|
1125
1217
|
|
|
1126
|
-
A group of checkboxes
|
|
1218
|
+
A group of checkboxes, one per entry in `options`: the multiple-choice counterpart of `Radio`, with the same `options` shape.
|
|
1219
|
+
|
|
1220
|
+
The group's selection lives in `value` / `onChange`, or in `defaultValue` when uncontrolled: the values of the checked options. That is a different thing from a lone `Checkbox` holding a boolean in `checked` — do not conflate them. `value` and `defaultValue` take a readonly array, and `onChange` receives a new `string[]` of the checked values in option order, so a `useState<string[]>` setter can be passed as it is.
|
|
1221
|
+
|
|
1222
|
+
It renders a `fieldset[role="group"]`, so `aria-labelledby` is required: `<FormControl labelAs="group">` draws the element it points at. Convey that the group is required through that element — `FormControl`'s required mark is part of the group's name in `'group'` mode. `role="group"` does not allow `aria-required`, so do not put it on the group. `required` is accepted so that `FormControl`'s props spread onto the group as they are, and is written to no element: a `<fieldset>` takes no `required`, and on a checkbox it would mean that box must be checked. Check the count with a rule of your own, or with `@k8ordo/form`'s, which a schema's `.min()` derives.
|
|
1127
1223
|
|
|
1128
|
-
|
|
1224
|
+
`invalid` — which `FormControl`'s props carry while its `errorText` is not empty — goes to every box as `aria-invalid` and the invalid look, since `role="group"` does not take `aria-invalid` either.
|
|
1129
1225
|
|
|
1130
|
-
|
|
1226
|
+
`name` goes on every box. It is optional and nothing fills it in: without a `name` the boxes submit nothing, which is what a group that only drives the page (`DataTable`'s column menu) wants even inside a form.
|
|
1131
1227
|
|
|
1132
|
-
Uncontrolled, the selection lives in the checkboxes themselves
|
|
1133
|
-
|
|
1134
|
-
back to `defaultValue` without leaving a stale selection behind.
|
|
1228
|
+
Uncontrolled, the selection lives in the checkboxes themselves, so a form reset
|
|
1229
|
+
puts the boxes back to `defaultValue` without leaving a stale selection behind.
|
|
1135
1230
|
|
|
1136
1231
|
```tsx
|
|
1137
1232
|
import { CheckboxGroup } from '@k8ordo/ui';
|
|
1138
1233
|
|
|
1139
1234
|
<p id="interests-label">Areas of interest</p>
|
|
1140
|
-
<CheckboxGroup
|
|
1235
|
+
<CheckboxGroup
|
|
1141
1236
|
aria-labelledby="interests-label"
|
|
1142
1237
|
name="interests"
|
|
1143
|
-
value={values}
|
|
1144
1238
|
onChange={setValues}
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1239
|
+
options={[
|
|
1240
|
+
{ value: 'music', label: 'Music' },
|
|
1241
|
+
{ value: 'movie', label: 'Film' },
|
|
1242
|
+
]}
|
|
1243
|
+
value={values}
|
|
1244
|
+
/>;
|
|
1149
1245
|
```
|
|
1150
1246
|
|
|
1151
|
-
Props
|
|
1152
|
-
|
|
1153
|
-
- `label`: `string` (required)
|
|
1154
|
-
- `checked`: `boolean`
|
|
1155
|
-
- `defaultChecked`: `boolean`
|
|
1156
|
-
- `indeterminate`: `boolean` (default: `false`)
|
|
1157
|
-
- `invalid`: `boolean` (default: `false`)
|
|
1158
|
-
- `itemValue`: `string`
|
|
1159
|
-
- `labelHidden`: `boolean` (default: `false`)
|
|
1160
|
-
- `onChange`: `(checked: boolean, event: ChangeEvent<HTMLInputElement>) => void`
|
|
1161
|
-
- `ref`: `Ref<HTMLInputElement>`
|
|
1162
|
-
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `type` / `className` / `style` / `value` / `children`.
|
|
1163
|
-
|
|
1164
|
-
Props (CheckboxGroup.Root):
|
|
1247
|
+
Props:
|
|
1165
1248
|
|
|
1166
1249
|
- `aria-labelledby`: `string` (required)
|
|
1167
|
-
- `
|
|
1168
|
-
- `
|
|
1169
|
-
- `
|
|
1250
|
+
- `options`: `readonly Option[]` (required)
|
|
1251
|
+
- `defaultValue`: `readonly string[]`
|
|
1252
|
+
- `disabled`: `boolean` (default: `false`)
|
|
1170
1253
|
- `invalid`: `boolean` (default: `false`)
|
|
1254
|
+
- `name`: `string`
|
|
1171
1255
|
- `onChange`: `(value: string[]) => void`
|
|
1172
1256
|
- `ref`: `Ref<HTMLFieldSetElement>`
|
|
1173
|
-
- `
|
|
1174
|
-
-
|
|
1257
|
+
- `required`: `boolean`
|
|
1258
|
+
- `value`: `readonly string[]`
|
|
1259
|
+
- Other props are forwarded to `FieldsetHTMLAttributes<HTMLFieldSetElement>`, except `className` / `style` / `children` / `role`.
|
|
1175
1260
|
|
|
1176
1261
|
### CheckboxCard
|
|
1177
1262
|
|
|
1178
1263
|
A card-styled checkbox. Uncontrolled, the selection and its look follow the
|
|
1179
1264
|
checkboxes themselves (`:checked`), so a form reset restores both; `onChange`
|
|
1180
|
-
receives the checked values in document order.
|
|
1265
|
+
receives the checked values in document order. Like `CheckboxGroup`, it takes
|
|
1266
|
+
`required` from `FormControl`'s props and writes it to no element; wrap it in
|
|
1267
|
+
`<FormControl labelAs="group" required>`, whose mark is part of the group's
|
|
1268
|
+
name. `invalid` sets `aria-invalid` on every box as well as the look —
|
|
1269
|
+
`role="group"` does not take `aria-invalid` — and while the form's action is
|
|
1270
|
+
pending the boxes take `aria-disabled` and ignore presses, as `Checkbox` does.
|
|
1181
1271
|
|
|
1182
1272
|
```tsx
|
|
1183
1273
|
import { CheckboxCard } from '@k8ordo/ui';
|
|
@@ -1204,15 +1294,25 @@ Props:
|
|
|
1204
1294
|
|
|
1205
1295
|
- `aria-labelledby`: `string` (required)
|
|
1206
1296
|
- `options`: `readonly CheckboxCardOption[]` (required)
|
|
1207
|
-
- `defaultValue`: `string[]`
|
|
1297
|
+
- `defaultValue`: `readonly string[]`
|
|
1208
1298
|
- `invalid`: `boolean` (default: `false`)
|
|
1209
1299
|
- `onChange`: `(value: string[]) => void`
|
|
1210
1300
|
- `ref`: `Ref<HTMLFieldSetElement>`
|
|
1211
|
-
- `
|
|
1301
|
+
- `required`: `boolean`
|
|
1302
|
+
- `value`: `readonly string[]`
|
|
1212
1303
|
- Other props are forwarded to `FieldsetHTMLAttributes<HTMLFieldSetElement>`, except `className` / `style` / `children` / `role`.
|
|
1213
1304
|
|
|
1214
1305
|
### Radio
|
|
1215
1306
|
|
|
1307
|
+
A `div[role="radiogroup"]` of real `input[type="radio"]` elements, named
|
|
1308
|
+
through the required `aria-labelledby`. `name` is optional. Without one, the
|
|
1309
|
+
radios share a name made with `useId`: the browser groups radios by name for
|
|
1310
|
+
single selection and arrow-key roving, so a radio group always has one, and two
|
|
1311
|
+
groups never take each other's selection. `RadioCard` does the same. The
|
|
1312
|
+
checkbox groups (`CheckboxGroup`, `CheckboxCard`) fill in no name, since a box
|
|
1313
|
+
needs none to work and one without a name submits nothing. Pass `name` to
|
|
1314
|
+
submit the choice.
|
|
1315
|
+
|
|
1216
1316
|
```tsx
|
|
1217
1317
|
import { Radio } from '@k8ordo/ui';
|
|
1218
1318
|
|
|
@@ -1244,7 +1344,7 @@ Props:
|
|
|
1244
1344
|
|
|
1245
1345
|
### RadioCard
|
|
1246
1346
|
|
|
1247
|
-
A card-styled radio button. Real `input[type="radio"]` elements sit inside a `fieldset[role="radiogroup"]`, so arrow-key roving and single selection are left to the browser. Reach them from tests with `getByRole('radio', { checked })`. `required` goes to every radio, and an uncontrolled selection's look follows `:checked`, so a form reset restores it.
|
|
1347
|
+
A card-styled radio button. Real `input[type="radio"]` elements sit inside a `fieldset[role="radiogroup"]`, so arrow-key roving and single selection are left to the browser. Reach them from tests with `getByRole('radio', { checked })`. `required` goes to every radio, and an uncontrolled selection's look follows `:checked`, so a form reset restores it. `invalid` sets `aria-invalid` on the group as well as the look, and while the form's action is pending the radios take `aria-disabled` and ignore presses and arrow keys, as `Radio` does.
|
|
1248
1348
|
|
|
1249
1349
|
```tsx
|
|
1250
1350
|
import { RadioCard } from '@k8ordo/ui';
|
|
@@ -1282,8 +1382,9 @@ Props:
|
|
|
1282
1382
|
### Slider
|
|
1283
1383
|
|
|
1284
1384
|
A range slider. Uncontrolled, the value lives in the input, so a form reset
|
|
1285
|
-
puts it back to `defaultValue` and the filled track follows. `min
|
|
1286
|
-
an uncontrolled `defaultValue` also
|
|
1385
|
+
puts it back to `defaultValue` and the filled track follows. `min` and `max`
|
|
1386
|
+
are numbers; an uncontrolled `defaultValue` also takes a string, and `step`
|
|
1387
|
+
takes `'any'`, as `@k8ordo/form` derives them.
|
|
1287
1388
|
|
|
1288
1389
|
```tsx
|
|
1289
1390
|
import { Slider } from '@k8ordo/ui';
|
|
@@ -1296,16 +1397,20 @@ import { Slider } from '@k8ordo/ui';
|
|
|
1296
1397
|
onChange={onChange}
|
|
1297
1398
|
invalid={false}
|
|
1298
1399
|
disabled={false}
|
|
1299
|
-
required={false}
|
|
1300
1400
|
/>;
|
|
1301
1401
|
```
|
|
1302
1402
|
|
|
1403
|
+
`required` is accepted, so `FormControl`'s props and `@k8ordo/form`'s `input`
|
|
1404
|
+
spread onto the slider as they are, and is written to no element: HTML does
|
|
1405
|
+
not allow it on a range, and a range always has a value, so there is nothing
|
|
1406
|
+
to require.
|
|
1407
|
+
|
|
1303
1408
|
Props:
|
|
1304
1409
|
|
|
1305
1410
|
- `defaultValue`: `number` | `string`
|
|
1306
1411
|
- `invalid`: `boolean` (default: `false`)
|
|
1307
|
-
- `max`: `number`
|
|
1308
|
-
- `min`: `number`
|
|
1412
|
+
- `max`: `number` (default: `100`)
|
|
1413
|
+
- `min`: `number` (default: `0`)
|
|
1309
1414
|
- `onChange`: `(value: number) => void`
|
|
1310
1415
|
- `ref`: `Ref<HTMLInputElement>`
|
|
1311
1416
|
- `step`: `number` | `'any'` (default: `1`)
|
|
@@ -1325,8 +1430,13 @@ pair `[lower, upper]`.
|
|
|
1325
1430
|
the thumbs keep their values in the DOM, so a form's reset and its dirty check
|
|
1326
1431
|
(value against default value) work on them as on any input. The whole slider is
|
|
1327
1432
|
a `role="group"`: name it with `aria-label` or `aria-labelledby`
|
|
1328
|
-
(
|
|
1329
|
-
followed by the built-in `rangeSliderStart` / `rangeSliderEnd`
|
|
1433
|
+
(`<FormControl labelAs="group">`'s `renderInput` props), and each thumb is read
|
|
1434
|
+
as that name followed by the built-in `rangeSliderStart` / `rangeSliderEnd`
|
|
1435
|
+
wording.
|
|
1436
|
+
|
|
1437
|
+
As on `Slider`, `required` is accepted and written to no thumb. In
|
|
1438
|
+
`<FormControl labelAs="group" required>` the mark is part of the group's
|
|
1439
|
+
name, so each thumb's name carries it.
|
|
1330
1440
|
|
|
1331
1441
|
```tsx
|
|
1332
1442
|
import { RangeSlider } from '@k8ordo/ui';
|
|
@@ -1350,14 +1460,14 @@ Props:
|
|
|
1350
1460
|
- `name`: `readonly [string, string]`
|
|
1351
1461
|
- `onChange`: `(value: [number, number]) => void`
|
|
1352
1462
|
- `ref`: `Ref<HTMLDivElement>`
|
|
1353
|
-
- `required`: `boolean`
|
|
1463
|
+
- `required`: `boolean`
|
|
1354
1464
|
- `step`: `number` (default: `1`)
|
|
1355
1465
|
- `value`: `readonly [number, number]`
|
|
1356
1466
|
- Other props are forwarded to `HTMLAttributes<HTMLDivElement>`, except `className` / `style` / `children` / `role`.
|
|
1357
1467
|
|
|
1358
1468
|
### Switch
|
|
1359
1469
|
|
|
1360
|
-
A toggle switch.
|
|
1470
|
+
A toggle switch. It is a checkbox underneath (`role="switch"`), so `value` is, as on `Checkbox`, the string it submits under its `name` when on, and `checked` / `defaultChecked` hold the state. Like `Checkbox`, it carries its own label and draws `errorText` / `helpText` itself, describing the input with them; a non-empty `errorText` sets `aria-invalid`.
|
|
1361
1471
|
|
|
1362
1472
|
```tsx
|
|
1363
1473
|
import { Switch } from '@k8ordo/ui';
|
|
@@ -1377,35 +1487,52 @@ Props:
|
|
|
1377
1487
|
- `label`: `string` (required)
|
|
1378
1488
|
- `checked`: `boolean`
|
|
1379
1489
|
- `defaultChecked`: `boolean`
|
|
1490
|
+
- `errorText`: `string`
|
|
1491
|
+
- `helpText`: `string`
|
|
1380
1492
|
- `invalid`: `boolean` (default: `false`)
|
|
1381
1493
|
- `onChange`: `(checked: boolean, event: ChangeEvent<HTMLInputElement>) => void`
|
|
1382
1494
|
- `ref`: `Ref<HTMLInputElement>`
|
|
1383
|
-
-
|
|
1495
|
+
- `value`: `string`
|
|
1496
|
+
- Other props are forwarded to `InputHTMLAttributes<HTMLInputElement>`, except `type` / `role` / `className` / `style` / `children`.
|
|
1384
1497
|
|
|
1385
1498
|
### FileField
|
|
1386
1499
|
|
|
1387
|
-
File upload, as a composite pattern.
|
|
1388
|
-
|
|
1500
|
+
File upload, as a composite pattern. The `<input type="file">` that submits
|
|
1501
|
+
is visually hidden, `aria-hidden`, and out of the Tab order; what a person
|
|
1502
|
+
reaches is the trigger. `FileField.Trigger`'s `renderItem` receives the wiring
|
|
1503
|
+
for it — `id`, `aria-labelledby` (the field's label, then the trigger's own
|
|
1504
|
+
text), `aria-describedby` (the root's), `ref`, `onClick`, and `disabled` —
|
|
1505
|
+
and nothing else, so it spreads onto a `Button` as it is. When a form moves focus to the hidden input after a failed
|
|
1506
|
+
submission, it goes on to the trigger, which `FormControl`'s error text
|
|
1507
|
+
already describes.
|
|
1508
|
+
|
|
1509
|
+
Wrap it in `<FormControl labelAs="group">`. The only element that carries
|
|
1510
|
+
`required` is the hidden input, and a button cannot take it, so the trigger
|
|
1511
|
+
says the field is required through its name: in `'group'` mode the mark is
|
|
1512
|
+
part of the heading the trigger reads, giving "Photos Required Choose files".
|
|
1389
1513
|
|
|
1390
1514
|
```tsx
|
|
1391
|
-
import { FileField } from '@k8ordo/ui';
|
|
1515
|
+
import { FileField, FormControl } from '@k8ordo/ui';
|
|
1392
1516
|
|
|
1393
|
-
<
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1517
|
+
<FormControl
|
|
1518
|
+
label="Photos"
|
|
1519
|
+
labelAs="group"
|
|
1520
|
+
required
|
|
1521
|
+
renderInput={(props) => (
|
|
1522
|
+
<FileField.Root {...props} accept="image/*" multiple maxFiles={5}>
|
|
1523
|
+
<FileField.Trigger
|
|
1524
|
+
renderItem={(wiring) => <Button {...wiring}>Choose files</Button>}
|
|
1525
|
+
/>
|
|
1526
|
+
<FileField.ItemList />
|
|
1527
|
+
</FileField.Root>
|
|
1528
|
+
)}
|
|
1529
|
+
/>;
|
|
1403
1530
|
```
|
|
1404
1531
|
|
|
1405
1532
|
`FileField.Dropzone` is an area files can be dropped onto. Left empty, it holds
|
|
1406
|
-
the built-in `fileFieldDrop` wording and a "choose files" button
|
|
1407
|
-
stays usable by keyboard; pass children to lay it out
|
|
1408
|
-
`FileField.Trigger` inside). Dropped files are added exactly like picked ones:
|
|
1533
|
+
the built-in `fileFieldDrop` wording and a "choose files" button wired as a
|
|
1534
|
+
trigger, so the field stays usable by keyboard; pass children to lay it out
|
|
1535
|
+
yourself (put a `FileField.Trigger` inside). Dropped files are added exactly like picked ones:
|
|
1409
1536
|
they respect `multiple` and `maxFiles`, land in the input so they are
|
|
1410
1537
|
submitted, and are announced with an `input` event so a form sees the change.
|
|
1411
1538
|
A dropped folder is skipped (choose folders through the picker with
|
|
@@ -1422,8 +1549,8 @@ submitted:
|
|
|
1422
1549
|
alone would keep only the files just picked. A rewrite is announced with an
|
|
1423
1550
|
`input` event.
|
|
1424
1551
|
- Removing a file from `ItemList` removes it from the input.
|
|
1425
|
-
-
|
|
1426
|
-
puts both back to
|
|
1552
|
+
- The files in `defaultValue` are submitted as well as listed, and a form
|
|
1553
|
+
reset puts both back to them (to an empty list without one).
|
|
1427
1554
|
- `onChange` receives that whole list — not only the files just picked or
|
|
1428
1555
|
dropped — after every pick, drop, and removal. Only a pick passes the
|
|
1429
1556
|
`event`.
|
|
@@ -1438,7 +1565,7 @@ submitted:
|
|
|
1438
1565
|
Props (Root):
|
|
1439
1566
|
|
|
1440
1567
|
- `children`: `ReactNode`
|
|
1441
|
-
- `defaultValue`: `File[]`
|
|
1568
|
+
- `defaultValue`: `File[]`
|
|
1442
1569
|
- `invalid`: `boolean` (default: `false`)
|
|
1443
1570
|
- `maxFiles`: `number`
|
|
1444
1571
|
- `onChange`: `(files: FileList | null, event?: ChangeEvent<HTMLInputElement>) => void`
|
|
@@ -1457,7 +1584,7 @@ Props (FileField.ItemList):
|
|
|
1457
1584
|
|
|
1458
1585
|
Props (FileField.Trigger):
|
|
1459
1586
|
|
|
1460
|
-
- `renderItem`: `(props: {
|
|
1587
|
+
- `renderItem`: `(props: { id: string; 'aria-labelledby': string | undefined; 'aria-describedby': string | undefined; ref: (node: HTMLElement | null) => void; onClick: () => void; disabled: boolean; }) => ReactElement` (required)
|
|
1461
1588
|
|
|
1462
1589
|
## Data display
|
|
1463
1590
|
|
|
@@ -1489,7 +1616,7 @@ import { Avatar } from '@k8ordo/ui';
|
|
|
1489
1616
|
|
|
1490
1617
|
<Avatar src="/avatar.jpg" alt="User name" size="md" />
|
|
1491
1618
|
<Avatar name="Ada Lovelace" fallback="A" size="lg" />
|
|
1492
|
-
<Avatar color="primary" icon={<
|
|
1619
|
+
<Avatar color="primary" icon={<BotMessageIcon />} name="AI" size="sm" />
|
|
1493
1620
|
```
|
|
1494
1621
|
|
|
1495
1622
|
Props:
|
|
@@ -1546,7 +1673,12 @@ A block of code, highlighted on the server with shiki, with a copy button.
|
|
|
1546
1673
|
It is an async Server Component on its own subpath, `@k8ordo/ui/code-block`,
|
|
1547
1674
|
and imports `server-only`: the highlighter never reaches the browser, and
|
|
1548
1675
|
importing it from a Client Component fails the build. Only the copy button is a
|
|
1549
|
-
client module.
|
|
1676
|
+
client module. shiki is an optional peer, installed by the application that
|
|
1677
|
+
imports `@k8ordo/ui/code-block`:
|
|
1678
|
+
|
|
1679
|
+
```bash
|
|
1680
|
+
pnpm add shiki
|
|
1681
|
+
```
|
|
1550
1682
|
|
|
1551
1683
|
```tsx
|
|
1552
1684
|
import { CodeBlock } from '@k8ordo/ui/code-block';
|
|
@@ -1848,7 +1980,7 @@ import { Tree } from '@k8ordo/ui';
|
|
|
1848
1980
|
```
|
|
1849
1981
|
|
|
1850
1982
|
- Which parents are open is controllable (`expandedIds` / `defaultExpandedIds`
|
|
1851
|
-
/ `
|
|
1983
|
+
/ `onExpandedIdsChange`, called with a new array), and so is the selected node (`selectedId` /
|
|
1852
1984
|
`defaultSelectedId` / `onChange`, called with the node's `id`).
|
|
1853
1985
|
- Keyboard: Down / Up move between the visible nodes; Right opens a closed
|
|
1854
1986
|
parent, then moves to its first child; Left closes an open parent, or moves
|
|
@@ -1871,20 +2003,23 @@ Props:
|
|
|
1871
2003
|
- `defaultSelectedId`: `string` | `null` (default: `null`)
|
|
1872
2004
|
- `expandedIds`: `readonly string[]`
|
|
1873
2005
|
- `onChange`: `(id: string) => void`
|
|
1874
|
-
- `
|
|
2006
|
+
- `onExpandedIdsChange`: `(ids: string[]) => void`
|
|
1875
2007
|
- `selectedId`: `string` | `null`
|
|
1876
2008
|
- Other props are forwarded to `HTMLAttributes<HTMLUListElement>`, except `children` / `className` / `style` / `role` / `aria-label`.
|
|
1877
2009
|
|
|
1878
2010
|
### Accordion
|
|
1879
2011
|
|
|
1880
|
-
A collapsible section, as a compound component.
|
|
2012
|
+
A collapsible section, as a compound component. `Accordion.Button` takes the
|
|
2013
|
+
heading `level` it sits at (required, the same words as `Heading`) and draws
|
|
2014
|
+
the button inside that heading element, as the WAI-ARIA accordion pattern
|
|
2015
|
+
asks; do not wrap it in a heading of your own.
|
|
1881
2016
|
|
|
1882
2017
|
```tsx
|
|
1883
2018
|
import { Accordion } from '@k8ordo/ui';
|
|
1884
2019
|
|
|
1885
2020
|
<Accordion.Root>
|
|
1886
2021
|
<Accordion.Item>
|
|
1887
|
-
<Accordion.Button>Section 1</Accordion.Button>
|
|
2022
|
+
<Accordion.Button level="h3">Section 1</Accordion.Button>
|
|
1888
2023
|
<Accordion.Panel>Content</Accordion.Panel>
|
|
1889
2024
|
</Accordion.Item>
|
|
1890
2025
|
</Accordion.Root>;
|
|
@@ -1892,6 +2027,7 @@ import { Accordion } from '@k8ordo/ui';
|
|
|
1892
2027
|
|
|
1893
2028
|
Props (Accordion.Button):
|
|
1894
2029
|
|
|
2030
|
+
- `level`: `'h2'` | `'h3'` | `'h4'` | `'h5'` | `'h6'` (required)
|
|
1895
2031
|
- `children`: `ReactNode`
|
|
1896
2032
|
|
|
1897
2033
|
Props (Accordion.Item):
|
|
@@ -1921,16 +2057,42 @@ import { Card } from '@k8ordo/ui';
|
|
|
1921
2057
|
<div style={{ padding: 'calc(var(--spacing) * 6)' }}>Content</div>
|
|
1922
2058
|
</Card>
|
|
1923
2059
|
|
|
1924
|
-
//
|
|
1925
|
-
<Card
|
|
1926
|
-
<
|
|
2060
|
+
// The whole card is a link, or a button
|
|
2061
|
+
<Card href="/articles/1">
|
|
2062
|
+
<h3>Article title</h3>
|
|
2063
|
+
<a href="/tags/react">React</a>
|
|
2064
|
+
</Card>
|
|
2065
|
+
<Card action={choose}>
|
|
2066
|
+
<h3>Go with this plan</h3>
|
|
1927
2067
|
</Card>
|
|
1928
2068
|
```
|
|
1929
2069
|
|
|
2070
|
+
`href` makes the whole card one link and `action` one button (`href` wins
|
|
2071
|
+
when both are given). The card draws an `<a>` or a `<button>` over its
|
|
2072
|
+
content, named by the content's text, so a keyboard reaches it and a screen
|
|
2073
|
+
reader announces it. Links, buttons, and fields inside the card are raised
|
|
2074
|
+
above it and stay pressable on their own. `action` runs in a transition, as
|
|
2075
|
+
`Button`'s does: while a promise it returned is pending, the card is busy and
|
|
2076
|
+
ignores presses. With `openInNewTab` the link opens in a new tab and says so
|
|
2077
|
+
to assistive technology the way `Anchor` does: its name ends with the
|
|
2078
|
+
dictionary's `opensInNewTab` wording ("opens in a new tab" in `en`,
|
|
2079
|
+
「新しいタブで開きます」 in `ja`), which the card keeps in a `hidden` element
|
|
2080
|
+
that `aria-labelledby` also points to. Pass `renderAnchor` to draw the link
|
|
2081
|
+
with your router's component; it receives `href`, `className`,
|
|
2082
|
+
`aria-labelledby`, and `target` / `rel` with `openInNewTab`.
|
|
2083
|
+
|
|
2084
|
+
Either one gives the card the pressable look: it scales to 1.02 on hover and to
|
|
2085
|
+
0.98 while pressed. `interactive` gives that look alone, for a card whose
|
|
2086
|
+
content is a link of your own.
|
|
2087
|
+
|
|
1930
2088
|
Props:
|
|
1931
2089
|
|
|
2090
|
+
- `action`: `() => void | Promise<void>`
|
|
1932
2091
|
- `children`: `ReactNode`
|
|
2092
|
+
- `href`: `T`
|
|
1933
2093
|
- `interactive`: `boolean` (default: `false`)
|
|
2094
|
+
- `openInNewTab`: `boolean` (default: `false`)
|
|
2095
|
+
- `renderAnchor`: `(props: CardRenderAnchorProps<T>) => ReactNode` (default: `defaultRenderAnchor`)
|
|
1934
2096
|
- `variant`: `'shadow'` | `'outline'` (default: `'shadow'`)
|
|
1935
2097
|
- `width`: `'full'` | `'fit'` (default: `'full'`)
|
|
1936
2098
|
- Other props are forwarded to `HTMLAttributes<HTMLDivElement>`, except `className` / `style`.
|
|
@@ -1955,14 +2117,22 @@ Props:
|
|
|
1955
2117
|
|
|
1956
2118
|
- `message`: `string` | `string[]` (required)
|
|
1957
2119
|
- `tone`: `Status` (required)
|
|
1958
|
-
- `action`: `
|
|
2120
|
+
- `action`: `ReactNode`
|
|
1959
2121
|
- `closeLabel`: `string`
|
|
1960
2122
|
- `onClose`: `() => void`
|
|
1961
2123
|
- Other props are forwarded to `HTMLAttributes<HTMLDivElement>`, except `children` / `role` / `className` / `style`.
|
|
1962
2124
|
|
|
1963
|
-
`action` is
|
|
1964
|
-
|
|
1965
|
-
|
|
2125
|
+
`action` is the link or button you render — an `Anchor`, a `Button`, a
|
|
2126
|
+
framework's `<Link>` — and `Alert` only decides where it goes: after a
|
|
2127
|
+
one-line message, or below a list. A Server Component can pass it as well.
|
|
2128
|
+
|
|
2129
|
+
```tsx
|
|
2130
|
+
<Alert
|
|
2131
|
+
action={<Anchor href="/settings">Open settings</Anchor>}
|
|
2132
|
+
message="Your profile setup is incomplete."
|
|
2133
|
+
tone="warning"
|
|
2134
|
+
/>
|
|
2135
|
+
```
|
|
1966
2136
|
|
|
1967
2137
|
### Callout
|
|
1968
2138
|
|
|
@@ -1998,7 +2168,8 @@ an optional description and icon, and an optional action. Inside a table, use
|
|
|
1998
2168
|
`Table.EmptyState`, which puts the same content in a row spanning the columns.
|
|
1999
2169
|
|
|
2000
2170
|
```tsx
|
|
2001
|
-
import { Button, EmptyState
|
|
2171
|
+
import { Button, EmptyState } from '@k8ordo/ui';
|
|
2172
|
+
import { TableIcon } from '@k8ordo/ui/icons';
|
|
2002
2173
|
|
|
2003
2174
|
<EmptyState
|
|
2004
2175
|
action={<Button onClick={clearFilters}>Clear filters</Button>}
|
|
@@ -2032,31 +2203,34 @@ const syncingId = open('info', 'Syncing…', {
|
|
|
2032
2203
|
close(syncingId);
|
|
2033
2204
|
```
|
|
2034
2205
|
|
|
2035
|
-
`
|
|
2206
|
+
`useToast` needs a `ToastProvider` above it, once at the app root. Inside a
|
|
2207
|
+
`Dialog` or a `Drawer`, `useToast` opens the toast in that `<dialog>`, since
|
|
2208
|
+
the top layer would cover one opened outside; it goes away when the dialog
|
|
2209
|
+
closes.
|
|
2036
2210
|
|
|
2037
2211
|
What `useToast()` returns:
|
|
2038
2212
|
|
|
2039
|
-
- `open`: `(tone: Status, message: string, options?: ToastOptions) => string` (returns the toast's id; `ToastOptions` is `{ duration?: number; action?:
|
|
2213
|
+
- `open`: `(tone: Status, message: string, options?: ToastOptions) => string` (returns the toast's id; `ToastOptions` is `{ duration?: number; action?: ReactNode }`. `duration` is in milliseconds and defaults to `5000`; `Number.POSITIVE_INFINITY` keeps the toast until it is closed. `action` is a `ReactNode` placed as `Alert`'s `action` is.)
|
|
2040
2214
|
- `close`: `(id: string) => void` (closes only the toast with the id `open` returned)
|
|
2041
2215
|
- `closeAll`: `() => void`
|
|
2042
2216
|
|
|
2043
2217
|
### ToastProvider
|
|
2044
2218
|
|
|
2045
|
-
|
|
2219
|
+
Holds the toasts `useToast` opens. Wrap the app root in it once; an
|
|
2220
|
+
application that opens no toasts needs no provider at all. The components'
|
|
2221
|
+
own wording needs none either: it follows `@k8ordo/i18n` (i18n, below).
|
|
2046
2222
|
|
|
2047
2223
|
```tsx
|
|
2048
2224
|
import { ToastProvider } from '@k8ordo/ui';
|
|
2049
2225
|
|
|
2050
|
-
<ToastProvider
|
|
2051
|
-
|
|
2226
|
+
<ToastProvider>
|
|
2227
|
+
<App />
|
|
2052
2228
|
</ToastProvider>;
|
|
2053
2229
|
```
|
|
2054
2230
|
|
|
2055
2231
|
Props:
|
|
2056
2232
|
|
|
2057
2233
|
- `children`: `ReactNode`
|
|
2058
|
-
- `portalRef`: `RefObject<HTMLElement | null>` (default: `null`)
|
|
2059
|
-
- `position`: `'fixed'` | `'absolute'` (default: `'fixed'`)
|
|
2060
2234
|
|
|
2061
2235
|
### Progress
|
|
2062
2236
|
|
|
@@ -2120,80 +2294,78 @@ Props:
|
|
|
2120
2294
|
|
|
2121
2295
|
## Overlays
|
|
2122
2296
|
|
|
2123
|
-
###
|
|
2297
|
+
### Dialog
|
|
2124
2298
|
|
|
2125
|
-
|
|
2299
|
+
A modal dialog, opened in a `<dialog>` in the browser's top layer from the
|
|
2300
|
+
center of the screen or, with `side="bottom"`, as a sheet from the bottom.
|
|
2301
|
+
`title` is drawn as an `h2` heading with a close button, and it names the
|
|
2302
|
+
dialog; a dialog that draws no heading is named by `label` instead (one or the
|
|
2303
|
+
other, never both). `description` is drawn above the children and is the only
|
|
2304
|
+
text the dialog is described by: the body — a form, the buttons — is never
|
|
2305
|
+
read out as its description. `role="alertdialog"` goes on the `<dialog>`
|
|
2306
|
+
itself, for a confirmation that interrupts.
|
|
2126
2307
|
|
|
2127
2308
|
```tsx
|
|
2128
|
-
import {
|
|
2309
|
+
import { Dialog } from '@k8ordo/ui';
|
|
2129
2310
|
|
|
2130
|
-
<
|
|
2311
|
+
<Dialog isOpen={open} onClose={() => setOpen(false)} title="Confirm">
|
|
2131
2312
|
Content
|
|
2132
|
-
</
|
|
2313
|
+
</Dialog>;
|
|
2314
|
+
|
|
2315
|
+
<Dialog
|
|
2316
|
+
description="A deleted file cannot be restored."
|
|
2317
|
+
isOpen={open}
|
|
2318
|
+
onClose={() => setOpen(false)}
|
|
2319
|
+
role="alertdialog"
|
|
2320
|
+
title="Delete the file?"
|
|
2321
|
+
>
|
|
2322
|
+
<Button onClick={remove}>Delete</Button>
|
|
2323
|
+
</Dialog>;
|
|
2324
|
+
|
|
2325
|
+
<Dialog isOpen={open} label="Image preview" onClose={() => setOpen(false)}>
|
|
2326
|
+
<img alt="" src={src} />
|
|
2327
|
+
</Dialog>;
|
|
2133
2328
|
```
|
|
2134
2329
|
|
|
2135
2330
|
Props:
|
|
2136
2331
|
|
|
2137
|
-
- `aria-describedby`: `string`
|
|
2138
|
-
- `aria-label`: `string`
|
|
2139
|
-
- `aria-labelledby`: `string`
|
|
2140
2332
|
- `children`: `ReactNode`
|
|
2141
2333
|
- `defaultOpen`: `boolean`
|
|
2334
|
+
- `description`: `ReactNode`
|
|
2142
2335
|
- `isOpen`: `boolean`
|
|
2336
|
+
- `label`: `string`
|
|
2143
2337
|
- `onClose`: `() => void`
|
|
2144
2338
|
- `ref`: `Ref<HTMLDialogElement>`
|
|
2145
|
-
- `side`: `ModalSide` (default: `'center'`)
|
|
2146
|
-
|
|
2147
|
-
Name resolution goes `aria-label` / `aria-labelledby` first, then the heading registered by a `Dialog.Root` inside. With neither, the dialog is unnamed — so pass `aria-label` when you place content directly without a `Dialog`.
|
|
2148
|
-
|
|
2149
|
-
```tsx
|
|
2150
|
-
<Modal aria-label="Image preview" isOpen={open} onClose={onClose}>
|
|
2151
|
-
<img alt="" src={src} />
|
|
2152
|
-
</Modal>
|
|
2153
|
-
```
|
|
2154
|
-
|
|
2155
|
-
### Dialog
|
|
2156
|
-
|
|
2157
|
-
A compound component, used together with Modal.
|
|
2158
|
-
|
|
2159
|
-
```tsx
|
|
2160
|
-
import { Modal, Dialog } from '@k8ordo/ui';
|
|
2161
|
-
|
|
2162
|
-
<Modal isOpen={open} onClose={onClose}>
|
|
2163
|
-
<Dialog.Root>
|
|
2164
|
-
<Dialog.Header title="Confirm" onClose={onClose} />
|
|
2165
|
-
<Dialog.Content>Content</Dialog.Content>
|
|
2166
|
-
</Dialog.Root>
|
|
2167
|
-
</Modal>;
|
|
2168
|
-
```
|
|
2169
|
-
|
|
2170
|
-
Props (Dialog.Content):
|
|
2171
|
-
|
|
2172
|
-
- `children`: `ReactNode`
|
|
2173
|
-
|
|
2174
|
-
Props (Dialog.Header):
|
|
2175
|
-
|
|
2176
|
-
- `onClose`: `() => void` (required)
|
|
2177
|
-
- `title`: `ReactNode` (required)
|
|
2178
|
-
|
|
2179
|
-
Props (Dialog.Root):
|
|
2180
|
-
|
|
2181
|
-
- `children`: `ReactNode`
|
|
2182
|
-
- `id`: `string`
|
|
2183
|
-
- `ref`: `Ref<HTMLElement>`
|
|
2184
2339
|
- `role`: `'dialog'` | `'alertdialog'`
|
|
2185
|
-
- `
|
|
2340
|
+
- `side`: `DialogSide` (default: `'center'`)
|
|
2341
|
+
- `title`: `ReactNode`
|
|
2342
|
+
|
|
2343
|
+
`onClose` is called when the dialog closes while it is meant to be open —
|
|
2344
|
+
Escape, a click on the backdrop, the close button, a `<form method="dialog">`,
|
|
2345
|
+
or `<Activity>` hiding it — and never when you set `isOpen` to `false`
|
|
2346
|
+
yourself, so a route-bound dialog that goes back in `onClose` does not go back
|
|
2347
|
+
twice. The children stay mounted while the dialog is closed, so an
|
|
2348
|
+
uncontrolled field keeps what was typed until the next opening; render them
|
|
2349
|
+
under `isOpen` when they should start over. `ref` is the `<dialog>` element.
|
|
2350
|
+
|
|
2351
|
+
A dialog opens in the browser's top layer, and the page behind it is inert, so
|
|
2352
|
+
anything portaled to `document.body` ends up behind it and cannot be pressed.
|
|
2353
|
+
Floating UI of your own opens in place with the `popover` attribute, which
|
|
2354
|
+
reaches the top layer from where it is. A library that portals takes the
|
|
2355
|
+
dialog's `<dialog>` from `ref` as its container; if a part deep inside needs
|
|
2356
|
+
it, put your own Context in the children.
|
|
2186
2357
|
|
|
2187
2358
|
### CommandPalette
|
|
2188
2359
|
|
|
2189
|
-
A command palette: a
|
|
2190
|
-
filters. Typing matches each item's `label` and `keywords`, case-insensitively
|
|
2360
|
+
A command palette: a modal dialog holding a search field and the list of commands it
|
|
2361
|
+
filters. Typing matches each item's `label` and `keywords`, case-insensitively
|
|
2362
|
+
in the language of `@k8ordo/i18n`'s current locale.
|
|
2191
2363
|
`ArrowDown` / `ArrowUp` move through the matches and wrap around, `Enter` or a
|
|
2192
|
-
click runs the item's `
|
|
2364
|
+
click runs the item's `onAction` after closing the palette, and `Escape` closes
|
|
2193
2365
|
it; focus stays in the search field throughout (the WAI-ARIA combobox, with the
|
|
2194
2366
|
list always shown). Items that share a `group` are gathered under that heading,
|
|
2195
2367
|
in the order the group first appears, and `shortcut` keys are drawn with `Kbd`.
|
|
2196
|
-
Each opening starts from an empty search. Open and close it like `
|
|
2368
|
+
Each opening starts from an empty search. Open and close it like `Dialog`
|
|
2197
2369
|
(`isOpen` / `defaultOpen` / `onClose`); a key such as ⌘K / Ctrl+K is the
|
|
2198
2370
|
application's to wire.
|
|
2199
2371
|
|
|
@@ -2209,13 +2381,13 @@ import { CommandPalette } from '@k8ordo/ui';
|
|
|
2209
2381
|
label: 'New file',
|
|
2210
2382
|
group: 'File',
|
|
2211
2383
|
shortcut: ['⌘', 'N'],
|
|
2212
|
-
|
|
2384
|
+
onAction: createFile,
|
|
2213
2385
|
},
|
|
2214
2386
|
{
|
|
2215
2387
|
id: 'theme',
|
|
2216
2388
|
label: 'Toggle theme',
|
|
2217
2389
|
keywords: ['dark', 'light'],
|
|
2218
|
-
|
|
2390
|
+
onAction: toggleTheme,
|
|
2219
2391
|
},
|
|
2220
2392
|
]}
|
|
2221
2393
|
/>;
|
|
@@ -2224,21 +2396,27 @@ import { CommandPalette } from '@k8ordo/ui';
|
|
|
2224
2396
|
Props:
|
|
2225
2397
|
|
|
2226
2398
|
- `items`: `readonly CommandPaletteItem[]` (required)
|
|
2227
|
-
- `aria-label`: `string`
|
|
2228
2399
|
- `defaultOpen`: `boolean`
|
|
2229
2400
|
- `isOpen`: `boolean`
|
|
2401
|
+
- `label`: `string`
|
|
2230
2402
|
- `onClose`: `() => void`
|
|
2231
2403
|
- `placeholder`: `string`
|
|
2232
2404
|
- `ref`: `Ref<HTMLDialogElement>`
|
|
2233
2405
|
|
|
2234
2406
|
### Drawer
|
|
2235
2407
|
|
|
2236
|
-
A
|
|
2408
|
+
A panel that slides in from the left or right edge of the screen, in a
|
|
2409
|
+
`<dialog>` like `Dialog`. `title` is drawn as an `h2` heading with a close
|
|
2410
|
+
button and names the drawer, and `description`, drawn above the children, is
|
|
2411
|
+
the only text it is described by. The body scrolls on its own below the
|
|
2412
|
+
heading. `onClose` and the children follow `Dialog`'s rules: it is called only
|
|
2413
|
+
when the drawer closes while it is meant to be open, and the children stay
|
|
2414
|
+
mounted while it is closed.
|
|
2237
2415
|
|
|
2238
2416
|
```tsx
|
|
2239
2417
|
import { Drawer } from '@k8ordo/ui';
|
|
2240
2418
|
|
|
2241
|
-
<Drawer
|
|
2419
|
+
<Drawer isOpen={open} onClose={() => setOpen(false)} side="left" title="Menu">
|
|
2242
2420
|
Content
|
|
2243
2421
|
</Drawer>;
|
|
2244
2422
|
```
|
|
@@ -2248,43 +2426,59 @@ Props:
|
|
|
2248
2426
|
- `title`: `ReactNode` (required)
|
|
2249
2427
|
- `children`: `ReactNode`
|
|
2250
2428
|
- `defaultOpen`: `boolean`
|
|
2429
|
+
- `description`: `ReactNode`
|
|
2251
2430
|
- `isOpen`: `boolean`
|
|
2252
2431
|
- `onClose`: `() => void`
|
|
2432
|
+
- `ref`: `Ref<HTMLDialogElement>`
|
|
2253
2433
|
- `side`: `DrawerSide` (default: `'right'`)
|
|
2254
2434
|
|
|
2255
2435
|
### Popover
|
|
2256
2436
|
|
|
2257
|
-
A
|
|
2437
|
+
A panel that opens next to its trigger, placed with CSS Anchor Positioning, as
|
|
2438
|
+
a compound component. It is always a dialog: `Popover.Content` renders
|
|
2439
|
+
`role="dialog"` named by `label`, opening moves focus into it, and a click
|
|
2440
|
+
outside, Escape, or tabbing out closes it. The content draws the surface — the
|
|
2441
|
+
raised ground, the corners, the shadow, and an outline under high contrast —
|
|
2442
|
+
and no padding, so the padding comes from what you put inside.
|
|
2258
2443
|
|
|
2259
2444
|
```tsx
|
|
2260
2445
|
import { Popover } from '@k8ordo/ui';
|
|
2261
2446
|
|
|
2262
2447
|
<Popover.Root placement="bottom">
|
|
2263
2448
|
<Popover.Trigger renderItem={(props) => <Button {...props}>Open</Button>} />
|
|
2264
|
-
<Popover.Content
|
|
2265
|
-
|
|
2266
|
-
|
|
2449
|
+
<Popover.Content label="Filters">
|
|
2450
|
+
<Stack gap="sm" padding="md">
|
|
2451
|
+
…
|
|
2452
|
+
</Stack>
|
|
2453
|
+
</Popover.Content>
|
|
2267
2454
|
</Popover.Root>;
|
|
2268
2455
|
```
|
|
2269
2456
|
|
|
2457
|
+
A menu, a listbox, and a tooltip are their own components (`DropdownMenu`,
|
|
2458
|
+
`ListBox`, `Tooltip`); they are built on the same positioning.
|
|
2459
|
+
|
|
2460
|
+
The trigger is the content's implicit anchor: the content opens with
|
|
2461
|
+
`showPopover({ source: trigger })` and positions itself with
|
|
2462
|
+
`position-anchor: auto`. Nothing is written to the trigger's `anchor-name`, so
|
|
2463
|
+
one element can be the trigger of a popover and of a tooltip at once (an
|
|
2464
|
+
`IconButton` as a `Popover.Trigger`), and a trigger keeps an `anchor-name` of
|
|
2465
|
+
its own.
|
|
2466
|
+
|
|
2270
2467
|
Props (Root):
|
|
2271
2468
|
|
|
2272
2469
|
- `children`: `ReactNode`
|
|
2273
|
-
- `closeOnClickAway`: `boolean` (default: `true`)
|
|
2274
2470
|
- `defaultOpen`: `boolean` (default: `false`)
|
|
2275
2471
|
- `flipDisabled`: `boolean` (default: `false`)
|
|
2276
2472
|
- `isOpen`: `boolean`
|
|
2277
2473
|
- `onChange`: `(isOpen: boolean) => void`
|
|
2278
2474
|
- `placement`: `Placement` (default: `'bottom-start'`)
|
|
2279
|
-
- `role`: `'dialog'` | `'menu'` | `'listbox'` (default: `'menu'`)
|
|
2280
|
-
- `trapFocus`: `boolean` (default: `true`)
|
|
2281
2475
|
|
|
2282
2476
|
Escape closes **only the innermost one** when they are nested.
|
|
2283
2477
|
|
|
2284
2478
|
Props (Popover.Content):
|
|
2285
2479
|
|
|
2286
|
-
- `
|
|
2287
|
-
- `
|
|
2480
|
+
- `children`: `ReactNode` (required)
|
|
2481
|
+
- `label`: `string` (required)
|
|
2288
2482
|
|
|
2289
2483
|
Props (Popover.Trigger):
|
|
2290
2484
|
|
|
@@ -2337,6 +2531,27 @@ import { DropdownMenu } from '@k8ordo/ui';
|
|
|
2337
2531
|
</DropdownMenu.Root>;
|
|
2338
2532
|
```
|
|
2339
2533
|
|
|
2534
|
+
An item is an action or a link. With `onAction` it renders a `<button
|
|
2535
|
+
role="menuitem">` and calls `onAction` when chosen. With `href` it renders an
|
|
2536
|
+
`<a role="menuitem">`: choosing it closes the menu and leaves the navigation to
|
|
2537
|
+
the browser, so the router's interception, a middle click, and opening in a new
|
|
2538
|
+
tab all work. Space chooses a link item as it does a button item, rather than
|
|
2539
|
+
scrolling the page. `renderAnchor` draws a link component of your own instead;
|
|
2540
|
+
its bag is `href`, `className`, `children`, `role`, and the keyboard wiring
|
|
2541
|
+
(`id`, `ref`, `tabIndex`, `onFocus`, `onClick`, `onKeyDown`), so spread all of
|
|
2542
|
+
it.
|
|
2543
|
+
|
|
2544
|
+
```tsx
|
|
2545
|
+
<DropdownMenu.Content>
|
|
2546
|
+
<DropdownMenu.Item href="/settings" label="Settings" />
|
|
2547
|
+
<DropdownMenu.Item
|
|
2548
|
+
href="/billing"
|
|
2549
|
+
label="Billing"
|
|
2550
|
+
renderAnchor={(props) => <Link {...props} />}
|
|
2551
|
+
/>
|
|
2552
|
+
</DropdownMenu.Content>
|
|
2553
|
+
```
|
|
2554
|
+
|
|
2340
2555
|
Props (Root):
|
|
2341
2556
|
|
|
2342
2557
|
- `children`: `ReactNode`
|
|
@@ -2347,8 +2562,8 @@ Props (Root):
|
|
|
2347
2562
|
|
|
2348
2563
|
Trigger variants:
|
|
2349
2564
|
|
|
2350
|
-
- `DropdownMenu.Trigger`: text-based (`label`, `size`, `variant`)
|
|
2351
|
-
- `DropdownMenu.IconTrigger`: icon-based (`icon`, `label`)
|
|
2565
|
+
- `DropdownMenu.Trigger`: text-based (`label`, and `Button`'s `size`, `variant`, `color`)
|
|
2566
|
+
- `DropdownMenu.IconTrigger`: icon-based (`icon`, `label`, and `IconButton`'s `size`, `variant`, `color`)
|
|
2352
2567
|
|
|
2353
2568
|
Props (DropdownMenu.Content):
|
|
2354
2569
|
|
|
@@ -2358,11 +2573,16 @@ Props (DropdownMenu.IconTrigger):
|
|
|
2358
2573
|
|
|
2359
2574
|
- `icon`: `ReactNode` (required)
|
|
2360
2575
|
- `label`: `string` (required)
|
|
2576
|
+
- `color`: `ComponentProps<typeof IconButton>['color']` (default: `'base'`)
|
|
2577
|
+
- `size`: `ComponentProps<typeof IconButton>['size']` (default: `'md'`)
|
|
2578
|
+
- `variant`: `ComponentProps<typeof IconButton>['variant']` (default: `'solid'`)
|
|
2361
2579
|
|
|
2362
2580
|
Props (DropdownMenu.Item):
|
|
2363
2581
|
|
|
2364
2582
|
- `label`: `string` (required)
|
|
2365
|
-
- `
|
|
2583
|
+
- `href`: `T`
|
|
2584
|
+
- `onAction`: `() => void`
|
|
2585
|
+
- `renderAnchor`: `(props: RenderItemAnchorProps<T>) => ReactNode` (default: `defaultRenderAnchor`)
|
|
2366
2586
|
|
|
2367
2587
|
`DropdownMenu.SubMenu` is a nested menu. Hovering the `label` row, or opening it from the keyboard, opens the child menu to the right.
|
|
2368
2588
|
|
|
@@ -2374,6 +2594,7 @@ Props (DropdownMenu.SubMenu):
|
|
|
2374
2594
|
Props (DropdownMenu.Trigger):
|
|
2375
2595
|
|
|
2376
2596
|
- `label`: `string` (required)
|
|
2597
|
+
- `color`: `ComponentProps<typeof Button>['color']` (default: `'base'`)
|
|
2377
2598
|
- `size`: `ComponentProps<typeof Button>['size']` (default: `'md'`)
|
|
2378
2599
|
- `variant`: `ComponentProps<typeof Button>['variant']` (default: `'solid'`)
|
|
2379
2600
|
|
|
@@ -2381,8 +2602,8 @@ Props (DropdownMenu.Trigger):
|
|
|
2381
2602
|
|
|
2382
2603
|
A menu opened by right-clicking (or by the keyboard's context-menu key or
|
|
2383
2604
|
Shift+F10) on an area, shown at the pointer. The inside is `DropdownMenu`'s —
|
|
2384
|
-
`ContextMenu.Content`, `ContextMenu.Item` (`label`
|
|
2385
|
-
`ContextMenu.SubMenu` behave exactly like theirs — and only how it opens and
|
|
2605
|
+
`ContextMenu.Content`, `ContextMenu.Item` (`label` with `onAction` or `href`),
|
|
2606
|
+
and `ContextMenu.SubMenu` behave exactly like theirs — and only how it opens and
|
|
2386
2607
|
where differ. When it closes from inside (an item, Escape), focus returns to
|
|
2387
2608
|
the element that had it before it opened; closing by clicking elsewhere leaves
|
|
2388
2609
|
focus where the click put it.
|
|
@@ -2426,7 +2647,9 @@ Props (ContextMenu.Content):
|
|
|
2426
2647
|
Props (ContextMenu.Item):
|
|
2427
2648
|
|
|
2428
2649
|
- `label`: `string` (required)
|
|
2429
|
-
- `
|
|
2650
|
+
- `href`: `T`
|
|
2651
|
+
- `onAction`: `() => void`
|
|
2652
|
+
- `renderAnchor`: `(props: RenderItemAnchorProps<T>) => ReactNode` (default: `defaultRenderAnchor`)
|
|
2430
2653
|
|
|
2431
2654
|
Props (ContextMenu.SubMenu):
|
|
2432
2655
|
|
|
@@ -2439,54 +2662,37 @@ Props (ContextMenu.Trigger):
|
|
|
2439
2662
|
|
|
2440
2663
|
### ListBox
|
|
2441
2664
|
|
|
2442
|
-
|
|
2665
|
+
Picks one option from a list that opens from a button. The choices use the same `Option` (`{ value, label }`) as `Select`. It is one component: the button shows the current value, or an icon when `icon` is given, and the list holds `options`.
|
|
2443
2666
|
|
|
2444
2667
|
```tsx
|
|
2445
2668
|
import { ListBox } from '@k8ordo/ui';
|
|
2446
2669
|
|
|
2447
|
-
<ListBox
|
|
2670
|
+
<ListBox
|
|
2671
|
+
label="Items per page"
|
|
2448
2672
|
onChange={onChange}
|
|
2449
2673
|
options={[
|
|
2450
2674
|
{ value: '1', label: 'Option 1' },
|
|
2451
2675
|
{ value: '2', label: 'Option 2' },
|
|
2452
2676
|
]}
|
|
2453
2677
|
value={value}
|
|
2454
|
-
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
</ListBox.Root>;
|
|
2678
|
+
/>;
|
|
2679
|
+
|
|
2680
|
+
<ListBox icon={<ListIcon />} label="Sort" options={sortOptions} />;
|
|
2458
2681
|
```
|
|
2459
2682
|
|
|
2460
|
-
Props
|
|
2683
|
+
Props:
|
|
2461
2684
|
|
|
2462
2685
|
- `options`: `readonly Option[]` (required)
|
|
2463
|
-
- `children`: `ReactNode`
|
|
2464
2686
|
- `defaultValue`: `Option['value']`
|
|
2687
|
+
- `helpContent`: `ReactElement`
|
|
2688
|
+
- `icon`: `ReactElement`
|
|
2689
|
+
- `label`: `string`
|
|
2465
2690
|
- `onChange`: `(value: Option['value']) => void`
|
|
2466
2691
|
- `placement`: `Placement` (default: `'bottom'`)
|
|
2692
|
+
- `size`: `'sm'` | `'md'` | `'lg'` (default: `'md'`)
|
|
2467
2693
|
- `value`: `Option['value']`
|
|
2468
2694
|
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
- `ListBox.Trigger`: text-based (`size`, `label`)
|
|
2472
|
-
- `ListBox.IconTrigger`: icon-based (`size`, `icon`, `label`)
|
|
2473
|
-
|
|
2474
|
-
Passing `label` makes the trigger's accessible name "label + current value". Omit it and only the current value is used, so pass it when there is no heading nearby.
|
|
2475
|
-
|
|
2476
|
-
Props (Content):
|
|
2477
|
-
|
|
2478
|
-
- `helpContent`: `ReactElement`
|
|
2479
|
-
|
|
2480
|
-
Props (ListBox.IconTrigger):
|
|
2481
|
-
|
|
2482
|
-
- `icon`: `ReactElement` (required)
|
|
2483
|
-
- `label`: `string`
|
|
2484
|
-
- `size`: `ComponentProps<typeof Button>['size']` (default: `'md'`)
|
|
2485
|
-
|
|
2486
|
-
Props (ListBox.Trigger):
|
|
2487
|
-
|
|
2488
|
-
- `label`: `string`
|
|
2489
|
-
- `size`: `ComponentProps<typeof Button>['size']` (default: `'md'`)
|
|
2695
|
+
Passing `label` makes the button's accessible name "label + current value". Omit it and only the current value is used, so pass it when there is no heading nearby. `helpContent` sits above the list, outside `role="listbox"`, and describes the list.
|
|
2490
2696
|
|
|
2491
2697
|
## Layout
|
|
2492
2698
|
|
|
@@ -2620,90 +2826,26 @@ Props (ResizablePanels.Handle):
|
|
|
2620
2826
|
- _No props of its own._
|
|
2621
2827
|
- Other props are forwarded to `HTMLAttributes<HTMLDivElement>`, except `className` / `style` / `role` / `children` / `tabIndex` / `aria-orientation` / `aria-valuenow` / `aria-valuemin` / `aria-valuemax` / `aria-controls`.
|
|
2622
2828
|
|
|
2623
|
-
## Observers
|
|
2624
|
-
|
|
2625
|
-
Components that watch their children and report back without adding a wrapper
|
|
2626
|
-
element. They are built on React's Fragment refs, so whatever the children
|
|
2627
|
-
render is what gets observed — including host elements that mount later.
|
|
2628
|
-
|
|
2629
|
-
### InView
|
|
2630
|
-
|
|
2631
|
-
Reports whether its children are inside the viewport, or inside `root`.
|
|
2632
|
-
|
|
2633
|
-
```tsx
|
|
2634
|
-
import { InView } from '@k8ordo/ui';
|
|
2635
|
-
|
|
2636
|
-
const [isInView, setIsInView] = useState(false);
|
|
2637
|
-
|
|
2638
|
-
<InView onChange={setIsInView}>
|
|
2639
|
-
<section>…</section>
|
|
2640
|
-
</InView>;
|
|
2641
|
-
|
|
2642
|
-
// inside a scroll container, and only until it has been seen once
|
|
2643
|
-
const [container, setContainer] = useState<HTMLElement | null>(null);
|
|
2644
|
-
|
|
2645
|
-
<div ref={setContainer} style={{ overflowY: 'auto' }}>
|
|
2646
|
-
<InView once onChange={reveal} root={container} rootMargin="0px 0px 24px 0px">
|
|
2647
|
-
<img alt="" src="…" />
|
|
2648
|
-
</InView>
|
|
2649
|
-
</div>;
|
|
2650
|
-
```
|
|
2651
|
-
|
|
2652
|
-
- `onChange` reports the state as soon as a host element is observed, then again
|
|
2653
|
-
each time it flips. The same value is never reported twice in a row, even
|
|
2654
|
-
when `root` changes and the observer is re-created.
|
|
2655
|
-
- With several host elements, `isInView` is `true` while **any** of them
|
|
2656
|
-
intersects, and it follows children that mount or unmount later. While the
|
|
2657
|
-
children render no host element, `onChange` is not called at all — the first
|
|
2658
|
-
report comes once one mounts.
|
|
2659
|
-
- `once` stops observing after the first `true`.
|
|
2660
|
-
- Hold `root` in state, not a `RefObject`: the observer has to be re-created
|
|
2661
|
-
once the element exists.
|
|
2662
|
-
|
|
2663
|
-
Props:
|
|
2664
|
-
|
|
2665
|
-
- `children`: `ReactNode` (required)
|
|
2666
|
-
- `onChange`: `(isInView: boolean) => void` (required)
|
|
2667
|
-
- `once`: `boolean` (default: `false`)
|
|
2668
|
-
- `root`: `Element` | `null` (default: `null`)
|
|
2669
|
-
- `rootMargin`: `string` (default: `'0px'`)
|
|
2670
|
-
- `threshold`: `number` (default: `0`)
|
|
2671
|
-
|
|
2672
|
-
### Resize
|
|
2673
|
-
|
|
2674
|
-
Calls `onChange` when the size of its children changes.
|
|
2675
|
-
|
|
2676
|
-
```tsx
|
|
2677
|
-
import { Resize } from '@k8ordo/ui';
|
|
2678
|
-
|
|
2679
|
-
<Resize onChange={remeasure}>
|
|
2680
|
-
<div>…</div>
|
|
2681
|
-
</Resize>;
|
|
2682
|
-
```
|
|
2683
|
-
|
|
2684
|
-
- `onChange` is also called once when observation starts, as a native
|
|
2685
|
-
`ResizeObserver` is.
|
|
2686
|
-
- It takes no argument; read what you need from the DOM in the handler.
|
|
2687
|
-
|
|
2688
|
-
Props:
|
|
2689
|
-
|
|
2690
|
-
- `children`: `ReactNode` (required)
|
|
2691
|
-
- `onChange`: `() => void` (required)
|
|
2692
|
-
|
|
2693
2829
|
## Icons
|
|
2694
2830
|
|
|
2695
|
-
Decorative icons,
|
|
2696
|
-
`aria-hidden
|
|
2697
|
-
control around it — an `IconButton`'s
|
|
2831
|
+
Decorative icons, from `@k8ordo/ui/icons` (the root entry does not export
|
|
2832
|
+
them). Each renders an `<svg>` with `aria-hidden`, so
|
|
2833
|
+
the accessible name belongs to the control around it — an `IconButton`'s
|
|
2834
|
+
`label`, for example. They are drawn as lines in `currentColor`, so an icon
|
|
2835
|
+
takes the text color of where it sits.
|
|
2698
2836
|
|
|
2699
2837
|
```tsx
|
|
2700
|
-
import { AlertIcon, ChevronIcon,
|
|
2838
|
+
import { AlertIcon, ChevronIcon, XIcon } from '@k8ordo/ui/icons';
|
|
2701
2839
|
|
|
2702
|
-
<
|
|
2840
|
+
<XIcon />
|
|
2703
2841
|
<ChevronIcon direction="down" size="sm" />
|
|
2704
2842
|
<AlertIcon status="warning" />
|
|
2705
2843
|
```
|
|
2706
2844
|
|
|
2845
|
+
An icon is named for what it draws, not for what it means in one application:
|
|
2846
|
+
`BookmarkIcon`, not "subscribe"; `EyeIcon`, not "show". Each one is a module of
|
|
2847
|
+
its own, so a bundler ships only the icons a page draws.
|
|
2848
|
+
|
|
2707
2849
|
Every icon takes one optional prop and nothing else:
|
|
2708
2850
|
|
|
2709
2851
|
- `size`: `'xs'` | `'sm'` | `'md'` | `'lg'` | `'xl'` | `'2xl'` | `'3xl'` (default: `'md'`)
|
|
@@ -2715,65 +2857,54 @@ Two of them also require a prop that picks the glyph:
|
|
|
2715
2857
|
|
|
2716
2858
|
<!-- generated:icons -->
|
|
2717
2859
|
|
|
2718
|
-
The icons: `
|
|
2719
|
-
`
|
|
2720
|
-
`
|
|
2721
|
-
`
|
|
2722
|
-
`
|
|
2723
|
-
`
|
|
2724
|
-
`
|
|
2725
|
-
`
|
|
2726
|
-
`
|
|
2727
|
-
`
|
|
2728
|
-
`
|
|
2729
|
-
`
|
|
2730
|
-
`
|
|
2731
|
-
`
|
|
2860
|
+
The icons: `AlertIcon`, `ArrowDownIcon`, `ArrowLeftIcon`, `ArrowRightIcon`,
|
|
2861
|
+
`ArrowUpIcon`, `BellIcon`, `BlendIcon`, `BookmarkIcon`, `BookTextIcon`,
|
|
2862
|
+
`BotIcon`, `BotMessageIcon`, `CalendarIcon`, `CheckIcon`, `ChevronDownIcon`,
|
|
2863
|
+
`ChevronIcon`, `ChevronLeftIcon`, `ChevronRightIcon`, `ChevronsUpDownIcon`,
|
|
2864
|
+
`ChevronUpIcon`, `CircleAlertIcon`, `CircleCheckIcon`, `CircleHelpIcon`,
|
|
2865
|
+
`CircleXIcon`, `ClipboardCheckIcon`, `ClockIcon`, `CodeIcon`, `ColorScaleIcon`,
|
|
2866
|
+
`ContrastIcon`, `CopyIcon`, `DownloadIcon`, `EllipsisIcon`,
|
|
2867
|
+
`EllipsisVerticalIcon`, `ExternalLinkIcon`, `EyeClosedIcon`, `EyeIcon`,
|
|
2868
|
+
`FileIcon`, `FileTextIcon`, `FilterIcon`, `FlaskIcon`, `FolderIcon`,
|
|
2869
|
+
`FolderOpenIcon`, `GitForkIcon`, `GitPullRequestIcon`, `GlobeIcon`, `GridIcon`,
|
|
2870
|
+
`GripVerticalIcon`, `HeartIcon`, `HistoryIcon`, `HomeIcon`, `ImageIcon`,
|
|
2871
|
+
`InfoIcon`, `LightbulbIcon`, `LinkIcon`, `ListIcon`, `LockIcon`, `LockOpenIcon`,
|
|
2872
|
+
`LogInIcon`, `LogOutIcon`, `MailIcon`, `MapPinIcon`, `MaximizeIcon`, `MenuIcon`,
|
|
2873
|
+
`MessageCircleIcon`, `MinimizeIcon`, `MinusIcon`, `MonitorIcon`, `MoonIcon`,
|
|
2874
|
+
`PackageIcon`, `PaintBucketIcon`, `PaletteIcon`, `PanelLeftIcon`,
|
|
2875
|
+
`PaperclipIcon`, `PauseIcon`, `PencilIcon`, `PinIcon`, `PlayIcon`, `PlusIcon`,
|
|
2876
|
+
`PresentationIcon`, `RedoIcon`, `RefreshIcon`, `RocketIcon`, `RssIcon`,
|
|
2877
|
+
`SearchIcon`, `SendIcon`, `SettingsIcon`, `ShareIcon`, `ShieldCheckIcon`,
|
|
2878
|
+
`SmileIcon`, `SparklesIcon`, `SquareIcon`, `SquircleIcon`, `StarIcon`,
|
|
2879
|
+
`SunIcon`, `TableIcon`, `TagIcon`, `TextHorizontalIcon`, `TextVerticalIcon`,
|
|
2880
|
+
`ThumbsDownIcon`, `ThumbsUpIcon`, `TrashIcon`, `TriangleAlertIcon`, `UndoIcon`,
|
|
2881
|
+
`UploadIcon`, `UserIcon`, `UsersIcon`, `XIcon`.
|
|
2732
2882
|
|
|
2733
2883
|
<!-- /generated:icons -->
|
|
2734
2884
|
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
|
|
2738
|
-
`IconRenderProps` (`{ className: string; 'aria-hidden': true; focusable: 'false' }`)
|
|
2739
|
-
are exported as well.
|
|
2740
|
-
|
|
2741
|
-
## Providers
|
|
2742
|
-
|
|
2743
|
-
### UIProvider
|
|
2744
|
-
|
|
2745
|
-
Wrap the app root once. It includes ToastProvider. The components' own wording needs no provider: it follows `@k8ordo/i18n` (i18n, below).
|
|
2885
|
+
There are no logos here: a brand mark belongs to the application that shows
|
|
2886
|
+
it. Draw one, or any icon this set lacks, on `BaseIcon`, which gives an `<svg>`
|
|
2887
|
+
of your own the same sizes and the same decorative attributes:
|
|
2746
2888
|
|
|
2747
2889
|
```tsx
|
|
2748
|
-
import {
|
|
2890
|
+
import { BaseIcon } from '@k8ordo/ui/icons';
|
|
2891
|
+
import type { BaseIconProps } from '@k8ordo/ui/icons';
|
|
2749
2892
|
|
|
2750
|
-
<
|
|
2751
|
-
<
|
|
2752
|
-
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2757
|
-
|
|
2758
|
-
|
|
2759
|
-
|
|
2760
|
-
|
|
2761
|
-
A context that shares a portal container with your own `createPortal` calls;
|
|
2762
|
-
read it with `usePortalRoot()`. The library's overlays do not read it — they
|
|
2763
|
-
open in the top layer (`<dialog>`, the Popover API), and toasts go where
|
|
2764
|
-
`ToastProvider`'s `portalRef` points. `Modal` passes its own `<dialog>` as the
|
|
2765
|
-
value, so a portal placed through `usePortalRoot()` inside a modal stays in it.
|
|
2766
|
-
|
|
2767
|
-
```tsx
|
|
2768
|
-
import { PortalRootProvider, usePortalRoot } from '@k8ordo/ui';
|
|
2769
|
-
|
|
2770
|
-
<PortalRootProvider value={containerRef}>{children}</PortalRootProvider>;
|
|
2893
|
+
export const BrandIcon = ({ size = 'md' }: Partial<BaseIconProps>) => (
|
|
2894
|
+
<BaseIcon
|
|
2895
|
+
renderItem={(props) => (
|
|
2896
|
+
<svg {...props} fill="currentColor" viewBox="0 0 16 16">
|
|
2897
|
+
<path d="…" />
|
|
2898
|
+
</svg>
|
|
2899
|
+
)}
|
|
2900
|
+
size={size}
|
|
2901
|
+
/>
|
|
2902
|
+
);
|
|
2771
2903
|
```
|
|
2772
2904
|
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
- `children`: `ReactNode`
|
|
2905
|
+
`renderItem` receives `IconRenderProps`
|
|
2906
|
+
(`{ className: string; 'aria-hidden': true }`); the types
|
|
2907
|
+
`BaseIconProps` (`{ size }`) and `IconRenderProps` are exported as well.
|
|
2777
2908
|
|
|
2778
2909
|
## i18n (message dictionary)
|
|
2779
2910
|
|
|
@@ -2801,7 +2932,7 @@ A regional tag without a dictionary of its own (`en-US`) reads its language's (`
|
|
|
2801
2932
|
|
|
2802
2933
|
**Component prop > registered dictionary > built-in dictionary**.
|
|
2803
2934
|
|
|
2804
|
-
A component with a wording prop of its own — `Spinner`'s `label`, `Alert`'s `closeLabel`, `PasswordInput`'s `showLabel` / `hideLabel`, `Pagination`'s `prevLabel` / `nextLabel` — takes that prop over the dictionary.
|
|
2935
|
+
A component with a wording prop of its own — `Spinner`'s `label`, `Alert`'s `closeLabel`, `PasswordInput`'s `showLabel` / `hideLabel`, `Pagination`'s `label` / `prevLabel` / `nextLabel`, `CommandPalette`'s `label` — takes that prop over the dictionary.
|
|
2805
2936
|
|
|
2806
2937
|
```tsx
|
|
2807
2938
|
// Whatever the locale, this one Spinner reads 「保存中」
|
|
@@ -2815,7 +2946,6 @@ import {
|
|
|
2815
2946
|
en,
|
|
2816
2947
|
getMessages,
|
|
2817
2948
|
ja,
|
|
2818
|
-
messageUsage,
|
|
2819
2949
|
registerMessages,
|
|
2820
2950
|
type Messages,
|
|
2821
2951
|
} from '@k8ordo/ui/i18n';
|
|
@@ -2841,7 +2971,8 @@ function DismissButton({ onDismiss }) {
|
|
|
2841
2971
|
### Key list
|
|
2842
2972
|
|
|
2843
2973
|
Every key in the `Messages` type, grouped by the components that draw it —
|
|
2844
|
-
the same mapping `
|
|
2974
|
+
the same mapping `@k8ordo/ui/props.json` carries under `messages`. All values
|
|
2975
|
+
are `string`.
|
|
2845
2976
|
|
|
2846
2977
|
<!-- generated:message-keys -->
|
|
2847
2978
|
|
|
@@ -2858,13 +2989,14 @@ the same mapping `messageUsage` exports. All values are `string`.
|
|
|
2858
2989
|
- Combobox: `comboboxToggle`, `comboboxEmpty`, `comboboxFailed`
|
|
2859
2990
|
- FileField: `fileFieldRemove`
|
|
2860
2991
|
- FileField.Dropzone / FileField (generative UI): `fileFieldTrigger`, `fileFieldDrop`
|
|
2861
|
-
- NumberField: `numberFieldIncrement`, `numberFieldDecrement
|
|
2992
|
+
- NumberField: `numberFieldIncrement`, `numberFieldDecrement`
|
|
2862
2993
|
- RangeSlider: `rangeSliderStart`, `rangeSliderEnd`
|
|
2863
2994
|
- Calendar / DatePicker: `calendarPreviousMonth`, `calendarNextMonth`
|
|
2864
2995
|
- DatePicker: `datePickerOpen`, `datePickerDialog`
|
|
2865
2996
|
- ColorPicker: `colorPickerHue`, `colorPickerSaturation`, `colorPickerLightness`, `colorPickerSwatches`, `colorPickerOpen`
|
|
2866
2997
|
- PasswordInput: `passwordShow`, `passwordHide`
|
|
2867
2998
|
- ListBox: `listBoxPlaceholder`
|
|
2999
|
+
- Anchor / Card: `opensInNewTab`
|
|
2868
3000
|
- Breadcrumb: `breadcrumb`
|
|
2869
3001
|
- Tabs (generative UI): `tabList`
|
|
2870
3002
|
- Pagination: `paginationLabel`, `paginationPrevious`, `paginationNext`
|