@godxjp/ui 31.31.8 → 32.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +102 -121
- package/agent/START-HERE.md +10 -10
- package/agent/components/Accordion.json +2 -2
- package/agent/components/AccountChip.json +1 -1
- package/agent/components/Actions.json +1 -1
- package/agent/components/Activity.json +2 -2
- package/agent/components/Affix.json +1 -1
- package/agent/components/Alert.json +22 -6
- package/agent/components/AlertDialog.json +8 -1
- package/agent/components/Anchor.json +4 -3
- package/agent/components/AppLauncher.json +2 -2
- package/agent/components/AppProvider.json +19 -11
- package/agent/components/AppSettingPicker.json +18 -2
- package/agent/components/AppShell.json +4 -5
- package/agent/components/AreaChart.json +0 -1
- package/agent/components/AspectRatio.json +2 -2
- package/agent/components/Attachments.json +3 -3
- package/agent/components/AuthAccountSummary.json +1 -1
- package/agent/components/AuthDivider.json +1 -1
- package/agent/components/AuthExpiryProvider.json +0 -1
- package/agent/components/AuthFooter.json +2 -2
- package/agent/components/AuthIdentity.json +3 -3
- package/agent/components/AuthStack.json +1 -1
- package/agent/components/Avatar.json +2 -12
- package/agent/components/Badge.json +1 -1
- package/agent/components/BarChart.json +0 -1
- package/agent/components/BranchScopePicker.json +1 -1
- package/agent/components/Breadcrumb.json +1 -1
- package/agent/components/Button.json +3 -3
- package/agent/components/Calendar.json +1 -1
- package/agent/components/Card.json +2 -2
- package/agent/components/CardBar.json +0 -1
- package/agent/components/CardContent.json +0 -1
- package/agent/components/Carousel.json +4 -3
- package/agent/components/Cascader.json +1 -1
- package/agent/components/CenteredShell.json +78 -17
- package/agent/components/ChatBubble.json +3 -3
- package/agent/components/ChatBubbleList.json +3 -3
- package/agent/components/ChatComposer.json +3 -3
- package/agent/components/ChatSuggestion.json +3 -3
- package/agent/components/Checkbox.json +1 -1
- package/agent/components/CheckboxGroup.json +0 -1
- package/agent/components/CodeBlock.json +1 -1
- package/agent/components/Collapsible.json +4 -4
- package/agent/components/ColorPicker.json +1 -1
- package/agent/components/Command.json +5 -5
- package/agent/components/CommandPalette.json +1 -1
- package/agent/components/CompactBarTrend.json +1 -1
- package/agent/components/Conversations.json +3 -3
- package/agent/components/CredentialReveal.json +1 -1
- package/agent/components/DataState.json +2 -2
- package/agent/components/DataTable.json +1 -1
- package/agent/components/DatePicker.json +1 -1
- package/agent/components/Descriptions.json +1 -1
- package/agent/components/Dialog.json +2 -2
- package/agent/components/DraggablePanel.json +5 -4
- package/agent/components/DropdownMenu.json +1 -1
- package/agent/components/EmojiPicker.json +3 -2
- package/agent/components/EmptyState.json +1 -1
- package/agent/components/ErrorSurface.json +3 -3
- package/agent/components/FeatureList.json +1 -1
- package/agent/components/Field.json +0 -1
- package/agent/components/Flex.json +34 -4
- package/agent/components/FloatButton.json +6 -5
- package/agent/components/Form.json +1 -1
- package/agent/components/FormErrors.json +0 -1
- package/agent/components/FormField.json +6 -6
- package/agent/components/FormFieldArray.json +0 -1
- package/agent/components/FormFieldControl.json +0 -1
- package/agent/components/FormRoot.json +1 -1
- package/agent/components/Heading.json +3 -0
- package/agent/components/Icon.json +1 -1
- package/agent/components/Image.json +7 -4
- package/agent/components/InfiniteQueryState.json +1 -1
- package/agent/components/Input.json +1 -1
- package/agent/components/InputOTP.json +2 -2
- package/agent/components/Label.json +3 -3
- package/agent/components/LegalDocumentShell.json +5 -4
- package/agent/components/Legend.json +1 -1
- package/agent/components/LineChart.json +0 -1
- package/agent/components/Link.json +0 -1
- package/agent/components/ListRow.json +1 -1
- package/agent/components/Logo.json +5 -4
- package/agent/components/Marquee.json +4 -3
- package/agent/components/Masonry.json +4 -3
- package/agent/components/MasterDetail.json +1 -1
- package/agent/components/MegaMenu.json +4 -3
- package/agent/components/MobileShell.json +4 -4
- package/agent/components/NavList.json +1 -1
- package/agent/components/NumberInput.json +1 -1
- package/agent/components/OrgChart.json +4 -3
- package/agent/components/OrgSwitcher.json +1 -1
- package/agent/components/OverlayPortalProvider.json +0 -1
- package/agent/components/PageContainer.json +3 -3
- package/agent/components/PageCover.json +3 -2
- package/agent/components/Pagination.json +1 -1
- package/agent/components/PasswordInput.json +1 -1
- package/agent/components/PasswordStrength.json +1 -1
- package/agent/components/PermissionMatrix.json +1 -1
- package/agent/components/PieChart.json +0 -1
- package/agent/components/Popover.json +31 -6
- package/agent/components/PrefetchLink.json +1 -1
- package/agent/components/Progress.json +1 -1
- package/agent/components/Prose.json +1 -1
- package/agent/components/QrCode.json +1 -1
- package/agent/components/Radio.json +0 -1
- package/agent/components/RadioGroup.json +2 -2
- package/agent/components/RangeTimeline.json +2 -1
- package/agent/components/Rating.json +1 -1
- package/agent/components/RecordPicker.json +1 -1
- package/agent/components/ResizablePanel.json +1 -1
- package/agent/components/ResponsiveGrid.json +2 -2
- package/agent/components/Reveal.json +3 -3
- package/agent/components/ScrollArea.json +2 -2
- package/agent/components/SearchInput.json +1 -1
- package/agent/components/Segmented.json +1 -1
- package/agent/components/Select.json +7 -5
- package/agent/components/Separator.json +1 -1
- package/agent/components/ServiceCatalogCta.json +0 -1
- package/agent/components/ServiceLauncherCard.json +1 -1
- package/agent/components/ServiceRolePanel.json +1 -1
- package/agent/components/Sheet.json +5 -5
- package/agent/components/Sidebar.json +1 -1
- package/agent/components/Skeleton.json +26 -12
- package/agent/components/Slider.json +2 -2
- package/agent/components/SortableList.json +3 -2
- package/agent/components/SplitPane.json +1 -1
- package/agent/components/StatCard.json +1 -1
- package/agent/components/Steps.json +1 -1
- package/agent/components/Swatch.json +1 -1
- package/agent/components/Switch.json +1 -1
- package/agent/components/Table.json +1 -1
- package/agent/components/Tabs.json +3 -3
- package/agent/components/Text.json +5 -1
- package/agent/components/TextDiff.json +5 -4
- package/agent/components/Textarea.json +1 -1
- package/agent/components/ThemeScope.json +1 -1
- package/agent/components/ThoughtChain.json +3 -3
- package/agent/components/TimePicker.json +1 -1
- package/agent/components/Timeline.json +1 -1
- package/agent/components/TimelineGrid.json +5 -4
- package/agent/components/Toaster.json +0 -1
- package/agent/components/Toggle.json +3 -3
- package/agent/components/ToggleGroup.json +1 -1
- package/agent/components/Toolbar.json +10 -3
- package/agent/components/Tooltip.json +9 -9
- package/agent/components/Topbar.json +1 -1
- package/agent/components/TopbarItem.json +1 -1
- package/agent/components/Transfer.json +2 -2
- package/agent/components/Tree.json +1 -1
- package/agent/components/TreeSelect.json +1 -1
- package/agent/components/TwoFactorSetup.json +1 -1
- package/agent/components/Upload.json +1 -1
- package/agent/components/UploadCropDialog.json +1 -1
- package/agent/components/Welcome.json +3 -3
- package/agent/components/formatDate.json +2 -2
- package/agent/components/inertiaUpload.json +0 -1
- package/agent/components/useZodForm.json +0 -1
- package/agent/components-index.json +80 -154
- package/agent/components.json +541 -1737
- package/agent/index.json +10 -10
- package/agent/llms.txt +9 -9
- package/agent/patterns/account-recovery-settings.json +1 -1
- package/agent/patterns/auth-recovery-panels.json +2 -2
- package/agent/patterns/error-pages.json +1 -1
- package/agent/patterns/pricing-plans.json +17 -0
- package/agent/patterns-index.json +17 -1
- package/agent/patterns.json +21 -4
- package/agent/rules.json +30 -65
- package/agent/tokens.json +27 -57
- package/agent/vocabulary.json +3 -3
- package/dist/app/app-provider.d.ts +5 -3
- package/dist/app/app-provider.js +47 -12
- package/dist/app/date-format-labels.d.ts +3 -1
- package/dist/app/date-format-labels.js +2 -4
- package/dist/app/date-formats.d.ts +21 -2
- package/dist/app/date-formats.js +51 -2
- package/dist/app/index.d.ts +3 -1
- package/dist/app/index.js +5 -0
- package/dist/app/locales.d.ts +58 -3
- package/dist/app/locales.js +134 -8
- package/dist/app/preset.d.ts +25 -0
- package/dist/app/preset.js +10 -0
- package/dist/app/request-headers.d.ts +3 -3
- package/dist/app/request-headers.js +19 -10
- package/dist/app/settings-scope.d.ts +54 -0
- package/dist/app/settings-scope.js +46 -0
- package/dist/app/tenant-theme.js +8 -3
- package/dist/app/time-format-labels.d.ts +4 -1
- package/dist/app/time-format-labels.js +7 -1
- package/dist/app/types.d.ts +10 -2
- package/dist/app/use-formatting.d.ts +1 -1
- package/dist/components/admin/index.d.ts +1 -1
- package/dist/components/admin/index.js +1 -1
- package/dist/components/data-display/accordion.d.ts +51 -1
- package/dist/components/data-display/accordion.js +247 -1
- package/dist/components/data-display/avatar.d.ts +16 -1
- package/dist/components/data-display/avatar.js +109 -1
- package/dist/components/data-display/credential-reveal.d.ts +9 -2
- package/dist/components/data-display/credential-reveal.js +156 -1
- package/dist/components/data-display/image.js +5 -3
- package/dist/components/data-display/index.d.ts +0 -21
- package/dist/components/data-display/index.js +1 -43
- package/dist/components/data-display/popover.d.ts +15 -3
- package/dist/components/data-display/popover.js +168 -2
- package/dist/components/data-entry/branch-scope-picker.d.ts +1 -1
- package/dist/components/data-entry/index.d.ts +5 -12
- package/dist/components/data-entry/index.js +11 -12
- package/dist/components/data-entry/input-otp.d.ts +48 -2
- package/dist/components/data-entry/input-otp.js +94 -1
- package/dist/components/data-entry/number-input.d.ts +1 -1
- package/dist/components/data-entry/password-input.d.ts +38 -2
- package/dist/components/data-entry/password-input.js +56 -1
- package/dist/components/data-entry/rating.d.ts +38 -2
- package/dist/components/data-entry/rating.js +127 -1
- package/dist/components/data-entry/segmented.d.ts +94 -2
- package/dist/components/data-entry/segmented.js +104 -1
- package/dist/components/{ui/tag-input.d.ts → data-entry/select-tags-inline.d.ts} +7 -4
- package/dist/components/{ui/tag-input.js → data-entry/select-tags-inline.js} +4 -4
- package/dist/components/data-entry/select.js +4 -0
- package/dist/components/data-entry/toggle-group.d.ts +108 -2
- package/dist/components/data-entry/toggle-group.js +189 -1
- package/dist/components/data-entry/toggle.d.ts +86 -2
- package/dist/components/data-entry/toggle.js +153 -2
- package/dist/components/feedback/alert.d.ts +5 -3
- package/dist/components/feedback/alert.js +14 -2
- package/dist/components/feedback/index.d.ts +2 -6
- package/dist/components/feedback/index.js +1 -13
- package/dist/components/feedback/skeleton.d.ts +4 -17
- package/dist/components/feedback/skeleton.js +3 -40
- package/dist/components/general/index.d.ts +2 -4
- package/dist/components/general/index.js +1 -6
- package/dist/components/general/typography.d.ts +4 -58
- package/dist/components/general/typography.js +7 -141
- package/dist/components/layout/aspect-ratio.d.ts +24 -1
- package/dist/components/layout/aspect-ratio.js +18 -1
- package/dist/components/layout/auth-divider.js +1 -1
- package/dist/components/layout/auth-identity.js +6 -2
- package/dist/components/layout/centered-shell.d.ts +13 -8
- package/dist/components/layout/centered-shell.js +43 -1
- package/dist/components/layout/flex.d.ts +1 -1
- package/dist/components/layout/flex.js +73 -1
- package/dist/components/layout/index.d.ts +1 -13
- package/dist/components/layout/index.js +0 -12
- package/dist/components/layout/separator.d.ts +25 -2
- package/dist/components/layout/separator.js +71 -1
- package/dist/components/navigation/{app-setting-toggle.d.ts → app-setting-cycle.d.ts} +3 -4
- package/dist/components/navigation/{app-setting-toggle.js → app-setting-cycle.js} +3 -3
- package/dist/components/navigation/app-setting-picker.d.ts +6 -2
- package/dist/components/navigation/app-setting-picker.js +20 -2
- package/dist/components/navigation/index.d.ts +3 -11
- package/dist/components/navigation/index.js +1 -9
- package/dist/components/navigation/tabs.js +1 -1
- package/dist/components/ui/carousel.d.ts +1 -1
- package/dist/components/ui/carousel.js +1 -1
- package/dist/components/ui/index.d.ts +11 -5
- package/dist/components/ui/index.js +5 -5
- package/dist/contracts/measurement.json +2 -2
- package/dist/email/brand-mark.d.ts +3 -2
- package/dist/email/brand-mark.js +1 -1
- package/dist/email/color.d.ts +7 -0
- package/dist/email/color.js +14 -1
- package/dist/email/index.d.ts +10 -2
- package/dist/email/index.js +23 -2
- package/dist/email/tokens.generated.d.ts +120 -2
- package/dist/email/tokens.generated.js +119 -1
- package/dist/i18n/locale-tags.d.ts +25 -0
- package/dist/i18n/locale-tags.js +59 -0
- package/dist/i18n/translate.d.ts +20 -3
- package/dist/i18n/translate.js +25 -14
- package/dist/i18n/use-translation.d.ts +3 -3
- package/dist/i18n/use-translation.js +4 -2
- package/dist/{components/navigation → lab}/anchor.d.ts +2 -2
- package/dist/{components/navigation → lab}/anchor.js +5 -5
- package/dist/{components/data-display → lab}/carousel.js +2 -2
- package/dist/{components/layout → lab}/draggable-panel.d.ts +8 -8
- package/dist/{components/layout → lab}/draggable-panel.js +2 -2
- package/dist/{components/data-entry → lab}/emoji-picker.d.ts +2 -2
- package/dist/{components/data-entry → lab}/emoji-picker.js +6 -6
- package/dist/{components/general → lab}/float-button.d.ts +8 -8
- package/dist/{components/general → lab}/float-button.js +7 -7
- package/dist/lab/index.d.ts +39 -0
- package/dist/lab/index.js +48 -0
- package/dist/{components/layout → lab}/legal-document-shell.d.ts +2 -2
- package/dist/{components/layout → lab}/legal-document-shell.js +4 -4
- package/dist/{components/data-display → lab}/marquee.d.ts +5 -5
- package/dist/{components/data-display → lab}/marquee.js +5 -5
- package/dist/{components/layout → lab}/masonry.d.ts +2 -2
- package/dist/{components/layout → lab}/masonry.js +3 -3
- package/dist/{components/navigation → lab}/mega-menu.d.ts +4 -4
- package/dist/{components/navigation → lab}/mega-menu.js +2 -2
- package/dist/{components/data-display → lab}/org-chart.d.ts +2 -2
- package/dist/{components/data-display → lab}/org-chart.js +4 -4
- package/dist/{components/layout → lab}/page-cover.d.ts +2 -2
- package/dist/{components/layout → lab}/page-cover.js +2 -2
- package/dist/{components/data-display → lab}/range-timeline.d.ts +1 -1
- package/dist/{components/data-display → lab}/range-timeline.js +6 -6
- package/dist/{components/data-entry → lab}/sortable-list.d.ts +2 -2
- package/dist/{components/data-entry → lab}/sortable-list.js +3 -3
- package/dist/{components/data-display → lab}/text-diff.d.ts +3 -3
- package/dist/{components/data-display → lab}/text-diff.js +4 -4
- package/dist/{components/data-display → lab}/timeline-grid.d.ts +2 -2
- package/dist/{components/data-display → lab}/timeline-grid.js +1 -1
- package/dist/lib/control-styles.js +1 -1
- package/dist/lib/datetime/format.js +20 -6
- package/dist/lib/datetime/sync.d.ts +6 -2
- package/dist/lib/datetime/sync.js +14 -18
- package/dist/lib/platform.d.ts +1 -1
- package/dist/props/components/app.prop.d.ts +28 -13
- package/dist/props/components/data-display.prop.d.ts +19 -29
- package/dist/props/components/feedback.prop.d.ts +15 -44
- package/dist/props/components/general.prop.d.ts +2 -64
- package/dist/props/components/index.d.ts +9 -1
- package/dist/props/components/layout.prop.d.ts +41 -57
- package/dist/props/registry.d.ts +48 -101
- package/dist/props/registry.js +45 -129
- package/dist/props/vocabulary/index.d.ts +1 -1
- package/dist/props/vocabulary/interaction.prop.d.ts +3 -12
- package/dist/styles/alert-layout.css +0 -29
- package/dist/styles/data-display-layout.css +14 -22
- package/dist/styles/fonts/OFL.txt +93 -0
- package/dist/styles/form-layout.css +4 -0
- package/dist/styles/index.css +0 -2
- package/dist/styles/layers.json +44 -179
- package/dist/styles/text-layout.css +0 -15
- package/dist/styles.css +2 -0
- package/dist/themes/godx-tokens.css +41 -0
- package/dist/themes/godx.css +3 -0
- package/dist/themes/godx.d.ts +16 -0
- package/dist/themes/godx.js +12 -0
- package/dist/tokens/components/feedback.css +0 -6
- package/dist/tokens/derived.css +23 -22
- package/dist/tokens/foundation.css +4 -6
- package/docs/COMPOSITION-VS-COMPONENT.md +58 -33
- package/docs/CONSUMER-RULES.md +1 -1
- package/docs/CUSTOMER-THEMING.md +17 -53
- package/docs/migrations/v32.md +105 -0
- package/package.json +59 -19
- package/scripts/_agent-setup.mjs +54 -3
- package/scripts/brand-accent.generated.mjs +15 -2
- package/scripts/cli.mjs +36 -11
- package/scripts/codemod.mjs +542 -0
- package/scripts/consumer-rule.md +21 -43
- package/scripts/postinstall.mjs +10 -47
- package/scripts/prune-css.mjs +1 -1
- package/scripts/ui-audit.mjs +5 -2
- package/dist/components/data-display/chat-bubble.d.ts +0 -30
- package/dist/components/data-display/chat-bubble.js +0 -229
- package/dist/components/data-display/hover-card.d.ts +0 -1
- package/dist/components/data-display/hover-card.js +0 -7
- package/dist/components/data-display/thought-chain.d.ts +0 -42
- package/dist/components/data-display/thought-chain.js +0 -177
- package/dist/components/data-display/thumbnail.d.ts +0 -37
- package/dist/components/data-display/thumbnail.js +0 -20
- package/dist/components/data-display/welcome.d.ts +0 -26
- package/dist/components/data-display/welcome.js +0 -37
- package/dist/components/data-entry/attachments.d.ts +0 -19
- package/dist/components/data-entry/attachments.js +0 -366
- package/dist/components/data-entry/chat-composer.d.ts +0 -51
- package/dist/components/data-entry/chat-composer.js +0 -200
- package/dist/components/data-entry/chat-suggestion.d.ts +0 -28
- package/dist/components/data-entry/chat-suggestion.js +0 -309
- package/dist/components/data-entry/tag-input.d.ts +0 -2
- package/dist/components/data-entry/tag-input.js +0 -5
- package/dist/components/feedback/banner.d.ts +0 -21
- package/dist/components/feedback/banner.js +0 -19
- package/dist/components/feedback/callout.d.ts +0 -23
- package/dist/components/feedback/callout.js +0 -42
- package/dist/components/layout/auth-shell.d.ts +0 -10
- package/dist/components/layout/auth-shell.js +0 -42
- package/dist/components/layout/space-compact.d.ts +0 -65
- package/dist/components/layout/space-compact.js +0 -52
- package/dist/components/navigation/conversations.d.ts +0 -39
- package/dist/components/navigation/conversations.js +0 -371
- package/dist/components/ui/accordion.d.ts +0 -51
- package/dist/components/ui/accordion.js +0 -254
- package/dist/components/ui/aspect-ratio.d.ts +0 -24
- package/dist/components/ui/aspect-ratio.js +0 -21
- package/dist/components/ui/avatar.d.ts +0 -16
- package/dist/components/ui/avatar.js +0 -115
- package/dist/components/ui/credential-reveal.d.ts +0 -9
- package/dist/components/ui/credential-reveal.js +0 -160
- package/dist/components/ui/hover-card.d.ts +0 -47
- package/dist/components/ui/hover-card.js +0 -205
- package/dist/components/ui/input-otp.d.ts +0 -48
- package/dist/components/ui/input-otp.js +0 -101
- package/dist/components/ui/password-input.d.ts +0 -38
- package/dist/components/ui/password-input.js +0 -60
- package/dist/components/ui/rating.d.ts +0 -38
- package/dist/components/ui/rating.js +0 -131
- package/dist/components/ui/segmented.d.ts +0 -94
- package/dist/components/ui/segmented.js +0 -108
- package/dist/components/ui/separator.d.ts +0 -25
- package/dist/components/ui/separator.js +0 -74
- package/dist/components/ui/toggle-group.d.ts +0 -108
- package/dist/components/ui/toggle-group.js +0 -194
- package/dist/components/ui/toggle.d.ts +0 -86
- package/dist/components/ui/toggle.js +0 -156
- package/docs/CANONICAL-CONTRACTS.md +0 -206
- package/docs/COMPONENTS.md +0 -163
- package/docs/DATETIME.md +0 -78
- package/docs/DEVELOPMENT.md +0 -269
- package/docs/FRAME-A11Y-CI.md +0 -287
- package/docs/FRAME-COVERAGE-LEDGER.md +0 -123
- package/docs/FRAME-COVERAGE-REPORT.md +0 -228
- package/docs/FRAME-COVERAGE-STANDARD.md +0 -65
- package/docs/FRAME-COVERAGE.md +0 -29
- package/docs/MEASUREMENT-CONTRACT.md +0 -109
- package/docs/PROPS-REGISTRY.md +0 -61
- package/docs/PROPS-VOCABULARY.md +0 -100
- package/docs/REGISTRY.md +0 -70
- package/docs/TESTING.md +0 -107
- package/docs/THEME-API-COVERAGE.md +0 -538
- package/docs/WHAT-BELONGS-HERE.md +0 -179
- package/docs/asset-modules.d.ts +0 -53
- package/docs/assets/cover-terrain.svg +0 -6
- package/docs/assets/portrait-amber.svg +0 -5
- package/docs/assets/portrait-clay.svg +0 -5
- package/docs/assets/portrait-indigo.svg +0 -5
- package/docs/assets/portrait-iris.svg +0 -5
- package/docs/assets/portrait-moss.svg +0 -5
- package/docs/assets/portrait-plum.svg +0 -5
- package/docs/assets/portrait-slate.svg +0 -5
- package/docs/assets/service-mark-rose.svg +0 -6
- package/docs/assets/service-mark-teal.svg +0 -5
- package/docs/assets/shot-landscape.svg +0 -12
- package/docs/assets/shot-portrait.svg +0 -10
- package/docs/assets/tcgm/card-1.svg +0 -1
- package/docs/assets/tcgm/card-2.svg +0 -1
- package/docs/assets/tcgm/card-3.svg +0 -1
- package/docs/assets/tcgm/card-4.svg +0 -1
- package/docs/assets/tcgm/card-5.svg +0 -1
- package/docs/assets/tcgm/card-6.svg +0 -1
- package/docs/assets/tcgm/hero-prism.svg +0 -1
- package/docs/assets/tcgm/scene-1.svg +0 -1
- package/docs/assets/tcgm/scene-2.svg +0 -1
- package/docs/assets/tcgm/scene-3.svg +0 -1
- package/docs/assets/tcgm/scene-4.svg +0 -1
- package/docs/assets/tcgm/scene-5.svg +0 -1
- package/docs/assets/tcgm/tcgm-lockup-color.svg +0 -1
- package/docs/assets/tcgm/tcgm-symbol-color.svg +0 -1
- package/docs/charts/cjk-category-axis.tsx +0 -81
- package/docs/charts/compact-bar-trend.tsx +0 -327
- package/docs/charts/size-tiers.tsx +0 -192
- package/docs/data-display/accordion.tsx +0 -99
- package/docs/data-display/avatar.tsx +0 -502
- package/docs/data-display/badge.tsx +0 -335
- package/docs/data-display/card/examples/detail-panel.tsx +0 -106
- package/docs/data-display/card/examples/tab-list.tsx +0 -97
- package/docs/data-display/card/index.md +0 -3
- package/docs/data-display/card/index.tsx +0 -390
- package/docs/data-display/carousel.tsx +0 -160
- package/docs/data-display/charts.tsx +0 -278
- package/docs/data-display/chat-bubble.tsx +0 -397
- package/docs/data-display/code-block.tsx +0 -188
- package/docs/data-display/collapsible.tsx +0 -162
- package/docs/data-display/credential-reveal.tsx +0 -148
- package/docs/data-display/data-table/examples/antd-parity.tsx +0 -257
- package/docs/data-display/data-table/examples/approval-queue.tsx +0 -212
- package/docs/data-display/data-table/examples/grid-features.tsx +0 -158
- package/docs/data-display/data-table/examples/list-page.tsx +0 -175
- package/docs/data-display/data-table/examples/selectable-inbox.tsx +0 -113
- package/docs/data-display/data-table/examples/server-paged.tsx +0 -179
- package/docs/data-display/data-table/examples/striped-list.tsx +0 -173
- package/docs/data-display/data-table/index.md +0 -9
- package/docs/data-display/data-table/index.tsx +0 -407
- package/docs/data-display/descriptions.tsx +0 -263
- package/docs/data-display/empty-state.tsx +0 -164
- package/docs/data-display/feature-list.tsx +0 -159
- package/docs/data-display/hover-card.tsx +0 -181
- package/docs/data-display/image.tsx +0 -170
- package/docs/data-display/legend.tsx +0 -158
- package/docs/data-display/list-row.tsx +0 -441
- package/docs/data-display/markdown.tsx +0 -86
- package/docs/data-display/marquee.tsx +0 -254
- package/docs/data-display/org-chart.tsx +0 -165
- package/docs/data-display/permission-matrix.tsx +0 -188
- package/docs/data-display/popover-touch.tsx +0 -27
- package/docs/data-display/popover.tsx +0 -331
- package/docs/data-display/progress.tsx +0 -162
- package/docs/data-display/prose.tsx +0 -169
- package/docs/data-display/qr-code.tsx +0 -68
- package/docs/data-display/scroll-area.tsx +0 -420
- package/docs/data-display/service-launcher-card.tsx +0 -445
- package/docs/data-display/stat-card.tsx +0 -354
- package/docs/data-display/swatch.tsx +0 -107
- package/docs/data-display/table.tsx +0 -362
- package/docs/data-display/text-diff.tsx +0 -89
- package/docs/data-display/thought-chain.tsx +0 -176
- package/docs/data-display/thumbnail.tsx +0 -128
- package/docs/data-display/timeline-grid.tsx +0 -119
- package/docs/data-display/timeline.tsx +0 -671
- package/docs/data-display/touch-actions.tsx +0 -36
- package/docs/data-display/tree.tsx +0 -724
- package/docs/data-display/welcome.tsx +0 -115
- package/docs/data-entry/attachments.tsx +0 -160
- package/docs/data-entry/block-editor.tsx +0 -105
- package/docs/data-entry/branch-scope-picker.tsx +0 -128
- package/docs/data-entry/calendar.tsx +0 -226
- package/docs/data-entry/cascader.tsx +0 -380
- package/docs/data-entry/chat-composer.tsx +0 -619
- package/docs/data-entry/chat-suggestion.tsx +0 -301
- package/docs/data-entry/checkbox.tsx +0 -256
- package/docs/data-entry/color-picker.tsx +0 -189
- package/docs/data-entry/command-palette.tsx +0 -179
- package/docs/data-entry/command.tsx +0 -341
- package/docs/data-entry/country-picker-recipe.tsx +0 -175
- package/docs/data-entry/date-picker.tsx +0 -452
- package/docs/data-entry/emoji-picker.tsx +0 -35
- package/docs/data-entry/form/examples/employee-settings.tsx +0 -267
- package/docs/data-entry/form/examples/invoice-form.tsx +0 -387
- package/docs/data-entry/form-dynamic-fields.tsx +0 -199
- package/docs/data-entry/form-field/examples/a11y-contract.tsx +0 -242
- package/docs/data-entry/form-field/examples/create-form.tsx +0 -107
- package/docs/data-entry/form-field/index.md +0 -8
- package/docs/data-entry/form-field/index.tsx +0 -337
- package/docs/data-entry/form-inertia.tsx +0 -80
- package/docs/data-entry/form-root.tsx +0 -112
- package/docs/data-entry/form.tsx +0 -1498
- package/docs/data-entry/input-otp.tsx +0 -258
- package/docs/data-entry/input.tsx +0 -796
- package/docs/data-entry/label.tsx +0 -102
- package/docs/data-entry/markdown-editor.tsx +0 -69
- package/docs/data-entry/number-input.tsx +0 -279
- package/docs/data-entry/password-input.tsx +0 -102
- package/docs/data-entry/password-strength.tsx +0 -99
- package/docs/data-entry/radio-group.tsx +0 -316
- package/docs/data-entry/rating.tsx +0 -91
- package/docs/data-entry/record-picker.tsx +0 -209
- package/docs/data-entry/search-input.tsx +0 -121
- package/docs/data-entry/segmented-in-filter-row.tsx +0 -60
- package/docs/data-entry/segmented.tsx +0 -300
- package/docs/data-entry/select-async-contracts.tsx +0 -108
- package/docs/data-entry/select-matrix.tsx +0 -209
- package/docs/data-entry/select.tsx +0 -547
- package/docs/data-entry/slider.tsx +0 -212
- package/docs/data-entry/sortable-list.tsx +0 -76
- package/docs/data-entry/switch.tsx +0 -314
- package/docs/data-entry/tag-input.tsx +0 -145
- package/docs/data-entry/textarea.tsx +0 -249
- package/docs/data-entry/time-picker.tsx +0 -187
- package/docs/data-entry/time-range-picker.tsx +0 -55
- package/docs/data-entry/toggle-count.tsx +0 -348
- package/docs/data-entry/toggle-group.tsx +0 -438
- package/docs/data-entry/toggle.tsx +0 -217
- package/docs/data-entry/transfer.tsx +0 -115
- package/docs/data-entry/tree-select.tsx +0 -204
- package/docs/data-entry/upload-crop-dialog.tsx +0 -109
- package/docs/data-entry/upload.tsx +0 -310
- package/docs/feedback/alert-dialog.tsx +0 -270
- package/docs/feedback/alert.tsx +0 -248
- package/docs/feedback/auth-expiry.tsx +0 -104
- package/docs/feedback/banner.tsx +0 -183
- package/docs/feedback/callout.tsx +0 -220
- package/docs/feedback/danger-confirm.tsx +0 -91
- package/docs/feedback/dialog-touch.tsx +0 -24
- package/docs/feedback/dialog.tsx +0 -373
- package/docs/feedback/sheet.tsx +0 -510
- package/docs/feedback/skeleton.tsx +0 -168
- package/docs/feedback/toast.tsx +0 -135
- package/docs/feedback/tooltip.tsx +0 -171
- package/docs/feedback/two-factor-setup.tsx +0 -68
- package/docs/foundation/_email-specimen.ts +0 -274
- package/docs/foundation/_theme-editor-scope.ts +0 -222
- package/docs/foundation/colors.tsx +0 -207
- package/docs/foundation/density.tsx +0 -242
- package/docs/foundation/email-tokens.tsx +0 -323
- package/docs/foundation/radius-shadow.tsx +0 -154
- package/docs/foundation/spacing.tsx +0 -216
- package/docs/foundation/theme-editor.tsx +0 -654
- package/docs/foundation/typography.tsx +0 -147
- package/docs/general/actions.tsx +0 -175
- package/docs/general/activity.tsx +0 -289
- package/docs/general/button/examples/destructive-confirm.tsx +0 -90
- package/docs/general/button/examples/form-actions.tsx +0 -87
- package/docs/general/button/examples/toolbar.tsx +0 -160
- package/docs/general/button/index.md +0 -16
- package/docs/general/button/index.tsx +0 -236
- package/docs/general/float-button.tsx +0 -133
- package/docs/general/icon.tsx +0 -217
- package/docs/general/logo.tsx +0 -194
- package/docs/general/reveal.tsx +0 -309
- package/docs/general/typography.tsx +0 -542
- package/docs/i18n/messages/en.json +0 -1715
- package/docs/i18n/messages/ja.json +0 -1708
- package/docs/i18n/messages/vi.json +0 -1708
- package/docs/layout/account-chip.tsx +0 -72
- package/docs/layout/admin-collection.tsx +0 -122
- package/docs/layout/affix.tsx +0 -209
- package/docs/layout/app-launcher.tsx +0 -211
- package/docs/layout/app-shell-arrangements.tsx +0 -225
- package/docs/layout/app-shell-narrow-bar.tsx +0 -205
- package/docs/layout/app-shell-states.tsx +0 -171
- package/docs/layout/app-shell.tsx +0 -395
- package/docs/layout/aspect-ratio.tsx +0 -135
- package/docs/layout/auth-account-summary.tsx +0 -103
- package/docs/layout/auth-divider.tsx +0 -28
- package/docs/layout/auth-footer.tsx +0 -37
- package/docs/layout/auth-identity.tsx +0 -70
- package/docs/layout/auth-recovery/examples/mfa-challenge.md +0 -41
- package/docs/layout/auth-recovery/examples/mfa-challenge.tsx +0 -254
- package/docs/layout/auth-recovery/examples/mobile-390.md +0 -25
- package/docs/layout/auth-recovery/examples/mobile-390.tsx +0 -82
- package/docs/layout/auth-recovery/examples/password-recovery.md +0 -24
- package/docs/layout/auth-recovery/examples/password-recovery.tsx +0 -197
- package/docs/layout/auth-recovery/examples/wrapping-ja-en-vi.md +0 -27
- package/docs/layout/auth-recovery/examples/wrapping-ja-en-vi.tsx +0 -156
- package/docs/layout/auth-recovery/index.md +0 -140
- package/docs/layout/auth-recovery/index.tsx +0 -96
- package/docs/layout/auth-shell-context.tsx +0 -103
- package/docs/layout/auth-shell-device.tsx +0 -112
- package/docs/layout/auth-shell-registration.tsx +0 -338
- package/docs/layout/auth-shell-variants.tsx +0 -143
- package/docs/layout/auth-shell.tsx +0 -59
- package/docs/layout/auth-stack.tsx +0 -40
- package/docs/layout/centered-shell.tsx +0 -102
- package/docs/layout/draggable-panel.tsx +0 -127
- package/docs/layout/error-surface/examples/application-403.tsx +0 -84
- package/docs/layout/error-surface/examples/application-404.tsx +0 -77
- package/docs/layout/error-surface/examples/system-500.tsx +0 -47
- package/docs/layout/error-surface/examples/system-503.tsx +0 -48
- package/docs/layout/error-surface/index.md +0 -153
- package/docs/layout/error-surface/index.tsx +0 -239
- package/docs/layout/flex.tsx +0 -444
- package/docs/layout/legal-document-shell/_data.ts +0 -110
- package/docs/layout/legal-document-shell/examples/desktop-1440.md +0 -12
- package/docs/layout/legal-document-shell/examples/desktop-1440.tsx +0 -83
- package/docs/layout/legal-document-shell/examples/mobile-390.md +0 -22
- package/docs/layout/legal-document-shell/examples/mobile-390.tsx +0 -70
- package/docs/layout/legal-document-shell/examples/tablet-1024.md +0 -3
- package/docs/layout/legal-document-shell/examples/tablet-1024.tsx +0 -84
- package/docs/layout/legal-document-shell/examples/wrapping-ja-en-vi.md +0 -18
- package/docs/layout/legal-document-shell/examples/wrapping-ja-en-vi.tsx +0 -61
- package/docs/layout/legal-document-shell/index.md +0 -51
- package/docs/layout/legal-document-shell/index.tsx +0 -101
- package/docs/layout/masonry.tsx +0 -291
- package/docs/layout/master-detail.tsx +0 -390
- package/docs/layout/mobile-shell.tsx +0 -106
- package/docs/layout/nav-list.tsx +0 -584
- package/docs/layout/org-switcher.tsx +0 -131
- package/docs/layout/page-container.tsx +0 -1020
- package/docs/layout/page-cover.tsx +0 -56
- package/docs/layout/resizable-panel.tsx +0 -419
- package/docs/layout/responsive-grid.tsx +0 -403
- package/docs/layout/separator.tsx +0 -327
- package/docs/layout/service-role-panel.tsx +0 -144
- package/docs/layout/sidebar.tsx +0 -689
- package/docs/layout/space-compact.tsx +0 -202
- package/docs/layout/split-pane.tsx +0 -532
- package/docs/layout/topbar-item.tsx +0 -233
- package/docs/layout/topbar.tsx +0 -360
- package/docs/navigation/anchor.tsx +0 -295
- package/docs/navigation/app-setting-picker.tsx +0 -178
- package/docs/navigation/app-setting-toggle.tsx +0 -111
- package/docs/navigation/breadcrumb.tsx +0 -207
- package/docs/navigation/card-tabs.tsx +0 -344
- package/docs/navigation/conversations.tsx +0 -176
- package/docs/navigation/dropdown-menu.tsx +0 -345
- package/docs/navigation/filter-bar.tsx +0 -247
- package/docs/navigation/mega-menu-panel.tsx +0 -86
- package/docs/navigation/mega-menu.tsx +0 -254
- package/docs/navigation/pagination.tsx +0 -293
- package/docs/navigation/steps.tsx +0 -315
- package/docs/navigation/tabs-rtl.tsx +0 -28
- package/docs/navigation/tabs.tsx +0 -755
- package/docs/navigation/toolbar.tsx +0 -347
- package/docs/providers/app-provider.tsx +0 -191
- package/docs/providers/format-date.tsx +0 -230
- package/docs/providers/theme-scope.tsx +0 -186
- package/docs/query/button-refetch.tsx +0 -161
- package/docs/query/data-state.tsx +0 -262
- package/docs/query/infinite-query-state.tsx +0 -97
- package/docs/query/mutation-feedback.tsx +0 -128
- package/docs/query/touch-actions.tsx +0 -68
- package/docs/react-router/prefetch-link.tsx +0 -262
- package/docs/roadmap/ai-chat-components.md +0 -206
- package/docs/roadmap/antd-parity.md +0 -155
- package/docs/roadmap/badge-tag-chip-count.md +0 -172
- package/docs/roadmap/list-masonry.md +0 -159
- package/docs/roadmap/parity-audit-data-display-feedback.md +0 -567
- package/docs/roadmap/parity-audit-data-entry.md +0 -368
- package/docs/roadmap/parity-audit-layout-navigation-general.md +0 -459
- package/docs/roadmap/parity-backlog.md +0 -77
- package/docs/roadmap/tree-components.md +0 -151
- package/docs/roadmap/website-components.md +0 -813
- package/docs/showcase/acme-portal.tsx +0 -461
- package/docs/showcase/acme-website.tsx +0 -499
- package/docs/showcase/caimono-price-comparison.tsx +0 -919
- package/docs/showcase/case1-warehouse-dashboard.tsx +0 -358
- package/docs/showcase/case2-employee-me.tsx +0 -438
- package/docs/showcase/case3-approval-workflow.tsx +0 -531
- package/docs/showcase/case4-login.tsx +0 -312
- package/docs/showcase/case5-shift-calendar.tsx +0 -702
- package/docs/showcase/case6-agency-handy.tsx +0 -1120
- package/docs/showcase/futurelastic-web.tsx +0 -441
- package/docs/showcase/marketing-page.tsx +0 -895
- package/docs/showcase/org-switcher.tsx +0 -320
- package/docs/showcase/permission-matrix.tsx +0 -354
- package/docs/showcase/public-landing.tsx +0 -210
- package/docs/showcase/settings-account-sections.tsx +0 -559
- package/docs/showcase/settings-security-mfa.tsx +0 -145
- package/docs/showcase/table-approval-queue.tsx +0 -199
- package/docs/showcase/table-bulk-actions.tsx +0 -468
- package/docs/showcase/table-compact-kintone.tsx +0 -438
- package/docs/showcase/table-conditional-format.tsx +0 -367
- package/docs/showcase/table-crud-list.tsx +0 -544
- package/docs/showcase/table-density.tsx +0 -349
- package/docs/showcase/table-expandable-rows.tsx +0 -496
- package/docs/showcase/table-filter-chips.tsx +0 -468
- package/docs/showcase/table-footer-totals.tsx +0 -328
- package/docs/showcase/table-grouped-subtotals.tsx +0 -398
- package/docs/showcase/table-master-detail.tsx +0 -482
- package/docs/showcase/table-pagination.tsx +0 -409
- package/docs/showcase/table-states.tsx +0 -371
- package/docs/showcase/table-sticky-columns.tsx +0 -377
- package/docs/showcase/table-tree-rows.tsx +0 -451
- package/docs/showcase/table-view-tabs.tsx +0 -488
- package/docs/showcase/tcgm-website.tsx +0 -1047
- package/docs/showcase/tenant-brand-color.tsx +0 -338
- package/docs/showcase/theme-customization.tsx +0 -1292
- package/docs/showcase/theme-lab.tsx +0 -2125
- package/docs/themes/flat.css +0 -466
- package/docs/themes/glassmorphism.css +0 -960
- package/docs/themes/index.ts +0 -219
- package/docs/themes/neubrutalism.css +0 -481
- /package/dist/components/navigation/{filter-bar.d.ts → toolbar.d.ts} +0 -0
- /package/dist/components/navigation/{filter-bar.js → toolbar.js} +0 -0
- /package/dist/{components/data-display → lab}/carousel.d.ts +0 -0
- /package/dist/{components/data-entry → lab}/emoji-data.d.ts +0 -0
- /package/dist/{components/data-entry → lab}/emoji-data.js +0 -0
- /package/dist/{components/data-display → lab}/marquee-reveal.d.ts +0 -0
- /package/dist/{components/data-display → lab}/marquee-reveal.js +0 -0
package/dist/app/app-provider.js
CHANGED
|
@@ -3,7 +3,15 @@ import { jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import * as React from "react";
|
|
4
4
|
import { I18nProvider } from "react-aria-components";
|
|
5
5
|
import { resolveDefaultDateFormat } from "./date-format-labels.js";
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
getDateFnsLocale,
|
|
8
|
+
getDayPickerLocale,
|
|
9
|
+
getRegisteredLocales,
|
|
10
|
+
resolvePageLocale,
|
|
11
|
+
resolveRegisteredLocale
|
|
12
|
+
} from "./locales.js";
|
|
13
|
+
import { AppPresetContext } from "./preset.js";
|
|
14
|
+
import { warnUnknownLocale } from "../i18n/locale-tags.js";
|
|
7
15
|
import { syncAppRequestHeaders } from "./request-headers.js";
|
|
8
16
|
import { syncI18nLocale } from "../i18n/translate.js";
|
|
9
17
|
const RTL_LANGUAGE_SUBTAGS = /* @__PURE__ */ new Set(["ar", "he", "fa", "ur", "ps", "sd", "yi", "dv", "ckb"]);
|
|
@@ -29,12 +37,18 @@ import {
|
|
|
29
37
|
import { resolveDefaultTimeFormat } from "./time-format-labels.js";
|
|
30
38
|
import { resolveDefaultTimezone, resolveHydrationSafeTimezone } from "./timezones.js";
|
|
31
39
|
import {
|
|
32
|
-
APP_LOCALES,
|
|
33
40
|
APP_REQUEST_HEADER_DATE_FORMAT,
|
|
34
41
|
APP_REQUEST_HEADER_LOCALE,
|
|
35
42
|
APP_REQUEST_HEADER_TIME_FORMAT,
|
|
36
43
|
APP_REQUEST_HEADER_TIMEZONE
|
|
37
44
|
} from "./types.js";
|
|
45
|
+
function resolveProviderLocale(defaultLocale, presetLocale) {
|
|
46
|
+
const fromProp = resolveRegisteredLocale(defaultLocale);
|
|
47
|
+
if (fromProp) return fromProp;
|
|
48
|
+
const resolved = resolvePageLocale() ?? resolveRegisteredLocale(presetLocale) ?? "en";
|
|
49
|
+
if (defaultLocale) warnUnknownLocale(defaultLocale, resolved);
|
|
50
|
+
return resolved;
|
|
51
|
+
}
|
|
38
52
|
const AppContext = React.createContext(null);
|
|
39
53
|
function resolveInitialTimeFormat(stored, defaultTimeFormat, locale) {
|
|
40
54
|
if (stored) return stored;
|
|
@@ -56,9 +70,10 @@ function buildRequestHeaders(locale, timezone, timeFormat, dateFormat) {
|
|
|
56
70
|
}
|
|
57
71
|
function AppProvider({
|
|
58
72
|
children,
|
|
59
|
-
|
|
73
|
+
preset,
|
|
74
|
+
defaultLocale: defaultLocaleProp,
|
|
60
75
|
fallbackLocale = "en",
|
|
61
|
-
defaultTimezone
|
|
76
|
+
defaultTimezone: defaultTimezoneProp,
|
|
62
77
|
systemTimezone,
|
|
63
78
|
defaultTimeFormat = "locale",
|
|
64
79
|
defaultDateFormat = "locale",
|
|
@@ -81,6 +96,12 @@ function AppProvider({
|
|
|
81
96
|
onFontSizeChange,
|
|
82
97
|
onScalingChange
|
|
83
98
|
}) {
|
|
99
|
+
const presetLocale = preset?.defaultLocale;
|
|
100
|
+
const defaultLocale = React.useMemo(
|
|
101
|
+
() => resolveProviderLocale(defaultLocaleProp, presetLocale),
|
|
102
|
+
[defaultLocaleProp, presetLocale]
|
|
103
|
+
);
|
|
104
|
+
const defaultTimezone = defaultTimezoneProp ?? preset?.timeZone ?? "browser";
|
|
84
105
|
const initialLocale = defaultLocale;
|
|
85
106
|
const [locale, setLocaleState] = React.useState(initialLocale);
|
|
86
107
|
const [timezone, setTimezoneState] = React.useState(
|
|
@@ -133,18 +154,22 @@ function AppProvider({
|
|
|
133
154
|
const raw = readStoredPreferences(storageKey);
|
|
134
155
|
const stored = pickPersistedAxes(raw, persistedAxes);
|
|
135
156
|
if (!raw.dateFormatChosen && stored.dateFormat !== void 0) {
|
|
136
|
-
const derivable =
|
|
157
|
+
const derivable = getRegisteredLocales().some(
|
|
158
|
+
(l) => resolveDefaultDateFormat(l) === stored.dateFormat
|
|
159
|
+
);
|
|
137
160
|
if (derivable) delete stored.dateFormat;
|
|
138
161
|
}
|
|
139
162
|
if (!raw.timeFormatChosen && stored.timeFormat !== void 0) {
|
|
140
|
-
const derivable =
|
|
163
|
+
const derivable = getRegisteredLocales().some(
|
|
164
|
+
(l) => resolveDefaultTimeFormat(l) === stored.timeFormat
|
|
165
|
+
);
|
|
141
166
|
if (derivable) delete stored.timeFormat;
|
|
142
167
|
}
|
|
143
168
|
formatChosenRef.current = {
|
|
144
169
|
dateFormat: stored.dateFormat !== void 0,
|
|
145
170
|
timeFormat: stored.timeFormat !== void 0
|
|
146
171
|
};
|
|
147
|
-
const nextLocale = stored.locale ?? defaultLocale;
|
|
172
|
+
const nextLocale = resolveRegisteredLocale(stored.locale) ?? defaultLocale;
|
|
148
173
|
const nextTimezone = stored.timezone ?? resolveDefaultTimezone(defaultTimezone, systemTimezone);
|
|
149
174
|
const nextTimeFormat = resolveInitialTimeFormat(
|
|
150
175
|
stored.timeFormat,
|
|
@@ -221,7 +246,12 @@ function AppProvider({
|
|
|
221
246
|
return () => query.removeEventListener("change", reapply);
|
|
222
247
|
}, [theme]);
|
|
223
248
|
const setLocale = React.useCallback(
|
|
224
|
-
(
|
|
249
|
+
(requested) => {
|
|
250
|
+
const next = resolveRegisteredLocale(requested);
|
|
251
|
+
if (!next) {
|
|
252
|
+
warnUnknownLocale(requested, prefsRef.current.locale);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
225
255
|
prefsRef.current = { ...prefsRef.current, locale: next };
|
|
226
256
|
setLocaleState(next);
|
|
227
257
|
if (!formatChosenRef.current.dateFormat && defaultDateFormat === "locale") {
|
|
@@ -326,18 +356,23 @@ function AppProvider({
|
|
|
326
356
|
dateFormat,
|
|
327
357
|
dateFnsLocale
|
|
328
358
|
});
|
|
359
|
+
syncAppRequestHeaders(requestHeaders);
|
|
329
360
|
if (!hasMountedRef.current) {
|
|
330
361
|
disableLiveRelativeFormatting();
|
|
331
362
|
}
|
|
332
|
-
React.useEffect(() => {
|
|
333
|
-
syncAppRequestHeaders(requestHeaders);
|
|
334
|
-
}, [requestHeaders]);
|
|
335
363
|
React.useEffect(() => {
|
|
336
364
|
if (typeof document !== "undefined") {
|
|
337
365
|
document.documentElement.dir = localeDirection(locale);
|
|
338
366
|
document.documentElement.lang = locale;
|
|
339
367
|
}
|
|
340
368
|
}, [locale]);
|
|
369
|
+
const presetName = preset?.name;
|
|
370
|
+
React.useEffect(() => {
|
|
371
|
+
if (typeof document === "undefined" || !presetName) return;
|
|
372
|
+
const root = document.documentElement;
|
|
373
|
+
root.setAttribute("data-preset", presetName);
|
|
374
|
+
return () => root.removeAttribute("data-preset");
|
|
375
|
+
}, [presetName]);
|
|
341
376
|
React.useEffect(() => {
|
|
342
377
|
hasMountedRef.current = true;
|
|
343
378
|
enableLiveRelativeFormatting();
|
|
@@ -395,7 +430,7 @@ function AppProvider({
|
|
|
395
430
|
setScaling
|
|
396
431
|
]
|
|
397
432
|
);
|
|
398
|
-
return /* @__PURE__ */ jsx(I18nProvider, { locale, children: /* @__PURE__ */ jsx(AppContext.Provider, { value, children }) });
|
|
433
|
+
return /* @__PURE__ */ jsx(I18nProvider, { locale, children: /* @__PURE__ */ jsx(AppPresetContext.Provider, { value: preset, children: /* @__PURE__ */ jsx(AppContext.Provider, { value, children }) }) });
|
|
399
434
|
}
|
|
400
435
|
function useAppContext() {
|
|
401
436
|
const ctx = React.useContext(AppContext);
|
|
@@ -5,7 +5,9 @@ export declare const APP_DATE_FORMAT_OPTIONS: {
|
|
|
5
5
|
}[];
|
|
6
6
|
export declare function getDateFormatLabel(dateFormat: AppDateFormat, locale: AppLocale, fallbackLocale?: AppLocale): string;
|
|
7
7
|
/**
|
|
8
|
-
* Suggested default per locale
|
|
8
|
+
* Suggested default per locale: the order the locale writes a numeric date in, from `Intl`
|
|
9
|
+
* (v32, gh#1219) — vi → dmy, ja → ymd, en → mdy, de / pt-BR / en-GB → dmy, ko → ymd. The three
|
|
10
|
+
* built-ins answer what the old hard-coded table answered.
|
|
9
11
|
*
|
|
10
12
|
* `ja` used to be `iso` (`yyyy-MM-dd`). Nothing recorded a reason for it, and it is not the form a
|
|
11
13
|
* Japanese business document is written in: those use `YYYY/MM/DD` (or `YYYY年MM月DD日`). The cost
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { APP_DATE_FORMATS } from "./date-formats.js";
|
|
1
|
+
import { APP_DATE_FORMATS, getLocaleDateOrder } from "./date-formats.js";
|
|
2
2
|
import { translate } from "../i18n/translate.js";
|
|
3
3
|
const APP_DATE_FORMAT_OPTIONS = APP_DATE_FORMATS.map((value) => ({ value }));
|
|
4
4
|
function getDateFormatLabel(dateFormat, locale, fallbackLocale = "en") {
|
|
5
5
|
return translate(locale, fallbackLocale, `dateFormat.${dateFormat}`);
|
|
6
6
|
}
|
|
7
7
|
function resolveDefaultDateFormat(locale) {
|
|
8
|
-
|
|
9
|
-
if (locale === "ja") return "ymd";
|
|
10
|
-
return "dmy";
|
|
8
|
+
return getLocaleDateOrder(locale);
|
|
11
9
|
}
|
|
12
10
|
export {
|
|
13
11
|
APP_DATE_FORMAT_OPTIONS,
|
|
@@ -15,8 +15,27 @@ export type AppDateFormat = "iso" | "ymd" | "dmy" | "mdy";
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const APP_DATE_FORMATS: readonly ["iso", "ymd", "dmy", "mdy"];
|
|
17
17
|
export declare const APP_REQUEST_HEADER_DATE_FORMAT: "x-date-format";
|
|
18
|
+
/**
|
|
19
|
+
* A date-fns pattern equivalent to `Intl.DateTimeFormat(locale, options)` — Gregorian calendar,
|
|
20
|
+
* Latin digits (what date-fns prints). `null` when the engine cannot format `locale`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function intlDatePattern(locale: string, options: Intl.DateTimeFormatOptions): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* The locale's own numeric date pattern, from `Intl` (v32, gh#1219): `de` → `dd.MM.yyyy`, `en-GB`
|
|
25
|
+
* → `dd/MM/yyyy`, `ja` → `yyyy/MM/dd`, `vi` → `dd/MM/yyyy`, `en` → `MM/dd/yyyy`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function getLocaleDatePattern(locale: string): string;
|
|
28
|
+
/** The ORDER the locale writes a numeric date in, from `Intl` — `ymd`, `dmy` or `mdy`. */
|
|
29
|
+
export declare function getLocaleDateOrder(locale: string): Exclude<AppDateFormat, "iso">;
|
|
30
|
+
/**
|
|
31
|
+
* date-fns pattern for date-only display IN A LOCALE (v32, gh#1219): the order the locale writes
|
|
32
|
+
* natively is printed with the locale's own separators from `Intl` — `dmy` under `de` is
|
|
33
|
+
* `dd.MM.yyyy`. Any other order prints the fixed {@link getDatePattern}. For `vi`, `en` and `ja`
|
|
34
|
+
* the native pattern equals the fixed one, so they print exactly what they always did.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getLocaleAwareDatePattern(dateFormat: AppDateFormat, locale: string): string;
|
|
18
37
|
/** date-fns pattern for date-only display. */
|
|
19
38
|
export declare function getDatePattern(dateFormat: AppDateFormat): string;
|
|
20
|
-
/** date-fns pattern for date + time (table cells). */
|
|
21
|
-
export declare function getDateTimePattern(timeFormat: AppTimeFormat, dateFormat: AppDateFormat): string;
|
|
39
|
+
/** date-fns pattern for date + time (table cells); with a `locale`, its native separators. */
|
|
40
|
+
export declare function getDateTimePattern(timeFormat: AppTimeFormat, dateFormat: AppDateFormat, locale?: string): string;
|
|
22
41
|
export declare function isAppDateFormat(value: string | null | undefined): value is AppDateFormat;
|
package/dist/app/date-formats.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getTimePattern } from "./time-formats.js";
|
|
2
|
+
import { dateTimeFormat } from "../lib/intl-cache.js";
|
|
2
3
|
const APP_DATE_FORMATS = [
|
|
3
4
|
"iso",
|
|
4
5
|
"ymd",
|
|
@@ -6,6 +7,49 @@ const APP_DATE_FORMATS = [
|
|
|
6
7
|
"mdy"
|
|
7
8
|
];
|
|
8
9
|
const APP_REQUEST_HEADER_DATE_FORMAT = "x-date-format";
|
|
10
|
+
function partToken(part, options) {
|
|
11
|
+
switch (part.type) {
|
|
12
|
+
case "year":
|
|
13
|
+
return "yyyy";
|
|
14
|
+
case "month":
|
|
15
|
+
return options.month === "long" ? "MMMM" : options.month === "short" ? "MMM" : options.month === "2-digit" ? "MM" : "M";
|
|
16
|
+
case "day":
|
|
17
|
+
return options.day === "2-digit" ? "dd" : "d";
|
|
18
|
+
case "weekday":
|
|
19
|
+
return options.weekday === "long" ? "EEEE" : "EEE";
|
|
20
|
+
default:
|
|
21
|
+
return /[A-Za-z']/.test(part.value) ? `'${part.value.replaceAll("'", "''")}'` : part.value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function intlParts(locale, options) {
|
|
25
|
+
const resolved = { ...options, calendar: "gregory", numberingSystem: "latn", timeZone: "UTC" };
|
|
26
|
+
try {
|
|
27
|
+
return dateTimeFormat(locale, resolved).formatToParts(new Date(Date.UTC(2026, 9, 8)));
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
function intlDatePattern(locale, options) {
|
|
33
|
+
const parts = intlParts(locale, options);
|
|
34
|
+
return parts ? parts.map((part) => partToken(part, options)).join("") : null;
|
|
35
|
+
}
|
|
36
|
+
const NUMERIC_DATE = {
|
|
37
|
+
year: "numeric",
|
|
38
|
+
month: "2-digit",
|
|
39
|
+
day: "2-digit"
|
|
40
|
+
};
|
|
41
|
+
function getLocaleDatePattern(locale) {
|
|
42
|
+
return intlDatePattern(locale, NUMERIC_DATE) ?? getDatePattern("iso");
|
|
43
|
+
}
|
|
44
|
+
function getLocaleDateOrder(locale) {
|
|
45
|
+
const first = intlParts(locale, NUMERIC_DATE)?.find((part) => part.type !== "literal")?.type;
|
|
46
|
+
if (first === "year") return "ymd";
|
|
47
|
+
if (first === "month") return "mdy";
|
|
48
|
+
return "dmy";
|
|
49
|
+
}
|
|
50
|
+
function getLocaleAwareDatePattern(dateFormat, locale) {
|
|
51
|
+
return dateFormat !== "iso" && dateFormat === getLocaleDateOrder(locale) ? getLocaleDatePattern(locale) : getDatePattern(dateFormat);
|
|
52
|
+
}
|
|
9
53
|
function getDatePattern(dateFormat) {
|
|
10
54
|
switch (dateFormat) {
|
|
11
55
|
case "ymd":
|
|
@@ -19,8 +63,9 @@ function getDatePattern(dateFormat) {
|
|
|
19
63
|
return "yyyy-MM-dd";
|
|
20
64
|
}
|
|
21
65
|
}
|
|
22
|
-
function getDateTimePattern(timeFormat, dateFormat) {
|
|
23
|
-
|
|
66
|
+
function getDateTimePattern(timeFormat, dateFormat, locale) {
|
|
67
|
+
const date = locale ? getLocaleAwareDatePattern(dateFormat, locale) : getDatePattern(dateFormat);
|
|
68
|
+
return `${date} ${getTimePattern(timeFormat)}`;
|
|
24
69
|
}
|
|
25
70
|
function isAppDateFormat(value) {
|
|
26
71
|
return APP_DATE_FORMATS.includes(value);
|
|
@@ -30,5 +75,9 @@ export {
|
|
|
30
75
|
APP_REQUEST_HEADER_DATE_FORMAT,
|
|
31
76
|
getDatePattern,
|
|
32
77
|
getDateTimePattern,
|
|
78
|
+
getLocaleAwareDatePattern,
|
|
79
|
+
getLocaleDateOrder,
|
|
80
|
+
getLocaleDatePattern,
|
|
81
|
+
intlDatePattern,
|
|
33
82
|
isAppDateFormat
|
|
34
83
|
};
|
package/dist/app/index.d.ts
CHANGED
|
@@ -9,7 +9,9 @@ export * from "./storage.js";
|
|
|
9
9
|
export * from "./theme-axes.js";
|
|
10
10
|
export * from "./tenant-theme.js";
|
|
11
11
|
export * from "./request-headers.js";
|
|
12
|
-
export {
|
|
12
|
+
export { runWithAppSettings, type AppSettings } from "./settings-scope.js";
|
|
13
|
+
export { AppPresetContext, useAppPreset, type AppPreset } from "./preset.js";
|
|
14
|
+
export { type AppProviderProps, AppProvider, useAppContext, useOptionalAppContext, useAppLocale, useAppTimezone, useAppTimeFormat, useAppDateFormat, } from "./app-provider.js";
|
|
13
15
|
export { useFormatting, useDateTime } from "./use-formatting.js";
|
|
14
16
|
export { syncDatetimeContext, getDatetimeContext, formatDate, isFormatDateValue, detectFormatDateKind, formatAppDate, formatAppDateTime, formatAppTime, formatAppDateLong, formatAppRelative, formatCalendarDate, formatTimeOfDay, parseDateInput, normalizeHhmm, isValidHhmm, type FormatDateOptions, type FormatDateKind, type FormatDatetimeOptions, } from "../lib/datetime/index.js";
|
|
15
17
|
export { useTranslation, usePickerLocales } from "../i18n/use-translation.js";
|
package/dist/app/index.js
CHANGED
|
@@ -9,6 +9,8 @@ export * from "./storage.js";
|
|
|
9
9
|
export * from "./theme-axes.js";
|
|
10
10
|
export * from "./tenant-theme.js";
|
|
11
11
|
export * from "./request-headers.js";
|
|
12
|
+
import { runWithAppSettings } from "./settings-scope.js";
|
|
13
|
+
import { AppPresetContext, useAppPreset } from "./preset.js";
|
|
12
14
|
import {
|
|
13
15
|
AppProvider,
|
|
14
16
|
useAppContext,
|
|
@@ -40,6 +42,7 @@ import { useTranslation, usePickerLocales } from "../i18n/use-translation.js";
|
|
|
40
42
|
import { OverlayPortalProvider } from "../lib/overlay-portal.js";
|
|
41
43
|
import { ThemeScope } from "../lib/overlay-portal.js";
|
|
42
44
|
export {
|
|
45
|
+
AppPresetContext,
|
|
43
46
|
AppProvider,
|
|
44
47
|
OverlayPortalProvider,
|
|
45
48
|
ThemeScope,
|
|
@@ -57,10 +60,12 @@ export {
|
|
|
57
60
|
isValidHhmm,
|
|
58
61
|
normalizeHhmm,
|
|
59
62
|
parseDateInput,
|
|
63
|
+
runWithAppSettings,
|
|
60
64
|
syncDatetimeContext,
|
|
61
65
|
useAppContext,
|
|
62
66
|
useAppDateFormat,
|
|
63
67
|
useAppLocale,
|
|
68
|
+
useAppPreset,
|
|
64
69
|
useAppTimeFormat,
|
|
65
70
|
useAppTimezone,
|
|
66
71
|
useDateTime,
|
package/dist/app/locales.d.ts
CHANGED
|
@@ -1,12 +1,67 @@
|
|
|
1
1
|
import type { Locale } from "date-fns";
|
|
2
2
|
import { vi as viDayPicker } from "react-day-picker/locale";
|
|
3
3
|
import type { AppLocale } from "./types.js";
|
|
4
|
+
export { getRegisteredLocales, resolveRegisteredLocale, resolveDefaultLocale, resolvePageLocale, } from "../i18n/locale-tags.js";
|
|
5
|
+
/** A react-day-picker locale: a date-fns `Locale` plus optional `labels`. */
|
|
6
|
+
export type DayPickerLocale = typeof viDayPicker;
|
|
4
7
|
export type AppLocaleConfig = {
|
|
5
8
|
code: AppLocale;
|
|
6
9
|
dateFns: Locale;
|
|
7
|
-
dayPicker:
|
|
10
|
+
dayPicker: DayPickerLocale;
|
|
8
11
|
};
|
|
9
|
-
|
|
12
|
+
/**
|
|
13
|
+
* What `registerLocale` takes. Only `code` is required: without `dateFns` the date adapter is built
|
|
14
|
+
* from `Intl` (month/weekday names, long date patterns, week start), and without `dayPicker` the
|
|
15
|
+
* calendar uses that same adapter.
|
|
16
|
+
*/
|
|
17
|
+
export type RegisterLocaleInput = {
|
|
18
|
+
/** Any BCP-47 tag — `de`, `pt-BR`, `en-GB`, `ar`. Canonicalised (`pt-br` → `pt-BR`). */
|
|
19
|
+
code: string;
|
|
20
|
+
/** This locale's strings. For a locale the library does not ship, its own namespaces too. */
|
|
21
|
+
messages?: Record<string, unknown>;
|
|
22
|
+
/** A date-fns locale (`import { de } from "date-fns/locale"`). */
|
|
23
|
+
dateFns?: Locale;
|
|
24
|
+
/** A react-day-picker locale (`import { de } from "react-day-picker/locale"`). */
|
|
25
|
+
dayPicker?: DayPickerLocale;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* First day of the week for `code`, as date-fns counts it (0 = Sunday … 6 = Saturday).
|
|
29
|
+
*
|
|
30
|
+
* From `Intl.Locale#getWeekInfo` (or the older `.weekInfo` getter) where the engine has it; else
|
|
31
|
+
* the pack's own `weekStartsOn`; else the region's CLDR first day, Monday (ISO 8601) by default.
|
|
32
|
+
*/
|
|
33
|
+
export declare function getLocaleWeekStart(code: string, pack?: Pick<Locale, "options">): 0 | 1 | 2 | 3 | 4 | 5 | 6;
|
|
34
|
+
/**
|
|
35
|
+
* Every registered locale's date adapters. `vi`, `en` and `ja` are pre-registered with the packs
|
|
36
|
+
* they always had; `registerLocale` adds the rest. Exported for compatibility — read it through
|
|
37
|
+
* `getDateFnsLocale` / `getDayPickerLocale`, which also handle an unregistered tag.
|
|
38
|
+
*/
|
|
39
|
+
export declare const APP_LOCALE_CONFIG: Record<string, AppLocaleConfig>;
|
|
40
|
+
/** The three locales the library ships packs for. */
|
|
41
|
+
export declare const BUILT_IN_LOCALES: readonly ["vi", "en", "ja"];
|
|
42
|
+
/**
|
|
43
|
+
* REGISTER A LOCALE — any BCP-47 tag (v32, gh#1219).
|
|
44
|
+
*
|
|
45
|
+
* The locale set used to be a closed union of three, so a German or Brazilian app could not get
|
|
46
|
+
* German dates or a Monday/Sunday week from this package at all. Register once at startup, before
|
|
47
|
+
* the first render:
|
|
48
|
+
*
|
|
49
|
+
* ```ts
|
|
50
|
+
* import { de } from "date-fns/locale";
|
|
51
|
+
* import { de as deDayPicker } from "react-day-picker/locale";
|
|
52
|
+
* registerLocale({ code: "de", messages: deMessages, dateFns: de, dayPicker: deDayPicker });
|
|
53
|
+
* ```
|
|
54
|
+
*
|
|
55
|
+
* Registering an already-registered tag updates it (messages merge; adapters given replace).
|
|
56
|
+
* Returns the canonical tag.
|
|
57
|
+
*/
|
|
58
|
+
export declare function registerLocale(input: RegisterLocaleInput): AppLocale;
|
|
59
|
+
/** Whether `value` is a REGISTERED locale tag (exactly, after canonicalisation). */
|
|
10
60
|
export declare function isAppLocale(value: string | null | undefined): value is AppLocale;
|
|
61
|
+
/**
|
|
62
|
+
* The registered locale that serves `tag` (`de-AT` → `de`), or — with one development warning —
|
|
63
|
+
* the default locale (`<html lang>` if registered, else `en`).
|
|
64
|
+
*/
|
|
65
|
+
export declare function normalizeAppLocale(tag: string | null | undefined): AppLocale;
|
|
11
66
|
export declare function getDateFnsLocale(locale: AppLocale): Locale;
|
|
12
|
-
export declare function getDayPickerLocale(locale: AppLocale):
|
|
67
|
+
export declare function getDayPickerLocale(locale: AppLocale): DayPickerLocale;
|
package/dist/app/locales.js
CHANGED
|
@@ -5,23 +5,149 @@ import {
|
|
|
5
5
|
ja as jaDayPicker,
|
|
6
6
|
vi as viDayPicker
|
|
7
7
|
} from "react-day-picker/locale";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import { registerLocaleMessages } from "../i18n/translate.js";
|
|
9
|
+
import {
|
|
10
|
+
canonicalLocaleTag,
|
|
11
|
+
getRegisteredLocales,
|
|
12
|
+
isBuiltInLocale,
|
|
13
|
+
markLocaleRegistered,
|
|
14
|
+
resolveDefaultLocale,
|
|
15
|
+
resolveRegisteredLocale,
|
|
16
|
+
warnUnknownLocale
|
|
17
|
+
} from "../i18n/locale-tags.js";
|
|
18
|
+
import { dateTimeFormat } from "../lib/intl-cache.js";
|
|
19
|
+
import { intlDatePattern } from "./date-formats.js";
|
|
20
|
+
import {
|
|
21
|
+
getRegisteredLocales as getRegisteredLocales2,
|
|
22
|
+
resolveRegisteredLocale as resolveRegisteredLocale2,
|
|
23
|
+
resolveDefaultLocale as resolveDefaultLocale2,
|
|
24
|
+
resolvePageLocale
|
|
25
|
+
} from "../i18n/locale-tags.js";
|
|
26
|
+
const SUNDAY_FIRST = "AG AS BD BR BS BT BW BZ CA CN CO DM DO ET GT GU HK HN ID IL IN JM JP KE KH KR LA MH MM MO MT MX MZ NI NP PA PE PH PK PR PT PY SA SG SV TH TT TW UM US VE VI WS YE ZA ZW";
|
|
27
|
+
const SATURDAY_FIRST = "AE AF BH DJ DZ EG IQ IR JO KW LY OM QA SD SY";
|
|
28
|
+
function intlWeekInfo(code) {
|
|
29
|
+
try {
|
|
30
|
+
const locale = new Intl.Locale(code);
|
|
31
|
+
return locale.getWeekInfo?.() ?? locale.weekInfo;
|
|
32
|
+
} catch {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function getLocaleWeekStart(code, pack) {
|
|
37
|
+
const info = intlWeekInfo(code);
|
|
38
|
+
if (info) return info.firstDay % 7;
|
|
39
|
+
const fromPack = pack?.options?.weekStartsOn;
|
|
40
|
+
if (fromPack !== void 0) return fromPack;
|
|
41
|
+
let region = "";
|
|
42
|
+
try {
|
|
43
|
+
region = new Intl.Locale(code).maximize().region ?? "";
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
if (region && SUNDAY_FIRST.split(" ").includes(region)) return 0;
|
|
47
|
+
if (region && SATURDAY_FIRST.split(" ").includes(region)) return 6;
|
|
48
|
+
return 1;
|
|
49
|
+
}
|
|
50
|
+
function withIntlWeekStart(code, pack) {
|
|
51
|
+
const weekStartsOn = getLocaleWeekStart(code, pack);
|
|
52
|
+
if (pack.options?.weekStartsOn === weekStartsOn) return pack;
|
|
53
|
+
return { ...pack, options: { ...pack.options, weekStartsOn } };
|
|
54
|
+
}
|
|
55
|
+
const INTL_WIDTH = {
|
|
56
|
+
narrow: "narrow",
|
|
57
|
+
short: "short",
|
|
58
|
+
abbreviated: "short",
|
|
59
|
+
wide: "long",
|
|
60
|
+
any: "long"
|
|
61
|
+
};
|
|
62
|
+
const LONG_DATE = {
|
|
63
|
+
full: { weekday: "long", year: "numeric", month: "long", day: "numeric" },
|
|
64
|
+
long: { year: "numeric", month: "long", day: "numeric" },
|
|
65
|
+
medium: { year: "numeric", month: "short", day: "numeric" },
|
|
66
|
+
short: { year: "numeric", month: "2-digit", day: "2-digit" },
|
|
67
|
+
any: { year: "numeric", month: "long", day: "numeric" }
|
|
12
68
|
};
|
|
69
|
+
function intlDateFnsLocale(code) {
|
|
70
|
+
const name = (options, date) => dateTimeFormat(code, { ...options, timeZone: "UTC" }).format(date);
|
|
71
|
+
const width = (options) => INTL_WIDTH[options?.width ?? "wide"];
|
|
72
|
+
const info = intlWeekInfo(code);
|
|
73
|
+
return {
|
|
74
|
+
...enUS,
|
|
75
|
+
code,
|
|
76
|
+
localize: {
|
|
77
|
+
...enUS.localize,
|
|
78
|
+
// 2017-01-01 was a Sunday, so day `n` of that week is weekday `n` in date-fns' numbering.
|
|
79
|
+
month: (n, options) => name({ month: width(options) }, new Date(Date.UTC(2017, n, 1))),
|
|
80
|
+
day: (n, options) => name({ weekday: width(options) }, new Date(Date.UTC(2017, 0, 1 + n)))
|
|
81
|
+
},
|
|
82
|
+
formatLong: {
|
|
83
|
+
...enUS.formatLong,
|
|
84
|
+
date: ({ width: w = "full" } = {}) => intlDatePattern(code, LONG_DATE[w]) ?? enUS.formatLong.date({ width: w })
|
|
85
|
+
},
|
|
86
|
+
options: {
|
|
87
|
+
weekStartsOn: getLocaleWeekStart(code),
|
|
88
|
+
firstWeekContainsDate: info?.minimalDays === 4 ? 4 : 1
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
const APP_LOCALE_CONFIG = {};
|
|
93
|
+
function storeConfig(code, dateFns, dayPicker) {
|
|
94
|
+
const config = {
|
|
95
|
+
code,
|
|
96
|
+
dateFns: withIntlWeekStart(code, dateFns),
|
|
97
|
+
dayPicker: withIntlWeekStart(code, dayPicker)
|
|
98
|
+
};
|
|
99
|
+
APP_LOCALE_CONFIG[code] = config;
|
|
100
|
+
return config;
|
|
101
|
+
}
|
|
102
|
+
storeConfig("vi", vi, viDayPicker);
|
|
103
|
+
storeConfig("en", enUS, enUSDayPicker);
|
|
104
|
+
storeConfig("ja", ja, jaDayPicker);
|
|
105
|
+
const BUILT_IN_LOCALES = ["vi", "en", "ja"];
|
|
106
|
+
function registerLocale(input) {
|
|
107
|
+
const code = canonicalLocaleTag(input.code);
|
|
108
|
+
const existing = APP_LOCALE_CONFIG[code];
|
|
109
|
+
const dateFns = input.dateFns ?? existing?.dateFns ?? intlDateFnsLocale(code);
|
|
110
|
+
const dayPicker = input.dayPicker ?? existing?.dayPicker ?? dateFns;
|
|
111
|
+
storeConfig(code, dateFns, dayPicker);
|
|
112
|
+
markLocaleRegistered(code);
|
|
113
|
+
registerLocaleMessages(code, input.messages ?? {}, !isBuiltInLocale(code));
|
|
114
|
+
return code;
|
|
115
|
+
}
|
|
13
116
|
function isAppLocale(value) {
|
|
14
|
-
|
|
117
|
+
if (!value) return false;
|
|
118
|
+
try {
|
|
119
|
+
return getRegisteredLocales().includes(canonicalLocaleTag(value));
|
|
120
|
+
} catch {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function normalizeAppLocale(tag) {
|
|
125
|
+
const resolved = resolveRegisteredLocale(tag);
|
|
126
|
+
if (resolved) return resolved;
|
|
127
|
+
const fallback = resolveDefaultLocale();
|
|
128
|
+
if (tag) warnUnknownLocale(tag, fallback);
|
|
129
|
+
return fallback;
|
|
130
|
+
}
|
|
131
|
+
function configFor(locale) {
|
|
132
|
+
return APP_LOCALE_CONFIG[locale] ?? APP_LOCALE_CONFIG[normalizeAppLocale(locale)] ?? APP_LOCALE_CONFIG.en;
|
|
15
133
|
}
|
|
16
134
|
function getDateFnsLocale(locale) {
|
|
17
|
-
return
|
|
135
|
+
return configFor(locale).dateFns;
|
|
18
136
|
}
|
|
19
137
|
function getDayPickerLocale(locale) {
|
|
20
|
-
return
|
|
138
|
+
return configFor(locale).dayPicker;
|
|
21
139
|
}
|
|
22
140
|
export {
|
|
23
141
|
APP_LOCALE_CONFIG,
|
|
142
|
+
BUILT_IN_LOCALES,
|
|
24
143
|
getDateFnsLocale,
|
|
25
144
|
getDayPickerLocale,
|
|
26
|
-
|
|
145
|
+
getLocaleWeekStart,
|
|
146
|
+
getRegisteredLocales2 as getRegisteredLocales,
|
|
147
|
+
isAppLocale,
|
|
148
|
+
normalizeAppLocale,
|
|
149
|
+
registerLocale,
|
|
150
|
+
resolveDefaultLocale2 as resolveDefaultLocale,
|
|
151
|
+
resolvePageLocale,
|
|
152
|
+
resolveRegisteredLocale2 as resolveRegisteredLocale
|
|
27
153
|
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
/**
|
|
3
|
+
* An app PRESET (v32, gh#1220): the product-specific defaults a host opts into, so the library's
|
|
4
|
+
* own defaults can stay neutral. Core never imports a preset; a host passes one to
|
|
5
|
+
* `<AppProvider preset={…}>`, and the GoDX look ships as `godxPreset` from
|
|
6
|
+
* `@godxjp/ui/themes/godx` together with `@godxjp/ui/themes/godx.css`.
|
|
7
|
+
*
|
|
8
|
+
* Every field is optional and only fills what the host left unset: an explicit `AppProvider` prop
|
|
9
|
+
* always wins over the preset.
|
|
10
|
+
*/
|
|
11
|
+
export interface AppPreset {
|
|
12
|
+
/** Stable name, written to `<html data-preset>` so a preset stylesheet can scope itself. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** BCP-47 tag used when the host gives no `defaultLocale` (and `<html lang>` has none registered). */
|
|
15
|
+
defaultLocale?: string;
|
|
16
|
+
/** IANA zone used when the host gives no `timeZone`. */
|
|
17
|
+
timeZone?: string;
|
|
18
|
+
/** The brand mark `AuthIdentity` (and other identity surfaces) render when given no `brand`. */
|
|
19
|
+
brandMark?: React.ReactNode;
|
|
20
|
+
/** Label for the email brand mark when the caller passes none. */
|
|
21
|
+
emailBrandLabel?: string;
|
|
22
|
+
}
|
|
23
|
+
export declare const AppPresetContext: React.Context<AppPreset | undefined>;
|
|
24
|
+
/** The active preset, or `undefined` when the host chose none (the neutral default). */
|
|
25
|
+
export declare function useAppPreset(): AppPreset | undefined;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AppRequestHeaders } from "./types.js";
|
|
2
|
-
/** Sync locale/timezone into
|
|
2
|
+
/** Sync locale/timezone into the CURRENT scope for HTTP clients (via `getAppRequestHeaders`). */
|
|
3
3
|
export declare function syncAppRequestHeaders(headers: Partial<AppRequestHeaders>): void;
|
|
4
|
-
/** Read current
|
|
4
|
+
/** Read the current scope's preference headers — wire to API client `setAppHeaderProvider`. */
|
|
5
5
|
export declare function getAppRequestHeaders(): AppRequestHeaders;
|
|
6
|
-
/** Reset to defaults — for tests only. */
|
|
6
|
+
/** Reset the current scope's headers to defaults — for tests only. */
|
|
7
7
|
export declare function resetAppRequestHeaders(): void;
|
|
@@ -4,21 +4,30 @@ import {
|
|
|
4
4
|
APP_REQUEST_HEADER_TIME_FORMAT,
|
|
5
5
|
APP_REQUEST_HEADER_TIMEZONE
|
|
6
6
|
} from "./types.js";
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
import { getAppSettingsState } from "./settings-scope.js";
|
|
8
|
+
import { resolveDefaultDateFormat } from "./date-format-labels.js";
|
|
9
|
+
import { resolveDefaultTimeFormat } from "./time-format-labels.js";
|
|
10
|
+
import { getBrowserTimezone } from "./timezones.js";
|
|
11
|
+
import { resolveDefaultLocale } from "../i18n/locale-tags.js";
|
|
12
|
+
function defaultHeaders() {
|
|
13
|
+
const { i18n, datetime } = getAppSettingsState();
|
|
14
|
+
const locale = i18n?.locale ?? datetime?.locale ?? resolveDefaultLocale();
|
|
15
|
+
return {
|
|
16
|
+
[APP_REQUEST_HEADER_LOCALE]: locale,
|
|
17
|
+
[APP_REQUEST_HEADER_TIMEZONE]: datetime?.timezone ?? (typeof window === "undefined" ? "UTC" : getBrowserTimezone()),
|
|
18
|
+
[APP_REQUEST_HEADER_TIME_FORMAT]: datetime?.timeFormat ?? resolveDefaultTimeFormat(locale),
|
|
19
|
+
[APP_REQUEST_HEADER_DATE_FORMAT]: datetime?.dateFormat ?? resolveDefaultDateFormat(locale)
|
|
20
|
+
};
|
|
21
|
+
}
|
|
14
22
|
function syncAppRequestHeaders(headers) {
|
|
15
|
-
|
|
23
|
+
const state = getAppSettingsState();
|
|
24
|
+
state.headers = { ...state.headers, ...headers };
|
|
16
25
|
}
|
|
17
26
|
function getAppRequestHeaders() {
|
|
18
|
-
return { ...
|
|
27
|
+
return { ...defaultHeaders(), ...getAppSettingsState().headers };
|
|
19
28
|
}
|
|
20
29
|
function resetAppRequestHeaders() {
|
|
21
|
-
|
|
30
|
+
getAppSettingsState().headers = void 0;
|
|
22
31
|
}
|
|
23
32
|
export {
|
|
24
33
|
getAppRequestHeaders,
|