@xdev-asia/ui 0.0.0-stage → 4.15.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/AGENTS.md +66 -0
- package/LICENSE +202 -0
- package/README.md +149 -2
- package/assets/brand/mobile/android-background-1024.png +0 -0
- package/assets/brand/mobile/android-background.svg +13 -0
- package/assets/brand/mobile/android-foreground-1024.png +0 -0
- package/assets/brand/mobile/android-foreground.svg +13 -0
- package/assets/brand/mobile/android-monochrome-1024.png +0 -0
- package/assets/brand/mobile/android-monochrome.svg +3 -0
- package/assets/brand/mobile/ios-icon-1024.png +0 -0
- package/assets/brand/mobile/ios-icon-dark-1024.png +0 -0
- package/assets/brand/mobile/ios-icon-dark.svg +22 -0
- package/assets/brand/mobile/ios-icon.svg +22 -0
- package/assets/brand/systems/xdev-ui-icon.svg +23 -0
- package/assets/brand/systems/xdev-ui-lockup-dark.svg +24 -0
- package/assets/brand/systems/xdev-ui-lockup-light.svg +24 -0
- package/assets/brand/systems/xdev-ui-mark-lit.svg +13 -0
- package/assets/brand/systems/xdev-ui-mark.svg +3 -0
- package/assets/brand/xdev-icon-512.png +0 -0
- package/assets/brand/xdev-icon-blue.svg +23 -0
- package/assets/brand/xdev-icon.svg +23 -0
- package/assets/brand/xdev-lockup-dark.svg +24 -0
- package/assets/brand/xdev-lockup-light.svg +24 -0
- package/assets/brand/xdev-mark-lit.svg +13 -0
- package/assets/brand/xdev-mark-tile.svg +3 -0
- package/assets/brand/xdev-mark.svg +3 -0
- package/bin/xdev-ui-skills.mjs +142 -0
- package/dist/Workspace.stories.d.ts +15 -0
- package/dist/ai-manifest.json +3727 -0
- package/dist/chunks/FileDrop-C-ygn8kF.js +891 -0
- package/dist/chunks/FileDrop-C-ygn8kF.js.map +1 -0
- package/dist/chunks/Popover-Ds4RBtZv.js +121 -0
- package/dist/chunks/Popover-Ds4RBtZv.js.map +1 -0
- package/dist/chunks/crop-CahE3q01.js +55 -0
- package/dist/chunks/crop-CahE3q01.js.map +1 -0
- package/dist/chunks/modal-BYFY08ti.js +54 -0
- package/dist/chunks/modal-BYFY08ti.js.map +1 -0
- package/dist/components/ActionTile/ActionTile.d.ts +14 -0
- package/dist/components/ActionTile/ActionTile.stories.d.ts +18 -0
- package/dist/components/ActivityBar/ActivityBar.d.ts +36 -0
- package/dist/components/ActivityBar/ActivityBar.stories.d.ts +27 -0
- package/dist/components/AgentChip/AgentChip.d.ts +10 -0
- package/dist/components/AgentChip/AgentChip.stories.d.ts +21 -0
- package/dist/components/AgentRow/AgentRow.d.ts +24 -0
- package/dist/components/AgentRow/AgentRow.stories.d.ts +19 -0
- package/dist/components/AppShell/AppShell.d.ts +58 -0
- package/dist/components/AppShell/AppShell.stories.d.ts +17 -0
- package/dist/components/ApprovalBar/ApprovalBar.d.ts +23 -0
- package/dist/components/ApprovalBar/ApprovalBar.stories.d.ts +18 -0
- package/dist/components/AttentionInbox/AttentionInbox.d.ts +43 -0
- package/dist/components/AttentionInbox/AttentionInbox.stories.d.ts +16 -0
- package/dist/components/AudioPreview/AudioPreview.d.ts +33 -0
- package/dist/components/AudioPreview/AudioPreview.stories.d.ts +23 -0
- package/dist/components/AudioPreview/audio-preview-store.d.ts +14 -0
- package/dist/components/AuthShell/AuthShell.d.ts +24 -0
- package/dist/components/AuthShell/AuthShell.stories.d.ts +20 -0
- package/dist/components/Avatar/Avatar.d.ts +13 -0
- package/dist/components/Avatar/Avatar.stories.d.ts +21 -0
- package/dist/components/Badge/Badge.d.ts +14 -0
- package/dist/components/Badge/Badge.stories.d.ts +26 -0
- package/dist/components/Banner/Banner.d.ts +11 -0
- package/dist/components/Banner/Banner.stories.d.ts +23 -0
- package/dist/components/BarChart/BarChart.d.ts +20 -0
- package/dist/components/BarChart/BarChart.stories.d.ts +24 -0
- package/dist/components/Board/Board.d.ts +9 -0
- package/dist/components/Board/Board.stories.d.ts +18 -0
- package/dist/components/BoardCard/BoardCard.d.ts +32 -0
- package/dist/components/BoardColumn/BoardColumn.d.ts +24 -0
- package/dist/components/BottomNav/BottomNav.d.ts +40 -0
- package/dist/components/BottomNav/BottomNav.stories.d.ts +40 -0
- package/dist/components/BrandMark/BrandMark.d.ts +20 -0
- package/dist/components/BrandMark/BrandMark.stories.d.ts +28 -0
- package/dist/components/Breadcrumb/Breadcrumb.d.ts +22 -0
- package/dist/components/Breadcrumb/Breadcrumb.stories.d.ts +27 -0
- package/dist/components/BulkBar/BulkBar.d.ts +21 -0
- package/dist/components/BulkBar/BulkBar.stories.d.ts +16 -0
- package/dist/components/Button/Button.d.ts +42 -0
- package/dist/components/Button/Button.stories.d.ts +41 -0
- package/dist/components/Card/Card.d.ts +22 -0
- package/dist/components/Card/Card.stories.d.ts +307 -0
- package/dist/components/Checkbox/Checkbox.d.ts +10 -0
- package/dist/components/Checkbox/Checkbox.stories.d.ts +18 -0
- package/dist/components/Coachmark/Coachmark.d.ts +31 -0
- package/dist/components/Coachmark/Coachmark.stories.d.ts +27 -0
- package/dist/components/Coachmark/placeCoachmark.d.ts +31 -0
- package/dist/components/CodeBlock/CodeBlock.d.ts +19 -0
- package/dist/components/CodeBlock/CodeBlock.stories.d.ts +22 -0
- package/dist/components/CodeInput/CodeInput.d.ts +25 -0
- package/dist/components/CodeInput/CodeInput.stories.d.ts +32 -0
- package/dist/components/CodeInput/normalizeCode.d.ts +10 -0
- package/dist/components/ColorField/ColorField.d.ts +29 -0
- package/dist/components/Combobox/Combobox.d.ts +105 -0
- package/dist/components/Combobox/Combobox.stories.d.ts +42 -0
- package/dist/components/CommandPalette/CommandPalette.d.ts +94 -0
- package/dist/components/CommandPalette/CommandPalette.stories.d.ts +39 -0
- package/dist/components/Comment/Comment.d.ts +25 -0
- package/dist/components/Comment/Comment.stories.d.ts +24 -0
- package/dist/components/CommitGraph/CommitGraph.d.ts +15 -0
- package/dist/components/CommitGraph/CommitGraph.stories.d.ts +15 -0
- package/dist/components/CommitGraph/graphLanes.d.ts +56 -0
- package/dist/components/Composer/Composer.d.ts +31 -0
- package/dist/components/Composer/Composer.stories.d.ts +17 -0
- package/dist/components/Container/Container.d.ts +11 -0
- package/dist/components/Container/Container.stories.d.ts +14 -0
- package/dist/components/DataTable/DataTable.d.ts +79 -0
- package/dist/components/DataTable/DataTable.stories.d.ts +26 -0
- package/dist/components/DataTable/table-helpers.d.ts +16 -0
- package/dist/components/DataTable/table-reorder.d.ts +40 -0
- package/dist/components/DatePicker/Calendar.d.ts +51 -0
- package/dist/components/DatePicker/DatePicker.d.ts +51 -0
- package/dist/components/DatePicker/DatePicker.stories.d.ts +42 -0
- package/dist/components/DateRangePicker/DateRangePicker.d.ts +59 -0
- package/dist/components/DateRangePicker/DateRangePicker.stories.d.ts +42 -0
- package/dist/components/DescriptionList/DescriptionList.d.ts +14 -0
- package/dist/components/DescriptionList/DescriptionList.stories.d.ts +21 -0
- package/dist/components/Dialog/Dialog.d.ts +43 -0
- package/dist/components/Dialog/Dialog.stories.d.ts +22 -0
- package/dist/components/DiffStat/DiffStat.d.ts +12 -0
- package/dist/components/DiffStat/DiffStat.stories.d.ts +15 -0
- package/dist/components/Disclosure/Disclosure.d.ts +18 -0
- package/dist/components/Disclosure/Disclosure.stories.d.ts +27 -0
- package/dist/components/DonutChart/DonutChart.d.ts +30 -0
- package/dist/components/DonutChart/DonutChart.stories.d.ts +26 -0
- package/dist/components/Drawer/Drawer.d.ts +27 -0
- package/dist/components/Drawer/Drawer.stories.d.ts +18 -0
- package/dist/components/Emblem/Emblem.d.ts +19 -0
- package/dist/components/Emblem/Emblem.stories.d.ts +19 -0
- package/dist/components/EmptyState/EmptyState.d.ts +43 -0
- package/dist/components/EmptyState/EmptyState.stories.d.ts +17 -0
- package/dist/components/EndpointPanel/EndpointPanel.d.ts +29 -0
- package/dist/components/FacetFilter/FacetFilter.d.ts +39 -0
- package/dist/components/FacetFilter/FacetFilter.stories.d.ts +23 -0
- package/dist/components/FacetFilter/facet-helpers.d.ts +5 -0
- package/dist/components/Field/Field.d.ts +27 -0
- package/dist/components/Field/Field.stories.d.ts +25 -0
- package/dist/components/FieldMessage/FieldMessage.d.ts +10 -0
- package/dist/components/FieldMessage/FieldMessage.stories.d.ts +14 -0
- package/dist/components/FileDrop/FileDrop.d.ts +72 -0
- package/dist/components/FileDrop/FileDrop.stories.d.ts +18 -0
- package/dist/components/FileIcon/FileIcon.d.ts +25 -0
- package/dist/components/FileIcon/FileIcon.stories.d.ts +14 -0
- package/dist/components/FilterChip/FilterChip.d.ts +9 -0
- package/dist/components/FilterChip/FilterChip.stories.d.ts +19 -0
- package/dist/components/FlowMap/FlowMap.d.ts +74 -0
- package/dist/components/FlowMap/FlowMap.stories.d.ts +24 -0
- package/dist/components/FontField/FontField.d.ts +15 -0
- package/dist/components/FontField/FontField.stories.d.ts +17 -0
- package/dist/components/FormDialog/FormDialog.d.ts +40 -0
- package/dist/components/FormDialog/FormDialog.stories.d.ts +22 -0
- package/dist/components/FormSection/FormSection.d.ts +19 -0
- package/dist/components/FormSection/FormSection.stories.d.ts +16 -0
- package/dist/components/Grid/Grid.d.ts +23 -0
- package/dist/components/Grid/Grid.stories.d.ts +19 -0
- package/dist/components/Grid/breakpoints.d.ts +25 -0
- package/dist/components/Heatmap/Heatmap.d.ts +22 -0
- package/dist/components/Heatmap/Heatmap.stories.d.ts +24 -0
- package/dist/components/Icon/Icon.d.ts +14 -0
- package/dist/components/Icon/Icon.stories.d.ts +20 -0
- package/dist/components/IconButton/IconButton.d.ts +16 -0
- package/dist/components/IconButton/IconButton.stories.d.ts +27 -0
- package/dist/components/Identity/Identity.d.ts +14 -0
- package/dist/components/Identity/Identity.stories.d.ts +14 -0
- package/dist/components/Kbd/Kbd.d.ts +5 -0
- package/dist/components/Kbd/Kbd.stories.d.ts +13 -0
- package/dist/components/Label/Label.d.ts +15 -0
- package/dist/components/Label/Label.stories.d.ts +16 -0
- package/dist/components/LaunchCard/LaunchCard.d.ts +36 -0
- package/dist/components/LaunchCard/LaunchCard.stories.d.ts +32 -0
- package/dist/components/List/List.d.ts +11 -0
- package/dist/components/List/List.stories.d.ts +13 -0
- package/dist/components/ListRow/ListRow.d.ts +20 -0
- package/dist/components/ListRow/ListRow.stories.d.ts +27 -0
- package/dist/components/Menu/Menu.d.ts +53 -0
- package/dist/components/Menu/Menu.stories.d.ts +85 -0
- package/dist/components/Menu/MenuButton.d.ts +23 -0
- package/dist/components/Menu/MenuButton.stories.d.ts +46 -0
- package/dist/components/Menu/menu-keys.d.ts +26 -0
- package/dist/components/Meter/Meter.d.ts +18 -0
- package/dist/components/Meter/Meter.stories.d.ts +34 -0
- package/dist/components/ModelChip/ModelChip.d.ts +26 -0
- package/dist/components/ModelChip/ModelChip.stories.d.ts +18 -0
- package/dist/components/NavList/NavList.d.ts +56 -0
- package/dist/components/NavList/NavList.stories.d.ts +25 -0
- package/dist/components/PageHeader/PageHeader.d.ts +14 -0
- package/dist/components/PageHeader/PageHeader.stories.d.ts +14 -0
- package/dist/components/Pagination/Pagination.d.ts +28 -0
- package/dist/components/Pagination/Pagination.stories.d.ts +16 -0
- package/dist/components/PairingCode/PairingCode.d.ts +17 -0
- package/dist/components/PairingCode/PairingCode.stories.d.ts +24 -0
- package/dist/components/PaletteTrigger/PaletteTrigger.d.ts +16 -0
- package/dist/components/PanZoom/PanZoom.d.ts +24 -0
- package/dist/components/PanZoom/PanZoom.stories.d.ts +11 -0
- package/dist/components/Popover/Popover.d.ts +24 -0
- package/dist/components/Popover/Popover.stories.d.ts +25 -0
- package/dist/components/Prose/Prose.d.ts +8 -0
- package/dist/components/Prose/Prose.stories.d.ts +12 -0
- package/dist/components/RadioGroup/RadioGroup.d.ts +27 -0
- package/dist/components/RadioGroup/RadioGroup.stories.d.ts +22 -0
- package/dist/components/ReactionBar/ReactionBar.d.ts +21 -0
- package/dist/components/ReactionBar/ReactionBar.stories.d.ts +26 -0
- package/dist/components/ResourceCard/ResourceCard.d.ts +30 -0
- package/dist/components/ResourceCard/ResourceCard.stories.d.ts +19 -0
- package/dist/components/ReviewComment/ReviewComment.d.ts +41 -0
- package/dist/components/ReviewComment/ReviewComment.stories.d.ts +19 -0
- package/dist/components/RouteDiagram/RouteDiagram.d.ts +27 -0
- package/dist/components/RunTimeline/RunTimeline.d.ts +28 -0
- package/dist/components/RunTimeline/RunTimeline.stories.d.ts +31 -0
- package/dist/components/SaveBar/SaveBar.d.ts +56 -0
- package/dist/components/SaveBar/SaveBar.stories.d.ts +16 -0
- package/dist/components/SearchInput/SearchInput.d.ts +22 -0
- package/dist/components/SearchInput/SearchInput.stories.d.ts +18 -0
- package/dist/components/SearchPicker/SearchPicker.d.ts +49 -0
- package/dist/components/SearchPicker/SearchPicker.stories.d.ts +33 -0
- package/dist/components/Segmented/Segmented.d.ts +18 -0
- package/dist/components/Segmented/Segmented.stories.d.ts +18 -0
- package/dist/components/Select/Select.d.ts +26 -0
- package/dist/components/Select/Select.stories.d.ts +22 -0
- package/dist/components/ServiceStatus/ServiceStatus.d.ts +13 -0
- package/dist/components/SessionBar/SessionBar.d.ts +33 -0
- package/dist/components/SessionBar/SessionBar.stories.d.ts +27 -0
- package/dist/components/SettingRow/SettingRow.d.ts +17 -0
- package/dist/components/SettingRow/SettingRow.stories.d.ts +26 -0
- package/dist/components/SettingsShell/SettingsShell.d.ts +52 -0
- package/dist/components/SettingsShell/SettingsShell.stories.d.ts +9 -0
- package/dist/components/ShellTitle/ShellTitle.d.ts +25 -0
- package/dist/components/SiteShell/SiteShell.d.ts +24 -0
- package/dist/components/SiteShell/SiteShell.stories.d.ts +18 -0
- package/dist/components/Skeleton/Skeleton.d.ts +20 -0
- package/dist/components/Skeleton/Skeleton.stories.d.ts +15 -0
- package/dist/components/SortableList/SortableList.d.ts +30 -0
- package/dist/components/SortableList/SortableList.stories.d.ts +16 -0
- package/dist/components/Spinner/Spinner.d.ts +15 -0
- package/dist/components/Spinner/Spinner.stories.d.ts +14 -0
- package/dist/components/SplitHandle/SplitHandle.d.ts +25 -0
- package/dist/components/SplitHandle/SplitHandle.stories.d.ts +18 -0
- package/dist/components/Stack/Stack.d.ts +18 -0
- package/dist/components/Stack/Stack.stories.d.ts +12 -0
- package/dist/components/StatTile/StatTile.d.ts +30 -0
- package/dist/components/StatTile/StatTile.stories.d.ts +32 -0
- package/dist/components/StatusBar/StatusBar.d.ts +8 -0
- package/dist/components/StatusBar/StatusBar.stories.d.ts +15 -0
- package/dist/components/StatusDot/StatusDot.d.ts +18 -0
- package/dist/components/StatusDot/StatusDot.stories.d.ts +24 -0
- package/dist/components/StepDots/StepDots.d.ts +15 -0
- package/dist/components/StepDots/StepDots.stories.d.ts +15 -0
- package/dist/components/SwatchGroup/SwatchGroup.d.ts +20 -0
- package/dist/components/SwatchGroup/SwatchGroup.stories.d.ts +33 -0
- package/dist/components/Switch/Switch.d.ts +10 -0
- package/dist/components/Switch/Switch.stories.d.ts +17 -0
- package/dist/components/TabStrip/TabStrip.d.ts +44 -0
- package/dist/components/TabStrip/TabStrip.stories.d.ts +66 -0
- package/dist/components/Tabs/Tabs.d.ts +28 -0
- package/dist/components/Tabs/Tabs.stories.d.ts +34 -0
- package/dist/components/Tag/Tag.d.ts +12 -0
- package/dist/components/Tag/Tag.stories.d.ts +21 -0
- package/dist/components/Textarea/Textarea.d.ts +15 -0
- package/dist/components/Textarea/Textarea.stories.d.ts +19 -0
- package/dist/components/ThemeEditor/ThemeEditor.d.ts +56 -0
- package/dist/components/ThemePreview/ThemePreview.d.ts +15 -0
- package/dist/components/ThemeSwitch/ThemeSwitch.d.ts +30 -0
- package/dist/components/ThemeSwitch/ThemeSwitch.stories.d.ts +15 -0
- package/dist/components/TimeField/TimeField.d.ts +32 -0
- package/dist/components/TimeField/TimeField.stories.d.ts +36 -0
- package/dist/components/TimeField/time-text.d.ts +26 -0
- package/dist/components/TimeSeriesChart/TimeSeriesChart.d.ts +30 -0
- package/dist/components/TimeSeriesChart/TimeSeriesChart.stories.d.ts +29 -0
- package/dist/components/Toast/Toast.d.ts +18 -0
- package/dist/components/Toast/Toast.stories.d.ts +15 -0
- package/dist/components/Toast/Toaster.d.ts +18 -0
- package/dist/components/Toast/Toaster.stories.d.ts +16 -0
- package/dist/components/Toast/toast-region.d.ts +17 -0
- package/dist/components/Toast/toast-store.d.ts +46 -0
- package/dist/components/ToggleButton/ToggleButton.d.ts +16 -0
- package/dist/components/ToggleButton/ToggleButton.stories.d.ts +20 -0
- package/dist/components/Toolbar/Toolbar.d.ts +21 -0
- package/dist/components/Toolbar/Toolbar.stories.d.ts +25 -0
- package/dist/components/Tooltip/Tooltip.d.ts +13 -0
- package/dist/components/Tooltip/Tooltip.stories.d.ts +23 -0
- package/dist/components/TreeView/TreeView.d.ts +42 -0
- package/dist/components/TreeView/TreeView.stories.d.ts +26 -0
- package/dist/components/TreeView/pathRows.d.ts +16 -0
- package/dist/components/TreeView/treeKeys.d.ts +16 -0
- package/dist/components/UsageMeterRow/UsageMeterRow.d.ts +28 -0
- package/dist/components/UsageMeterRow/UsageMeterRow.stories.d.ts +26 -0
- package/dist/components/WorktreeRow/WorktreeRow.d.ts +32 -0
- package/dist/components/WorktreeRow/WorktreeRow.stories.d.ts +32 -0
- package/dist/components/ZoomBar/ZoomBar.d.ts +22 -0
- package/dist/components/ZoomBar/ZoomBar.stories.d.ts +17 -0
- package/dist/editor/RichTextEditor/EditorToolbar.d.ts +35 -0
- package/dist/editor/RichTextEditor/ImageBar.d.ts +17 -0
- package/dist/editor/RichTextEditor/LinkForm.d.ts +16 -0
- package/dist/editor/RichTextEditor/RichTextEditor.d.ts +45 -0
- package/dist/editor/RichTextEditor/RichTextEditor.stories.d.ts +43 -0
- package/dist/editor/RichTextEditor/extensions.d.ts +23 -0
- package/dist/editor/RichTextEditor/icons.d.ts +23 -0
- package/dist/editor/RichTextEditor/insertImage.d.ts +28 -0
- package/dist/editor/RichTextEditor/labels.d.ts +32 -0
- package/dist/editor/index.d.ts +4 -0
- package/dist/editor.js +629 -0
- package/dist/editor.js.map +1 -0
- package/dist/fonts.css +2 -0
- package/dist/icons.d.ts +891 -0
- package/dist/image/ImageCropper/ImageCropper.d.ts +39 -0
- package/dist/image/ImageCropper/ImageCropper.stories.d.ts +18 -0
- package/dist/image/ImageField/ImageField.d.ts +86 -0
- package/dist/image/ImageField/ImageField.stories.d.ts +29 -0
- package/dist/image/crop.d.ts +39 -0
- package/dist/image/index.d.ts +3 -0
- package/dist/image.js +377 -0
- package/dist/image.js.map +1 -0
- package/dist/index.d.ts +138 -0
- package/dist/index.js +8253 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/cx.d.ts +2 -0
- package/dist/internal/date.d.ts +96 -0
- package/dist/internal/duration.d.ts +4 -0
- package/dist/internal/focus.d.ts +34 -0
- package/dist/internal/keys.d.ts +21 -0
- package/dist/internal/modal.d.ts +8 -0
- package/dist/internal/portal.d.ts +9 -0
- package/dist/internal/position.d.ts +37 -0
- package/dist/internal/reveal.d.ts +6 -0
- package/dist/internal/roving.d.ts +25 -0
- package/dist/internal/scroll-fade.d.ts +16 -0
- package/dist/internal/session-labels.d.ts +3 -0
- package/dist/internal/text.d.ts +2 -0
- package/dist/llms-full.txt +9786 -0
- package/dist/llms.txt +162 -0
- package/dist/mcp.js +24706 -0
- package/dist/panZoom.d.ts +40 -0
- package/dist/styles.css +2 -0
- package/dist/styles.layered.css +4 -0
- package/dist/tailwind.css +38 -0
- package/dist/test-utils.d.ts +5 -0
- package/dist/theme/font.d.ts +20 -0
- package/dist/theme/index.d.ts +2 -0
- package/dist/theme/theme.d.ts +62 -0
- package/dist/tokens.css +304 -0
- package/dist/tokens.json +267 -0
- package/dist/types.d.ts +6 -0
- package/package.json +177 -4
- package/skills/xdev-ui-admin/SKILL.md +106 -0
- package/skills/xdev-ui-admin/references/audit-log.md +18 -0
- package/skills/xdev-ui-admin/references/console-chrome.md +119 -0
- package/skills/xdev-ui-admin/references/dashboard.md +24 -0
- package/skills/xdev-ui-admin/references/detail-and-forms.md +22 -0
- package/skills/xdev-ui-admin/references/dialogs.md +33 -0
- package/skills/xdev-ui-admin/references/forms.md +60 -0
- package/skills/xdev-ui-admin/references/from-other-kits.md +75 -0
- package/skills/xdev-ui-admin/references/layout.md +58 -0
- package/skills/xdev-ui-admin/references/navigation.md +10 -0
- package/skills/xdev-ui-admin/references/permissions.md +26 -0
- package/skills/xdev-ui-admin/references/resource-list.md +64 -0
- package/skills/xdev-ui-admin/references/responsive.md +68 -0
- package/skills/xdev-ui-admin/references/rich-content.md +37 -0
- package/skills/xdev-ui-admin/references/settings.md +20 -0
- package/skills/xdev-ui-admin/references/sign-in.md +47 -0
- package/skills/xdev-ui-admin/references/states-feedback.md +26 -0
- package/skills/xdev-ui-admin/references/tree-list.md +50 -0
- package/skills/xdev-ui-admin/references/users-roles.md +32 -0
- package/skills/xdev-ui-admin/references/ux-principles.md +43 -0
- package/skills/xdev-ui-admin/references/visual-identity.md +62 -0
- package/skills/xdev-ui-admin/templates/admin/_gitignore +3 -0
- package/skills/xdev-ui-admin/templates/admin/_mcp.json +5 -0
- package/skills/xdev-ui-admin/templates/admin/_npmrc +2 -0
- package/skills/xdev-ui-admin/templates/admin/index.html +14 -0
- package/skills/xdev-ui-admin/templates/admin/package.json +24 -0
- package/skills/xdev-ui-admin/templates/admin/src/App.tsx +66 -0
- package/skills/xdev-ui-admin/templates/admin/src/app.css +26 -0
- package/skills/xdev-ui-admin/templates/admin/src/auth/permissions.ts +7 -0
- package/skills/xdev-ui-admin/templates/admin/src/auth/session.ts +42 -0
- package/skills/xdev-ui-admin/templates/admin/src/data/context.ts +11 -0
- package/skills/xdev-ui-admin/templates/admin/src/data/store.ts +84 -0
- package/skills/xdev-ui-admin/templates/admin/src/data/useLoad.ts +25 -0
- package/skills/xdev-ui-admin/templates/admin/src/i18n/en.ts +98 -0
- package/skills/xdev-ui-admin/templates/admin/src/i18n/index.tsx +63 -0
- package/skills/xdev-ui-admin/templates/admin/src/i18n/vi.ts +98 -0
- package/skills/xdev-ui-admin/templates/admin/src/i18n/xdev-ui-labels.ts +47 -0
- package/skills/xdev-ui-admin/templates/admin/src/main.tsx +12 -0
- package/skills/xdev-ui-admin/templates/admin/src/notify.tsx +36 -0
- package/skills/xdev-ui-admin/templates/admin/src/pages/Dashboard.tsx +55 -0
- package/skills/xdev-ui-admin/templates/admin/src/pages/ItemDetail.tsx +83 -0
- package/skills/xdev-ui-admin/templates/admin/src/pages/ItemsList.tsx +140 -0
- package/skills/xdev-ui-admin/templates/admin/src/pages/NotFound.tsx +17 -0
- package/skills/xdev-ui-admin/templates/admin/src/pages/Settings.tsx +37 -0
- package/skills/xdev-ui-admin/templates/admin/src/pages/SignIn.tsx +105 -0
- package/skills/xdev-ui-admin/templates/admin/src/router.ts +49 -0
- package/skills/xdev-ui-admin/templates/admin/src/shell/AccountMenu.tsx +36 -0
- package/skills/xdev-ui-admin/templates/admin/src/shell/Shell.tsx +53 -0
- package/skills/xdev-ui-admin/templates/admin/src/theme.ts +34 -0
- package/skills/xdev-ui-admin/templates/admin/tsconfig.json +16 -0
- package/skills/xdev-ui-admin/templates/admin/vite.config.ts +4 -0
- package/skills/xdev-ui-build-app/SKILL.md +85 -0
- package/skills/xdev-ui-build-app/references/app-shell.md +20 -0
- package/skills/xdev-ui-build-app/references/i18n.md +9 -0
- package/skills/xdev-ui-build-app/references/responsive-a11y.md +10 -0
- package/skills/xdev-ui-build-app/references/routing.md +14 -0
- package/skills/xdev-ui-build-app/references/setup.md +25 -0
- package/skills/xdev-ui-build-app/references/states.md +25 -0
- package/skills/xdev-ui-build-app/references/theme.md +11 -0
- package/skills/xdev-ui-build-app/templates/app/_gitignore +3 -0
- package/skills/xdev-ui-build-app/templates/app/_mcp.json +5 -0
- package/skills/xdev-ui-build-app/templates/app/_npmrc +2 -0
- package/skills/xdev-ui-build-app/templates/app/index.html +14 -0
- package/skills/xdev-ui-build-app/templates/app/package.json +24 -0
- package/skills/xdev-ui-build-app/templates/app/src/App.tsx +77 -0
- package/skills/xdev-ui-build-app/templates/app/src/app.css +3 -0
- package/skills/xdev-ui-build-app/templates/app/src/i18n/en.ts +35 -0
- package/skills/xdev-ui-build-app/templates/app/src/i18n/index.tsx +63 -0
- package/skills/xdev-ui-build-app/templates/app/src/i18n/vi.ts +35 -0
- package/skills/xdev-ui-build-app/templates/app/src/i18n/xdev-ui-labels.ts +19 -0
- package/skills/xdev-ui-build-app/templates/app/src/main.tsx +12 -0
- package/skills/xdev-ui-build-app/templates/app/src/notify.tsx +36 -0
- package/skills/xdev-ui-build-app/templates/app/src/pages/Home.tsx +22 -0
- package/skills/xdev-ui-build-app/templates/app/src/pages/NotFound.tsx +17 -0
- package/skills/xdev-ui-build-app/templates/app/src/pages/Settings.tsx +35 -0
- package/skills/xdev-ui-build-app/templates/app/src/router.ts +26 -0
- package/skills/xdev-ui-build-app/templates/app/src/theme.ts +34 -0
- package/skills/xdev-ui-build-app/templates/app/tsconfig.json +16 -0
- package/skills/xdev-ui-build-app/templates/app/vite.config.ts +4 -0
- package/skills/xdev-ui-design/SKILL.md +111 -0
- package/skills/xdev-ui-design/references/brand.md +58 -0
- package/skills/xdev-ui-design/references/checklist.md +55 -0
- package/skills/xdev-ui-design/references/owner-notes.md +54 -0
- package/skills/xdev-ui-design/references/porting.md +56 -0
- package/skills/xdev-ui-design/references/rules.md +135 -0
- package/skills/xdev-ui-design/references/screens.md +61 -0
- package/skills/xdev-ui-design/references/tokens.md +97 -0
- package/skills/xdev-ui-improve/SKILL.md +96 -0
- package/skills/xdev-ui-improve/references/plan-template.md +59 -0
- package/skills/xdev-ui-motion/SKILL.md +87 -0
- package/skills/xdev-ui-motion/references/recipes.md +117 -0
- package/skills/xdev-ui-review/SKILL.md +141 -0
- package/skills/xdev-ui-review/references/checklist.md +92 -0
- package/skills/xdev-ui-review/references/grep-recipes.md +37 -0
- package/skills/xdev-ui-review/references/pages/dashboard.md +21 -0
- package/skills/xdev-ui-review/references/pages/dialogs-forms.md +23 -0
- package/skills/xdev-ui-review/references/pages/list.md +22 -0
- package/skills/xdev-ui-review/references/pages/provider-grid.md +19 -0
- package/skills/xdev-ui-review/references/pages/settings.md +18 -0
- package/skills/xdev-ui-review/references/pages/sign-in.md +21 -0
- package/skills/xdev-ui-review/references/web-interface.md +73 -0
- package/skills/xdev-ui-review/scripts/audit.mjs +775 -0
- package/skills/xdev-ui-ux-standards/SKILL.md +88 -0
- package/skills/xdev-ui-ux-standards/references/heuristics-checklist.md +129 -0
- package/skills/xdev-ui-ux-standards/references/patterns.md +120 -0
- package/skills/xdev-ui-ux-standards/references/platforms.md +104 -0
- package/skills/xdev-ui-ux-standards/references/standards-map.md +144 -0
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en" data-theme="dark">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
6
|
+
<meta name="color-scheme" content="dark light" />
|
|
7
|
+
<meta name="robots" content="noindex, nofollow" />
|
|
8
|
+
<title>Admin console</title>
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<div id="root"></div>
|
|
12
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "my-admin",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc --noEmit && vite build",
|
|
9
|
+
"typecheck": "tsc --noEmit",
|
|
10
|
+
"audit": "node node_modules/@xdev-asia/ui/skills/xdev-ui-review/scripts/audit.mjs src --i18n src/i18n"
|
|
11
|
+
},
|
|
12
|
+
"dependencies": {
|
|
13
|
+
"@xdev-asia/ui": "latest",
|
|
14
|
+
"react": "^19.0.0",
|
|
15
|
+
"react-dom": "^19.0.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/react": "^19.0.0",
|
|
19
|
+
"@types/react-dom": "^19.0.0",
|
|
20
|
+
"@vitejs/plugin-react": "^6.0.0",
|
|
21
|
+
"typescript": "^7.0.0",
|
|
22
|
+
"vite": "^8.0.0"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState, type JSX } from "react";
|
|
2
|
+
import { signIn, signOut, useSession, type Session } from "./auth/session";
|
|
3
|
+
import { StoreContext } from "./data/context";
|
|
4
|
+
import { storeFromLocation } from "./data/store";
|
|
5
|
+
import { I18nProvider, readLocale, type Locale } from "./i18n";
|
|
6
|
+
import { NotifyContext, useToasts } from "./notify";
|
|
7
|
+
import { DashboardPage } from "./pages/Dashboard";
|
|
8
|
+
import { ItemDetailPage } from "./pages/ItemDetail";
|
|
9
|
+
import { ItemsPage } from "./pages/ItemsList";
|
|
10
|
+
import { NotFoundPage } from "./pages/NotFound";
|
|
11
|
+
import { SettingsPage } from "./pages/Settings";
|
|
12
|
+
import { SignInPage } from "./pages/SignIn";
|
|
13
|
+
import { href, navigate, useRoute } from "./router";
|
|
14
|
+
import { Shell } from "./shell/Shell";
|
|
15
|
+
import { useTheme } from "./theme";
|
|
16
|
+
|
|
17
|
+
const LOCALE_KEY = "admin-locale";
|
|
18
|
+
|
|
19
|
+
function Signed({ session, theme, onThemeChange }: { session: Session; theme: ReturnType<typeof useTheme>[0]; onThemeChange: ReturnType<typeof useTheme>[1] }): JSX.Element {
|
|
20
|
+
const route = useRoute();
|
|
21
|
+
const { notify, toasts } = useToasts();
|
|
22
|
+
return (
|
|
23
|
+
<NotifyContext.Provider value={notify}>
|
|
24
|
+
<Shell route={route} session={session} toasts={toasts} onSignOut={signOut}>
|
|
25
|
+
{route.name === "dashboard" ? <DashboardPage /> : route.name === "items" ? <ItemsPage session={session} /> : route.name === "item" ? <ItemDetailPage key={route.params.id} id={route.params.id ?? ""} session={session} /> : route.name === "settings" ? <SettingsPage theme={theme} onThemeChange={onThemeChange} /> : <NotFoundPage />}
|
|
26
|
+
</Shell>
|
|
27
|
+
</NotifyContext.Provider>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function App(): JSX.Element {
|
|
32
|
+
const [locale, setLocaleState] = useState<Locale>("en");
|
|
33
|
+
const [theme, setTheme] = useTheme();
|
|
34
|
+
const session = useSession();
|
|
35
|
+
const route = useRoute();
|
|
36
|
+
const store = useMemo(() => storeFromLocation(typeof window === "undefined" ? "" : window.location.search), []);
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
try {
|
|
39
|
+
setLocaleState(readLocale(window.localStorage.getItem(LOCALE_KEY)));
|
|
40
|
+
} catch {
|
|
41
|
+
/* keep the default */
|
|
42
|
+
}
|
|
43
|
+
}, []);
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
document.documentElement.lang = locale;
|
|
46
|
+
}, [locale]);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (!session && route.name !== "sign-in") navigate(href.signIn);
|
|
49
|
+
if (session && route.name === "sign-in") navigate(href.dashboard);
|
|
50
|
+
}, [session, route.name]);
|
|
51
|
+
const setLocale = useCallback((l: Locale) => {
|
|
52
|
+
setLocaleState(l);
|
|
53
|
+
try {
|
|
54
|
+
window.localStorage.setItem(LOCALE_KEY, l);
|
|
55
|
+
} catch {
|
|
56
|
+
/* private mode */
|
|
57
|
+
}
|
|
58
|
+
}, []);
|
|
59
|
+
return (
|
|
60
|
+
<I18nProvider locale={locale} onLocaleChange={setLocale}>
|
|
61
|
+
<StoreContext.Provider value={store}>
|
|
62
|
+
{session ? <Signed session={session} theme={theme} onThemeChange={setTheme} /> : <SignInPage onSignedIn={signIn} theme={theme} onThemeChange={setTheme} />}
|
|
63
|
+
</StoreContext.Provider>
|
|
64
|
+
</I18nProvider>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/* App-level layout only. Colours, sizes and type come from the library tokens. */
|
|
2
|
+
.app-title { margin: 0; font: var(--type-page-title); }
|
|
3
|
+
.app-muted { margin: 0; font: var(--type-status); color: var(--text-2); }
|
|
4
|
+
.app-form { display: flex; flex-direction: column; gap: var(--x-space-4); }
|
|
5
|
+
.app-signin { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: var(--x-space-4); box-sizing: border-box; background: var(--bg-0); color: var(--text-1); }
|
|
6
|
+
.app-signin-card { width: 100%; max-width: 44ch; display: flex; flex-direction: column; gap: var(--x-space-3); }
|
|
7
|
+
.app-signin-foot { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: var(--x-space-3); }
|
|
8
|
+
.app-top-search { width: min(28ch, 40vw); }
|
|
9
|
+
.app-account { display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 50%; background: transparent; cursor: pointer; }
|
|
10
|
+
.app-account:focus-visible { outline: 2px solid var(--x-color-signal); outline-offset: 2px; }
|
|
11
|
+
.app-account-who { margin: 0; padding: var(--x-space-2) var(--x-space-3); border-bottom: 1px solid var(--line); font: var(--type-status); color: var(--text-2); }
|
|
12
|
+
.app-stack { display: flex; flex-direction: column; gap: var(--x-space-4); }
|
|
13
|
+
.app-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 22ch), 1fr)); gap: var(--x-space-4); }
|
|
14
|
+
.app-grid-wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 36ch), 1fr)); }
|
|
15
|
+
.app-pane { display: grid; place-items: center; padding: var(--x-space-8) var(--x-space-4); }
|
|
16
|
+
.app-list { margin: 0; padding: 0; list-style: none; }
|
|
17
|
+
.app-filters { display: flex; flex-wrap: wrap; gap: var(--x-space-3); align-items: center; }
|
|
18
|
+
.app-filters-search { flex: 1 1 24ch; min-width: 0; }
|
|
19
|
+
.app-chips { display: flex; flex-wrap: wrap; gap: var(--x-space-2); }
|
|
20
|
+
.app-person { display: inline-flex; align-items: center; gap: var(--x-space-2); }
|
|
21
|
+
.app-link { color: var(--text-1); text-decoration: none; font-weight: 600; }
|
|
22
|
+
.app-link:hover { text-decoration: underline; }
|
|
23
|
+
.app-link:focus-visible { outline: 2px solid var(--x-color-signal); outline-offset: 2px; }
|
|
24
|
+
.app-labelled { display: flex; flex-direction: column; gap: var(--x-space-1); }
|
|
25
|
+
.app-label { font: var(--type-label); color: var(--text-1); }
|
|
26
|
+
.app-panel { margin-top: var(--x-space-4); }
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type RoleId = "admin" | "viewer";
|
|
2
|
+
export type Capability = "items.create" | "items.update";
|
|
3
|
+
|
|
4
|
+
/** What the console checks before it shows a control. The server must check again; this only shapes the UI. */
|
|
5
|
+
const GRANTS: Record<RoleId, Capability[]> = { admin: ["items.create", "items.update"], viewer: [] };
|
|
6
|
+
|
|
7
|
+
export const can = (role: RoleId, capability: Capability): boolean => GRANTS[role].includes(capability);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
import type { RoleId } from "./permissions";
|
|
3
|
+
|
|
4
|
+
export interface Session {
|
|
5
|
+
name: string;
|
|
6
|
+
email: string;
|
|
7
|
+
role: RoleId;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const ACCOUNTS: (Session & { password: string })[] = [
|
|
11
|
+
{ name: "Ada Lovelace", email: "admin@example.com", password: "admin-demo", role: "admin" },
|
|
12
|
+
{ name: "Grace Hopper", email: "viewer@example.com", password: "viewer-demo", role: "viewer" },
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
export type SignInResult = { ok: true; session: Session } | { ok: false };
|
|
16
|
+
|
|
17
|
+
/** Demo only: checks two hard-coded accounts. A real app calls its server. */
|
|
18
|
+
export function checkCredentials(email: string, password: string): SignInResult {
|
|
19
|
+
const a = ACCOUNTS.find((x) => x.email === email.trim().toLowerCase() && x.password === password);
|
|
20
|
+
return a ? { ok: true, session: { name: a.name, email: a.email, role: a.role } } : { ok: false };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let current: Session | null = null;
|
|
24
|
+
const listeners = new Set<() => void>();
|
|
25
|
+
const set = (s: Session | null): void => {
|
|
26
|
+
current = s;
|
|
27
|
+
listeners.forEach((l) => l());
|
|
28
|
+
};
|
|
29
|
+
export const signIn = (s: Session): void => set(s);
|
|
30
|
+
export const signOut = (): void => set(null);
|
|
31
|
+
|
|
32
|
+
/** The signed-in user, or null. In memory only: a reload signs out. */
|
|
33
|
+
export function useSession(): Session | null {
|
|
34
|
+
return useSyncExternalStore(
|
|
35
|
+
(cb) => {
|
|
36
|
+
listeners.add(cb);
|
|
37
|
+
return () => listeners.delete(cb);
|
|
38
|
+
},
|
|
39
|
+
() => current,
|
|
40
|
+
() => null,
|
|
41
|
+
);
|
|
42
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createContext, useContext } from "react";
|
|
2
|
+
import type { Store } from "./store";
|
|
3
|
+
|
|
4
|
+
export const StoreContext = createContext<Store | null>(null);
|
|
5
|
+
|
|
6
|
+
/** The data store; swap it for a client of your API. */
|
|
7
|
+
export function useStore(): Store {
|
|
8
|
+
const s = useContext(StoreContext);
|
|
9
|
+
if (!s) throw new Error("useStore needs <StoreContext.Provider>");
|
|
10
|
+
return s;
|
|
11
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
export type ItemStatus = "active" | "draft" | "archived";
|
|
2
|
+
export interface Item {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
owner: string;
|
|
6
|
+
status: ItemStatus;
|
|
7
|
+
/** ISO timestamp. */
|
|
8
|
+
updated: string;
|
|
9
|
+
}
|
|
10
|
+
export interface Summary {
|
|
11
|
+
total: number;
|
|
12
|
+
active: number;
|
|
13
|
+
archived: number;
|
|
14
|
+
recent: Item[];
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export class StoreError extends Error {
|
|
18
|
+
constructor(public code: "failed" | "not-found") {
|
|
19
|
+
super(code);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface Store {
|
|
24
|
+
listItems(): Promise<Item[]>;
|
|
25
|
+
getItem(id: string): Promise<Item>;
|
|
26
|
+
createItem(name: string, owner: string): Promise<Item>;
|
|
27
|
+
saveItem(id: string, patch: Partial<Pick<Item, "name" | "status">>): Promise<Item>;
|
|
28
|
+
summary(): Promise<Summary>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const NAMES = ["Alpha", "Bravo", "Cedar", "Delta", "Ember", "Fjord", "Garnet", "Harbor", "Iris", "Juniper"];
|
|
32
|
+
const OWNERS = ["Ada Lovelace", "Grace Hopper", "Linus Torvalds", "Margaret Hamilton"];
|
|
33
|
+
const STATUSES: ItemStatus[] = ["active", "draft", "archived", "active"];
|
|
34
|
+
const NOW = Date.UTC(2026, 10, 4, 9, 0, 0);
|
|
35
|
+
|
|
36
|
+
/** Fixed seed, so tests and screenshots do not change. */
|
|
37
|
+
export const seedItems = (): Item[] =>
|
|
38
|
+
Array.from({ length: 25 }, (_, i) => ({
|
|
39
|
+
id: `i${i + 1}`,
|
|
40
|
+
name: `${NAMES[i % NAMES.length]} ${Math.floor(i / NAMES.length) + 1}`,
|
|
41
|
+
owner: OWNERS[i % OWNERS.length]!,
|
|
42
|
+
status: STATUSES[i % STATUSES.length]!,
|
|
43
|
+
updated: new Date(NOW - i * 5 * 3_600_000).toISOString(),
|
|
44
|
+
}));
|
|
45
|
+
|
|
46
|
+
/** In-memory store; swap it for a client of your API. `latency` slows every call; `fail` makes every call reject. */
|
|
47
|
+
export function createStore(options: { latency?: number; fail?: boolean } = {}): Store {
|
|
48
|
+
let items = seedItems();
|
|
49
|
+
let next = items.length + 1;
|
|
50
|
+
const run = async <T,>(fn: () => T): Promise<T> => {
|
|
51
|
+
if (options.latency) await new Promise((r) => setTimeout(r, options.latency));
|
|
52
|
+
if (options.fail) throw new StoreError("failed");
|
|
53
|
+
return structuredClone(fn());
|
|
54
|
+
};
|
|
55
|
+
const find = (id: string): Item => {
|
|
56
|
+
const item = items.find((x) => x.id === id);
|
|
57
|
+
if (!item) throw new StoreError("not-found");
|
|
58
|
+
return item;
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
listItems: () => run(() => items),
|
|
62
|
+
getItem: (id) => run(() => find(id)),
|
|
63
|
+
createItem: (name, owner) =>
|
|
64
|
+
run(() => {
|
|
65
|
+
const item: Item = { id: `i${next++}`, name, owner, status: "draft", updated: new Date(NOW).toISOString() };
|
|
66
|
+
items = [item, ...items];
|
|
67
|
+
return item;
|
|
68
|
+
}),
|
|
69
|
+
saveItem: (id, patch) => run(() => Object.assign(find(id), patch, { updated: new Date(NOW).toISOString() })),
|
|
70
|
+
summary: () =>
|
|
71
|
+
run(() => ({
|
|
72
|
+
total: items.length,
|
|
73
|
+
active: items.filter((i) => i.status === "active").length,
|
|
74
|
+
archived: items.filter((i) => i.status === "archived").length,
|
|
75
|
+
recent: items.slice(0, 5),
|
|
76
|
+
})),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/** `?fail=1` in the URL makes every call fail; `?latency=400` slows them. */
|
|
81
|
+
export function storeFromLocation(search: string): Store {
|
|
82
|
+
const q = new URLSearchParams(search);
|
|
83
|
+
return createStore({ latency: Number(q.get("latency") ?? 250), fail: q.get("fail") === "1" });
|
|
84
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
/** What a page renders: one of three states. */
|
|
4
|
+
export type Load<T> = { status: "loading" } | { status: "error" } | { status: "ready"; data: T };
|
|
5
|
+
|
|
6
|
+
/** Runs `load` on mount and whenever `deps` change; `reload()` runs it again. */
|
|
7
|
+
export function useLoad<T>(load: () => Promise<T>, deps: unknown[]): { state: Load<T>; reload: () => void; set: (data: T) => void } {
|
|
8
|
+
const [state, setState] = useState<Load<T>>({ status: "loading" });
|
|
9
|
+
const [tick, setTick] = useState(0);
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
let live = true;
|
|
12
|
+
setState({ status: "loading" });
|
|
13
|
+
load().then(
|
|
14
|
+
(data) => live && setState({ status: "ready", data }),
|
|
15
|
+
() => live && setState({ status: "error" }),
|
|
16
|
+
);
|
|
17
|
+
return () => {
|
|
18
|
+
live = false;
|
|
19
|
+
};
|
|
20
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
21
|
+
}, [...deps, tick]);
|
|
22
|
+
const reload = useCallback(() => setTick((n) => n + 1), []);
|
|
23
|
+
const set = useCallback((data: T) => setState({ status: "ready", data }), []);
|
|
24
|
+
return { state, reload, set };
|
|
25
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// English strings. Keep one `key: "value",` per line; vi.ts must have the same keys.
|
|
2
|
+
export const en = {
|
|
3
|
+
app: {
|
|
4
|
+
name: "Admin console",
|
|
5
|
+
notFoundTitle: "Page not found",
|
|
6
|
+
notFoundHint: "The page you are looking for does not exist or was moved.",
|
|
7
|
+
goDashboard: "Go to dashboard",
|
|
8
|
+
retry: "Try again",
|
|
9
|
+
loadFailed: "Could not load this page",
|
|
10
|
+
loadFailedHint: "Check your connection and try again.",
|
|
11
|
+
},
|
|
12
|
+
nav: {
|
|
13
|
+
overview: "Overview",
|
|
14
|
+
manage: "Manage",
|
|
15
|
+
dashboard: "Dashboard",
|
|
16
|
+
items: "Items",
|
|
17
|
+
settings: "Settings",
|
|
18
|
+
},
|
|
19
|
+
account: {
|
|
20
|
+
menu: "Account menu",
|
|
21
|
+
signedInAs: "Signed in as {email}",
|
|
22
|
+
signOut: "Sign out",
|
|
23
|
+
},
|
|
24
|
+
signIn: {
|
|
25
|
+
title: "Sign in",
|
|
26
|
+
subtitle: "Use your work email to open the console.",
|
|
27
|
+
email: "Email",
|
|
28
|
+
password: "Password",
|
|
29
|
+
submit: "Sign in",
|
|
30
|
+
emailRequired: "Enter your email.",
|
|
31
|
+
emailInvalid: "Enter an email such as name@example.com.",
|
|
32
|
+
passwordRequired: "Enter your password.",
|
|
33
|
+
wrongCredentials: "Email or password is wrong",
|
|
34
|
+
wrongCredentialsHint: "Check both and try again.",
|
|
35
|
+
demo: "Demo: admin@example.com / admin-demo, viewer@example.com / viewer-demo",
|
|
36
|
+
language: "Language",
|
|
37
|
+
},
|
|
38
|
+
dashboard: {
|
|
39
|
+
title: "Dashboard",
|
|
40
|
+
description: "A summary of your items.",
|
|
41
|
+
total: "All items",
|
|
42
|
+
active: "Active",
|
|
43
|
+
archived: "Archived",
|
|
44
|
+
recent: "Recently updated",
|
|
45
|
+
recentEmpty: "Nothing has changed yet.",
|
|
46
|
+
viewItems: "View items",
|
|
47
|
+
},
|
|
48
|
+
items: {
|
|
49
|
+
title: "Items",
|
|
50
|
+
description: "Everything in the workspace.",
|
|
51
|
+
create: "Create item",
|
|
52
|
+
created: "Item created.",
|
|
53
|
+
table: "Items",
|
|
54
|
+
searchLabel: "Search items",
|
|
55
|
+
searchPlaceholder: "Search by name or owner",
|
|
56
|
+
noMatchTitle: "No items match \"{query}\"",
|
|
57
|
+
noMatchFilters: "No items match these filters",
|
|
58
|
+
noMatchHint: "Check the spelling or clear the filters.",
|
|
59
|
+
clearFilters: "Clear filters",
|
|
60
|
+
emptyTitle: "No items yet",
|
|
61
|
+
emptyHint: "Create the first item to see it here.",
|
|
62
|
+
filterStatus: "Status",
|
|
63
|
+
status: {
|
|
64
|
+
active: "Active",
|
|
65
|
+
draft: "Draft",
|
|
66
|
+
archived: "Archived",
|
|
67
|
+
},
|
|
68
|
+
columns: {
|
|
69
|
+
name: "Name",
|
|
70
|
+
owner: "Owner",
|
|
71
|
+
status: "Status",
|
|
72
|
+
updated: "Updated",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
item: {
|
|
76
|
+
details: "Details",
|
|
77
|
+
edit: "Edit item",
|
|
78
|
+
name: "Name",
|
|
79
|
+
nameRequired: "Enter a name.",
|
|
80
|
+
owner: "Owner",
|
|
81
|
+
status: "Status",
|
|
82
|
+
updated: "Updated",
|
|
83
|
+
save: "Save changes",
|
|
84
|
+
saved: "Item saved.",
|
|
85
|
+
},
|
|
86
|
+
settings: {
|
|
87
|
+
title: "Settings",
|
|
88
|
+
description: "Preferences for this console.",
|
|
89
|
+
theme: "Theme",
|
|
90
|
+
themeHint: "System follows your device.",
|
|
91
|
+
language: "Language",
|
|
92
|
+
languageHint: "Applies to the whole console.",
|
|
93
|
+
digest: "Weekly email digest",
|
|
94
|
+
digestHint: "A summary of what changed.",
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
export type Dict = typeof en;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createContext, useContext, useMemo, type JSX, type ReactNode } from "react";
|
|
2
|
+
import { en, type Dict } from "./en";
|
|
3
|
+
import { vi } from "./vi";
|
|
4
|
+
import { uiLabels } from "./xdev-ui-labels";
|
|
5
|
+
|
|
6
|
+
export type Locale = "en" | "vi";
|
|
7
|
+
export const LOCALES: readonly Locale[] = ["en", "vi"];
|
|
8
|
+
export const dictionaries: Record<Locale, Dict> = { en, vi };
|
|
9
|
+
|
|
10
|
+
type Join<K, P> = K extends string ? (P extends string ? `${K}.${P}` : never) : never;
|
|
11
|
+
type Paths<T> = { [K in keyof T & string]: T[K] extends string ? K : Join<K, Paths<T[K]>> }[keyof T & string];
|
|
12
|
+
/** Every dotted key of the dictionary, e.g. "users.status.active". */
|
|
13
|
+
export type MessageKey = Paths<Dict>;
|
|
14
|
+
|
|
15
|
+
export type Translate = (key: MessageKey, vars?: Record<string, string | number>) => string;
|
|
16
|
+
|
|
17
|
+
/** Pure lookup with {name} interpolation; an unknown key returns the key itself. */
|
|
18
|
+
export function translate(locale: Locale, key: string, vars?: Record<string, string | number>): string {
|
|
19
|
+
let node: unknown = dictionaries[locale];
|
|
20
|
+
for (const part of key.split(".")) node = (node as Record<string, unknown> | undefined)?.[part];
|
|
21
|
+
const text = typeof node === "string" ? node : key;
|
|
22
|
+
return vars ? text.replace(/\{(\w+)\}/g, (m, name: string) => (name in vars ? String(vars[name]) : m)) : text;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function readLocale(value: string | null | undefined): Locale {
|
|
26
|
+
return value === "vi" || value === "en" ? value : "en";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface I18n {
|
|
30
|
+
locale: Locale;
|
|
31
|
+
t: Translate;
|
|
32
|
+
/** Library labels for the active language. */
|
|
33
|
+
ui: (typeof uiLabels)["en"];
|
|
34
|
+
/** Format a number for the active language. */
|
|
35
|
+
num: (n: number) => string;
|
|
36
|
+
/** Format a date for the active language. */
|
|
37
|
+
date: (value: string | number | Date, withTime?: boolean) => string;
|
|
38
|
+
setLocale: (locale: Locale) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const Ctx = createContext<I18n | null>(null);
|
|
42
|
+
|
|
43
|
+
export function I18nProvider({ locale, onLocaleChange, children }: { locale: Locale; onLocaleChange?: (l: Locale) => void; children: ReactNode }): JSX.Element {
|
|
44
|
+
const value = useMemo<I18n>(
|
|
45
|
+
() => ({
|
|
46
|
+
locale,
|
|
47
|
+
t: (key, vars) => translate(locale, key, vars),
|
|
48
|
+
ui: uiLabels[locale],
|
|
49
|
+
num: (n) => new Intl.NumberFormat(locale).format(n),
|
|
50
|
+
date: (v, withTime = false) =>
|
|
51
|
+
new Intl.DateTimeFormat(locale, withTime ? { dateStyle: "medium", timeStyle: "short", timeZone: "UTC" } : { dateStyle: "medium", timeZone: "UTC" }).format(new Date(v)),
|
|
52
|
+
setLocale: (l) => onLocaleChange?.(l),
|
|
53
|
+
}),
|
|
54
|
+
[locale, onLocaleChange],
|
|
55
|
+
);
|
|
56
|
+
return <Ctx.Provider value={value}>{children}</Ctx.Provider>;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function useI18n(): I18n {
|
|
60
|
+
const v = useContext(Ctx);
|
|
61
|
+
if (!v) throw new Error("useI18n needs <I18nProvider>");
|
|
62
|
+
return v;
|
|
63
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Vietnamese strings. Same keys as en.ts.
|
|
2
|
+
import type { Dict } from "./en";
|
|
3
|
+
|
|
4
|
+
export const vi: Dict = {
|
|
5
|
+
app: {
|
|
6
|
+
name: "Bảng quản trị",
|
|
7
|
+
notFoundTitle: "Không tìm thấy trang",
|
|
8
|
+
notFoundHint: "Trang bạn cần không tồn tại hoặc đã được chuyển.",
|
|
9
|
+
goDashboard: "Về trang tổng quan",
|
|
10
|
+
retry: "Thử lại",
|
|
11
|
+
loadFailed: "Không thể tải trang này",
|
|
12
|
+
loadFailedHint: "Kiểm tra kết nối và thử lại.",
|
|
13
|
+
},
|
|
14
|
+
nav: {
|
|
15
|
+
overview: "Tổng quan",
|
|
16
|
+
manage: "Quản lý",
|
|
17
|
+
dashboard: "Tổng quan",
|
|
18
|
+
items: "Mục",
|
|
19
|
+
settings: "Cài đặt",
|
|
20
|
+
},
|
|
21
|
+
account: {
|
|
22
|
+
menu: "Menu tài khoản",
|
|
23
|
+
signedInAs: "Đăng nhập với {email}",
|
|
24
|
+
signOut: "Đăng xuất",
|
|
25
|
+
},
|
|
26
|
+
signIn: {
|
|
27
|
+
title: "Đăng nhập",
|
|
28
|
+
subtitle: "Dùng email công việc để vào bảng quản trị.",
|
|
29
|
+
email: "Email",
|
|
30
|
+
password: "Mật khẩu",
|
|
31
|
+
submit: "Đăng nhập",
|
|
32
|
+
emailRequired: "Nhập email của bạn.",
|
|
33
|
+
emailInvalid: "Nhập email dạng name@example.com.",
|
|
34
|
+
passwordRequired: "Nhập mật khẩu của bạn.",
|
|
35
|
+
wrongCredentials: "Email hoặc mật khẩu không đúng",
|
|
36
|
+
wrongCredentialsHint: "Kiểm tra cả hai và thử lại.",
|
|
37
|
+
demo: "Demo: admin@example.com / admin-demo, viewer@example.com / viewer-demo",
|
|
38
|
+
language: "Ngôn ngữ",
|
|
39
|
+
},
|
|
40
|
+
dashboard: {
|
|
41
|
+
title: "Tổng quan",
|
|
42
|
+
description: "Tóm tắt các mục của bạn.",
|
|
43
|
+
total: "Tất cả mục",
|
|
44
|
+
active: "Đang dùng",
|
|
45
|
+
archived: "Đã lưu trữ",
|
|
46
|
+
recent: "Mới cập nhật",
|
|
47
|
+
recentEmpty: "Chưa có thay đổi nào.",
|
|
48
|
+
viewItems: "Xem các mục",
|
|
49
|
+
},
|
|
50
|
+
items: {
|
|
51
|
+
title: "Mục",
|
|
52
|
+
description: "Mọi thứ trong không gian làm việc.",
|
|
53
|
+
create: "Tạo mục",
|
|
54
|
+
created: "Đã tạo mục.",
|
|
55
|
+
table: "Danh sách mục",
|
|
56
|
+
searchLabel: "Tìm mục",
|
|
57
|
+
searchPlaceholder: "Tìm theo tên hoặc người phụ trách",
|
|
58
|
+
noMatchTitle: "Không có mục nào khớp \"{query}\"",
|
|
59
|
+
noMatchFilters: "Không có mục nào khớp bộ lọc",
|
|
60
|
+
noMatchHint: "Kiểm tra chính tả hoặc xóa bộ lọc.",
|
|
61
|
+
clearFilters: "Xóa bộ lọc",
|
|
62
|
+
emptyTitle: "Chưa có mục nào",
|
|
63
|
+
emptyHint: "Tạo mục đầu tiên để thấy nó ở đây.",
|
|
64
|
+
filterStatus: "Trạng thái",
|
|
65
|
+
status: {
|
|
66
|
+
active: "Đang dùng",
|
|
67
|
+
draft: "Bản nháp",
|
|
68
|
+
archived: "Đã lưu trữ",
|
|
69
|
+
},
|
|
70
|
+
columns: {
|
|
71
|
+
name: "Tên",
|
|
72
|
+
owner: "Người phụ trách",
|
|
73
|
+
status: "Trạng thái",
|
|
74
|
+
updated: "Cập nhật",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
item: {
|
|
78
|
+
details: "Chi tiết",
|
|
79
|
+
edit: "Sửa mục",
|
|
80
|
+
name: "Tên",
|
|
81
|
+
nameRequired: "Nhập tên.",
|
|
82
|
+
owner: "Người phụ trách",
|
|
83
|
+
status: "Trạng thái",
|
|
84
|
+
updated: "Cập nhật",
|
|
85
|
+
save: "Lưu thay đổi",
|
|
86
|
+
saved: "Đã lưu mục.",
|
|
87
|
+
},
|
|
88
|
+
settings: {
|
|
89
|
+
title: "Cài đặt",
|
|
90
|
+
description: "Tùy chọn cho bảng quản trị này.",
|
|
91
|
+
theme: "Chủ đề",
|
|
92
|
+
themeHint: "Hệ thống theo thiết bị của bạn.",
|
|
93
|
+
language: "Ngôn ngữ",
|
|
94
|
+
languageHint: "Áp dụng cho cả bảng quản trị.",
|
|
95
|
+
digest: "Email tóm tắt hằng tuần",
|
|
96
|
+
digestHint: "Tóm tắt những gì đã thay đổi.",
|
|
97
|
+
},
|
|
98
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Labels for the library parts this app uses. The parts ship English defaults; pass these as `labels`.
|
|
2
|
+
export const uiLabels = {
|
|
3
|
+
en: {
|
|
4
|
+
appShell: { openNav: "Open navigation", closeNav: "Close navigation", skipToContent: "Skip to content", nav: "Navigation" },
|
|
5
|
+
toast: { dismiss: "Dismiss" },
|
|
6
|
+
themeSwitch: { group: "Theme", system: "System", dark: "Dark", light: "Light" },
|
|
7
|
+
dataTable: {
|
|
8
|
+
selectAll: "Select all rows",
|
|
9
|
+
selectRow: (name: string) => `Select ${name}`,
|
|
10
|
+
sortedAsc: "sorted ascending",
|
|
11
|
+
sortedDesc: "sorted descending",
|
|
12
|
+
loading: "Loading",
|
|
13
|
+
sortBy: "Sort by",
|
|
14
|
+
sortNone: "Default order",
|
|
15
|
+
sortOption: (column: string, dir: "asc" | "desc") => `${column}, ${dir === "asc" ? "ascending" : "descending"}`,
|
|
16
|
+
},
|
|
17
|
+
pagination: { nav: "Pagination", previous: "Previous page", next: "Next page", range: (from: number, to: number, total: number) => `${from}–${to} of ${total}`, pageSize: "Rows per page", page: (page: number) => `Page ${page}` },
|
|
18
|
+
statTile: { loading: "Loading" },
|
|
19
|
+
spinner: { loading: "Loading" },
|
|
20
|
+
field: { show: "Show password", hide: "Hide password" },
|
|
21
|
+
searchInput: { search: "Search", clear: "Clear search", count: (n: number) => `${n} results` },
|
|
22
|
+
breadcrumb: { breadcrumb: "Breadcrumb" },
|
|
23
|
+
navList: { nav: "Sections" },
|
|
24
|
+
},
|
|
25
|
+
vi: {
|
|
26
|
+
appShell: { openNav: "Mở điều hướng", closeNav: "Đóng điều hướng", skipToContent: "Chuyển đến nội dung", nav: "Điều hướng" },
|
|
27
|
+
toast: { dismiss: "Đóng" },
|
|
28
|
+
themeSwitch: { group: "Chủ đề", system: "Hệ thống", dark: "Tối", light: "Sáng" },
|
|
29
|
+
dataTable: {
|
|
30
|
+
selectAll: "Chọn tất cả các dòng",
|
|
31
|
+
selectRow: (name: string) => `Chọn ${name}`,
|
|
32
|
+
sortedAsc: "sắp xếp tăng dần",
|
|
33
|
+
sortedDesc: "sắp xếp giảm dần",
|
|
34
|
+
loading: "Đang tải",
|
|
35
|
+
sortBy: "Sắp xếp theo",
|
|
36
|
+
sortNone: "Thứ tự mặc định",
|
|
37
|
+
sortOption: (column: string, dir: "asc" | "desc") => `${column}, ${dir === "asc" ? "tăng dần" : "giảm dần"}`,
|
|
38
|
+
},
|
|
39
|
+
pagination: { nav: "Phân trang", previous: "Trang trước", next: "Trang sau", range: (from: number, to: number, total: number) => `${from}–${to} trên ${total}`, pageSize: "Số dòng mỗi trang", page: (page: number) => `Trang ${page}` },
|
|
40
|
+
statTile: { loading: "Đang tải" },
|
|
41
|
+
spinner: { loading: "Đang tải" },
|
|
42
|
+
field: { show: "Hiện mật khẩu", hide: "Ẩn mật khẩu" },
|
|
43
|
+
searchInput: { search: "Tìm kiếm", clear: "Xóa nội dung tìm", count: (n: number) => `${n} kết quả` },
|
|
44
|
+
breadcrumb: { breadcrumb: "Đường dẫn" },
|
|
45
|
+
navList: { nav: "Mục" },
|
|
46
|
+
},
|
|
47
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StrictMode } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import "@xdev-asia/ui/fonts.css";
|
|
4
|
+
import "@xdev-asia/ui/styles.css";
|
|
5
|
+
import "./app.css";
|
|
6
|
+
import { App } from "./App";
|
|
7
|
+
|
|
8
|
+
createRoot(document.getElementById("root")!).render(
|
|
9
|
+
<StrictMode>
|
|
10
|
+
<App />
|
|
11
|
+
</StrictMode>,
|
|
12
|
+
);
|