@xdev-asia/ui 0.0.0-stage → 4.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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 +308 -0
- package/dist/tokens.json +269 -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,775 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Rules audit for apps built on @xdev-asia/ui. Line based, no dependencies.
|
|
3
|
+
// node audit.mjs <src-dir> [--i18n <dir>] [--manifest <path>] [--contrast]
|
|
4
|
+
// Prints `file:line rule message` per finding; exit code 1 on any error. Also exports audit(dir, opts).
|
|
5
|
+
import { existsSync, readFileSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
6
|
+
import { dirname, extname, join, relative, resolve } from "node:path";
|
|
7
|
+
import { fileURLToPath } from "node:url";
|
|
8
|
+
|
|
9
|
+
const SKIP_DIRS = new Set(["node_modules", "dist", "dist-examples", ".git", "generated", "fixtures"]);
|
|
10
|
+
const EXTS = new Set([".css", ".ts", ".tsx"]);
|
|
11
|
+
|
|
12
|
+
function walk(dir) {
|
|
13
|
+
const out = [];
|
|
14
|
+
for (const name of readdirSync(dir)) {
|
|
15
|
+
const p = join(dir, name);
|
|
16
|
+
const st = statSync(p);
|
|
17
|
+
if (st.isDirectory()) {
|
|
18
|
+
if (!SKIP_DIRS.has(name)) out.push(...walk(p));
|
|
19
|
+
} else if (EXTS.has(extname(name)) && !/\.(test|stories)\.[tj]sx?$/.test(name) && !name.endsWith(".d.ts")) out.push(p);
|
|
20
|
+
}
|
|
21
|
+
return out.sort();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const HEX = /#(?:[0-9a-fA-F]{8}|[0-9a-fA-F]{6}|[0-9a-fA-F]{3,4})\b/;
|
|
25
|
+
const COLOUR_FN = /\b(?:rgba?|hsla?|hwb|lab|lch|oklab|oklch)\(/;
|
|
26
|
+
const PX = /(?<![\w.#-])(\d+(?:\.\d+)?)px\b/g;
|
|
27
|
+
// Copyright, registered and trademark signs are pictographic in Unicode but are not emoji.
|
|
28
|
+
const EMOJI = /(?![©®™])\p{Extended_Pictographic}/u;
|
|
29
|
+
const TITLE_CASE = /\b(?:[A-Z][a-z]+\s+){2,}[A-Z][a-z]+\b/;
|
|
30
|
+
|
|
31
|
+
const isComment = (line) => /^\s*(\/\/|\/\*|\*)/.test(line);
|
|
32
|
+
const stripCssComments = (line) => line.replace(/\/\*.*?\*\//g, "");
|
|
33
|
+
|
|
34
|
+
/** Opening tags of `<Name ...>` in a JSX source, balanced over braces and quotes. */
|
|
35
|
+
function openingTags(src, name) {
|
|
36
|
+
const out = [];
|
|
37
|
+
const re = new RegExp(`<${name}(?=[\\s/>])`, "g");
|
|
38
|
+
let m;
|
|
39
|
+
while ((m = re.exec(src))) {
|
|
40
|
+
// `useState<Dialog | null>` is a type argument, not a tag: JSX never follows a name character.
|
|
41
|
+
if (/[\w$.]/.test(src[m.index - 1] ?? "")) continue;
|
|
42
|
+
let i = m.index + m[0].length;
|
|
43
|
+
let depth = 0;
|
|
44
|
+
let quote = "";
|
|
45
|
+
for (; i < src.length; i++) {
|
|
46
|
+
const c = src[i];
|
|
47
|
+
if (quote) {
|
|
48
|
+
if (c === quote && src[i - 1] !== "\\") quote = "";
|
|
49
|
+
} else if (c === '"' || c === "'" || c === "`") quote = c;
|
|
50
|
+
else if (c === "{") depth++;
|
|
51
|
+
else if (c === "}") depth--;
|
|
52
|
+
else if (c === ">" && depth === 0) break;
|
|
53
|
+
}
|
|
54
|
+
out.push({ text: src.slice(m.index, i + 1), line: src.slice(0, m.index).split("\n").length, end: i + 1 });
|
|
55
|
+
}
|
|
56
|
+
return out;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Top-level props of one opening tag: name → raw value (`"x"`, `{expr}`, or `true` for a bare prop).
|
|
61
|
+
* Props inside nested JSX in a value are not counted. `spread` is true when the tag spreads `{...x}`.
|
|
62
|
+
*/
|
|
63
|
+
function propsOf(tag) {
|
|
64
|
+
const props = new Map();
|
|
65
|
+
let spread = false;
|
|
66
|
+
const body = tag.replace(/^<[\w.]+/, "").replace(/\/?>$/, "");
|
|
67
|
+
let i = 0;
|
|
68
|
+
while (i < body.length) {
|
|
69
|
+
const c = body[i];
|
|
70
|
+
if (/\s/.test(c)) {
|
|
71
|
+
i++;
|
|
72
|
+
continue;
|
|
73
|
+
}
|
|
74
|
+
if (c === "{") {
|
|
75
|
+
const end = closeOf(body, i);
|
|
76
|
+
if (/^\{\s*\.\.\./.test(body.slice(i, end))) spread = true;
|
|
77
|
+
i = end;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
const m = /^[\w:-]+/.exec(body.slice(i));
|
|
81
|
+
if (!m) {
|
|
82
|
+
i++;
|
|
83
|
+
continue;
|
|
84
|
+
}
|
|
85
|
+
i += m[0].length;
|
|
86
|
+
if (body[i] !== "=") {
|
|
87
|
+
props.set(m[0], true);
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
i++;
|
|
91
|
+
const q = body[i];
|
|
92
|
+
const end = q === "{" ? closeOf(body, i) : q === '"' || q === "'" ? body.indexOf(q, i + 1) + 1 : i + 1;
|
|
93
|
+
props.set(m[0], body.slice(i, end));
|
|
94
|
+
i = end;
|
|
95
|
+
}
|
|
96
|
+
return { props, spread };
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/** Index just past the brace that closes the one at `start`, skipping quoted strings. */
|
|
100
|
+
function closeOf(src, start) {
|
|
101
|
+
let depth = 0;
|
|
102
|
+
let quote = "";
|
|
103
|
+
for (let i = start; i < src.length; i++) {
|
|
104
|
+
const c = src[i];
|
|
105
|
+
if (quote) {
|
|
106
|
+
if (c === quote && src[i - 1] !== "\\") quote = "";
|
|
107
|
+
} else if (c === '"' || c === "'" || c === "`") quote = c;
|
|
108
|
+
else if (c === "{") depth++;
|
|
109
|
+
else if (c === "}" && --depth === 0) return i + 1;
|
|
110
|
+
}
|
|
111
|
+
return src.length;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** A prop that is set and not `{false}`. */
|
|
115
|
+
const isOn = (props, name) => props.has(name) && !/^\{\s*false\s*\}$/.test(String(props.get(name)));
|
|
116
|
+
|
|
117
|
+
/** Flat `a.b.c` keys of a dictionary file with `key: value` lines and nested `{ }`; empty-string values flagged. */
|
|
118
|
+
function dictKeys(text) {
|
|
119
|
+
const keys = new Map();
|
|
120
|
+
const stack = [];
|
|
121
|
+
text.split("\n").forEach((line, i) => {
|
|
122
|
+
const t = line.trim();
|
|
123
|
+
const m = /^"?([A-Za-z0-9_.-]+)"?\s*:\s*(.*?),?$/.exec(t);
|
|
124
|
+
if (m && !t.startsWith("//")) {
|
|
125
|
+
const rest = m[2];
|
|
126
|
+
if (rest === "{") return void stack.push(m[1]);
|
|
127
|
+
keys.set([...stack, m[1]].join("."), { line: i + 1, empty: /^(""|''|``)$/.test(rest), value: rest });
|
|
128
|
+
} else if (/^\}/.test(t) && stack.length) stack.pop();
|
|
129
|
+
});
|
|
130
|
+
return keys;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const strValue = (raw) => /^(["'`])(.*)\1$/.exec(raw)?.[2];
|
|
134
|
+
|
|
135
|
+
/** CSS rules with selector, enclosing at-rules and line-numbered declarations. Comments blanked, `&` nesting resolved. */
|
|
136
|
+
function cssRules(text) {
|
|
137
|
+
const src = text.replace(/\/\*[\s\S]*?\*\//g, (c) => c.replace(/[^\n]/g, " "));
|
|
138
|
+
const rules = [];
|
|
139
|
+
const stack = [];
|
|
140
|
+
let buf = "";
|
|
141
|
+
let started = false;
|
|
142
|
+
let line = 1;
|
|
143
|
+
let bufLine = 1;
|
|
144
|
+
let quote = "";
|
|
145
|
+
let paren = 0;
|
|
146
|
+
const top = () => stack[stack.length - 1];
|
|
147
|
+
const flush = () => {
|
|
148
|
+
const t = top();
|
|
149
|
+
const m = /^([-\w]+)\s*:\s*([\s\S]*)$/.exec(buf.trim());
|
|
150
|
+
if (t && t.rule && m) t.rule.decls.push({ prop: m[1].toLowerCase(), value: m[2].trim(), line: bufLine });
|
|
151
|
+
buf = "";
|
|
152
|
+
started = false;
|
|
153
|
+
};
|
|
154
|
+
for (let i = 0; i < src.length; i++) {
|
|
155
|
+
const c = src[i];
|
|
156
|
+
if (quote) {
|
|
157
|
+
if (c === quote && src[i - 1] !== "\\") quote = "";
|
|
158
|
+
} else if (c === '"' || c === "'") quote = c;
|
|
159
|
+
else if (c === "(") paren++;
|
|
160
|
+
else if (c === ")") paren = Math.max(0, paren - 1);
|
|
161
|
+
else if (!paren && c === "{") {
|
|
162
|
+
const prelude = buf.trim().replace(/\s+/g, " ");
|
|
163
|
+
const parent = [...stack].reverse().find((s) => s.rule);
|
|
164
|
+
if (prelude.startsWith("@")) stack.push({ at: prelude, rule: null });
|
|
165
|
+
else {
|
|
166
|
+
const selector = parent ? nestSelector(parent.rule.selector, prelude) : prelude;
|
|
167
|
+
const rule = { selector, at: stack.filter((s) => s.at).map((s) => s.at), line: bufLine, decls: [] };
|
|
168
|
+
rules.push(rule);
|
|
169
|
+
stack.push({ rule });
|
|
170
|
+
}
|
|
171
|
+
buf = "";
|
|
172
|
+
started = false;
|
|
173
|
+
continue;
|
|
174
|
+
} else if (!paren && (c === ";" || c === "}")) {
|
|
175
|
+
flush();
|
|
176
|
+
if (c === "}") stack.pop();
|
|
177
|
+
continue;
|
|
178
|
+
}
|
|
179
|
+
if (!started && !/\s/.test(c)) {
|
|
180
|
+
started = true;
|
|
181
|
+
bufLine = line;
|
|
182
|
+
}
|
|
183
|
+
if (started) buf += c;
|
|
184
|
+
if (c === "\n") line++;
|
|
185
|
+
}
|
|
186
|
+
return rules;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Split a selector list on top-level commas. */
|
|
190
|
+
function splitList(sel) {
|
|
191
|
+
const out = [];
|
|
192
|
+
let depth = 0;
|
|
193
|
+
let cur = "";
|
|
194
|
+
for (const c of sel) {
|
|
195
|
+
if (c === "(" || c === "[") depth++;
|
|
196
|
+
else if (c === ")" || c === "]") depth--;
|
|
197
|
+
if (c === "," && depth === 0) {
|
|
198
|
+
out.push(cur.trim());
|
|
199
|
+
cur = "";
|
|
200
|
+
} else cur += c;
|
|
201
|
+
}
|
|
202
|
+
if (cur.trim()) out.push(cur.trim());
|
|
203
|
+
return out;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function nestSelector(parent, child) {
|
|
207
|
+
const ps = splitList(parent);
|
|
208
|
+
return splitList(child)
|
|
209
|
+
.flatMap((c) => ps.map((p) => (c.includes("&") ? c.replace(/&/g, p) : `${p} ${c}`)))
|
|
210
|
+
.join(", ");
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** The subject (last compound) of a complex selector, with :not()/:is()/:where()/:has() arguments removed. */
|
|
214
|
+
function subject(sel) {
|
|
215
|
+
let depth = 0;
|
|
216
|
+
let cut = 0;
|
|
217
|
+
for (let i = 0; i < sel.length; i++) {
|
|
218
|
+
const c = sel[i];
|
|
219
|
+
if (c === "(" || c === "[") depth++;
|
|
220
|
+
else if (c === ")" || c === "]") depth--;
|
|
221
|
+
else if (depth === 0 && /[\s>+~]/.test(c)) cut = i + 1;
|
|
222
|
+
}
|
|
223
|
+
return sel.slice(cut).replace(/:(?:not|is|where|has)\((?:[^()]|\([^()]*\))*\)/g, "");
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** A single px or rem length (or a var() of a length token) in CSS px; null when it is anything else. */
|
|
227
|
+
function pxOf(v, sizes) {
|
|
228
|
+
const t = v.replace(/\s*!important$/, "").trim();
|
|
229
|
+
const m = /^(\d*\.?\d+)(px|rem)$/.exec(t);
|
|
230
|
+
if (m) return Number(m[1]) * (m[2] === "rem" ? 16 : 1);
|
|
231
|
+
const tok = /^var\(\s*--([a-z0-9-]+)\s*\)$/.exec(t);
|
|
232
|
+
return tok && sizes.has(tok[1]) ? pxOf(sizes.get(tok[1]), new Map()) : null;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
const INTERACTIVE =
|
|
236
|
+
/(?:^|[^-\w])button(?![-\w])|\[role=["']?(?:button|tab|menuitem|menuitemcheckbox|menuitemradio|option|checkbox|radio|switch|treeitem)["']?\]|(?:^|[^-\w])select(?![-\w])|input\[type=["']?(?:checkbox|radio)["']?\]|\.(?:[\w-]*-)?(?:btn|button)(?:-(?:primary|secondary|ghost|danger|icon|close|sm|xs|mini|small|tiny))*(?![-\w])/;
|
|
237
|
+
const SIZE_PROPS = new Set(["width", "height", "min-width", "min-height", "inline-size", "block-size", "min-inline-size", "min-block-size"]);
|
|
238
|
+
const MOTION = /(?:^|[\s;{])(?:transform|translate|rotate|scale|top|left|right|bottom|inset[\w-]*|margin[\w-]*|offset[\w-]*|background-position)\s*:/;
|
|
239
|
+
const REDUCED = /prefers-reduced-motion\s*(?::\s*reduce\s*)?\)/;
|
|
240
|
+
const GLOBAL_KEYWORDS = new Set(["none", "inherit", "initial", "unset", "revert", "revert-layer"]);
|
|
241
|
+
// Properties whose change runs layout on every frame of a transition or animation (fixing-motion-performance).
|
|
242
|
+
const LAYOUT_PROP = /^(?:width|height|min-width|min-height|max-width|max-height|inline-size|block-size|min-inline-size|min-block-size|max-inline-size|max-block-size|top|left|right|bottom|inset(?:-[\w-]+)?|margin(?:-[\w-]+)?|padding(?:-[\w-]+)?|flex-basis|grid-template-(?:columns|rows))$/;
|
|
243
|
+
const LAYOUT_FRAME = /(?:^|[\s;{])(?:width|height|top|left|right|bottom|margin(?:-[\w-]+)?|padding(?:-[\w-]+)?)\s*:/;
|
|
244
|
+
const TIMING = /^(?:-?\d*\.?\d+m?s|ease(?:-in|-out|-in-out)?|linear|step-start|step-end|allow-discrete|normal|(?:cubic-bezier|steps|linear|var)\(.*\))$/;
|
|
245
|
+
/** Property names a `transition` or `transition-property` value animates; a shorthand item with no property means `all`. */
|
|
246
|
+
function transitioned(prop, value) {
|
|
247
|
+
return splitList(value).map((item) => {
|
|
248
|
+
if (prop === "transition-property") return item.trim();
|
|
249
|
+
const words = item.trim().split(/\s+(?![^(]*\))/);
|
|
250
|
+
return words.find((w) => !TIMING.test(w)) ?? "all";
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/** WCAG 2.2 relative luminance of an sRGB colour [r, g, b] in 0..255. */
|
|
255
|
+
export function luminance([r, g, b]) {
|
|
256
|
+
const lin = (c) => {
|
|
257
|
+
const s = c / 255;
|
|
258
|
+
return s <= 0.04045 ? s / 12.92 : ((s + 0.055) / 1.055) ** 2.4;
|
|
259
|
+
};
|
|
260
|
+
return 0.2126 * lin(r) + 0.7152 * lin(g) + 0.0722 * lin(b);
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/** Parse #rgb, #rgba, #rrggbb, #rrggbbaa, rgb() or rgba() into [r, g, b, a]; null otherwise. */
|
|
264
|
+
export function parseColour(v) {
|
|
265
|
+
const s = String(v).trim();
|
|
266
|
+
let m = /^#([0-9a-f]{3,8})$/i.exec(s);
|
|
267
|
+
if (m && m[1].length !== 5 && m[1].length !== 7) {
|
|
268
|
+
let h = m[1];
|
|
269
|
+
if (h.length <= 4) h = [...h].map((c) => c + c).join("");
|
|
270
|
+
const n = (i) => parseInt(h.slice(i, i + 2), 16);
|
|
271
|
+
return [n(0), n(2), n(4), h.length === 8 ? n(6) / 255 : 1];
|
|
272
|
+
}
|
|
273
|
+
m = /^rgba?\(\s*([\d.]+)[\s,]+([\d.]+)[\s,]+([\d.]+)(?:[\s,/]+([\d.]+%?))?\s*\)$/i.exec(s);
|
|
274
|
+
if (!m) return null;
|
|
275
|
+
const a = m[4] === undefined ? 1 : m[4].endsWith("%") ? Number(m[4].slice(0, -1)) / 100 : Number(m[4]);
|
|
276
|
+
return [Number(m[1]), Number(m[2]), Number(m[3]), a];
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** Contrast ratio of fg on bg. A translucent bg is composited over `base`, then a translucent fg over that. */
|
|
280
|
+
export function contrastRatio(fg, bg, base = [255, 255, 255, 1]) {
|
|
281
|
+
const over = (t, u) => [0, 1, 2].map((i) => t[i] * t[3] + u[i] * (1 - t[3])).concat(1);
|
|
282
|
+
const b = bg[3] < 1 ? over(bg, base) : bg;
|
|
283
|
+
const f = fg[3] < 1 ? over(fg, b) : fg;
|
|
284
|
+
const [l1, l2] = [luminance(f), luminance(b)].sort((x, y) => y - x);
|
|
285
|
+
return (l1 + 0.05) / (l2 + 0.05);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
// Token pairs the design system documents as used together (token usage notes). kind text needs 4.5:1 (SC 1.4.3),
|
|
289
|
+
// kind ui needs 3:1 (SC 1.4.11). level warn: decorative hairlines (a failure only
|
|
290
|
+
// when the hairline is the only thing that identifies a control).
|
|
291
|
+
const TEXT_GROUNDS = ["bg-0", "bg-1", "bg-2", "bg-3", "side-tint", "term"];
|
|
292
|
+
export const CONTRAST_PAIRS = [
|
|
293
|
+
...["text-1", "text-2", "text-3"].flatMap((fg) => TEXT_GROUNDS.map((bg) => ({ fg, bg, kind: "text" }))),
|
|
294
|
+
...["signal", "warn", "violet", "ok", "danger", "orange"].flatMap((fg) => [
|
|
295
|
+
...["bg-0", "bg-1", "bg-2"].map((bg) => ({ fg, bg, kind: "text" })),
|
|
296
|
+
{ fg, bg: `${fg}-bg`, base: "bg-1", kind: "text" },
|
|
297
|
+
]),
|
|
298
|
+
...["x-color-bg", "x-color-panel", "x-color-surface", "x-color-surface-2"].map((bg) => ({ fg: "x-color-ink", bg, kind: "text" })),
|
|
299
|
+
...["x-color-bg", "x-color-panel", "x-color-surface"].map((bg) => ({ fg: "x-color-muted", bg, kind: "text" })),
|
|
300
|
+
{ fg: "x-color-on-accent", bg: "x-color-accent", kind: "text" },
|
|
301
|
+
...["x-color-danger", "x-color-ok", "x-color-warn", "x-color-signal"].flatMap((fg) => [
|
|
302
|
+
...["x-color-bg", "x-color-panel"].map((bg) => ({ fg, bg, kind: "text" })),
|
|
303
|
+
{ fg, bg: `${fg}-soft`, base: "x-color-panel", kind: "text" },
|
|
304
|
+
]),
|
|
305
|
+
...["x-color-bg", "x-color-panel", "x-color-surface", "x-color-surface-2", "bg-0", "bg-1", "bg-2", "bg-3", "term"].map((bg) => ({ fg: "x-color-focus", bg, kind: "ui" })),
|
|
306
|
+
...["x-color-bg", "x-color-panel", "x-color-surface"].map((bg) => ({ fg: "x-color-accent", bg, kind: "ui" })),
|
|
307
|
+
...["bg-1", "bg-2"].map((bg) => ({ fg: "accent", bg, kind: "ui" })),
|
|
308
|
+
...["bg-0", "bg-1", "bg-2"].map((bg) => ({ fg: "line", bg, kind: "ui", level: "warn" })),
|
|
309
|
+
...TEXT_GROUNDS.map((bg) => ({ fg: "line-strong", bg, kind: "ui" })),
|
|
310
|
+
...["x-color-bg", "x-color-panel", "x-color-surface", "x-color-surface-2"].map((bg) => ({ fg: "x-color-line-strong", bg, kind: "ui" })),
|
|
311
|
+
...["x-color-bg", "x-color-panel", "x-color-surface"].map((bg) => ({ fg: "x-color-line", bg, kind: "ui", level: "warn" })),
|
|
312
|
+
];
|
|
313
|
+
|
|
314
|
+
/** Every documented pair in dark and light with its ratio. Pairs whose tokens are missing are skipped. */
|
|
315
|
+
export function contrastReport(manifestTokens) {
|
|
316
|
+
const byName = new Map(manifestTokens.map((t) => [t.name, t.value]));
|
|
317
|
+
const colour = (name, theme, hops = 0) => {
|
|
318
|
+
let v = byName.get(name);
|
|
319
|
+
if (v && typeof v === "object") v = v[theme];
|
|
320
|
+
const alias = typeof v === "string" && /^\{([a-z0-9-]+)\}$/.exec(v);
|
|
321
|
+
if (alias) return hops < 5 ? colour(alias[1], theme, hops + 1) : null;
|
|
322
|
+
return v === undefined ? null : parseColour(v);
|
|
323
|
+
};
|
|
324
|
+
const out = [];
|
|
325
|
+
for (const theme of ["dark", "light"]) {
|
|
326
|
+
for (const p of CONTRAST_PAIRS) {
|
|
327
|
+
const fg = colour(p.fg, theme);
|
|
328
|
+
const bg = colour(p.bg, theme);
|
|
329
|
+
const base = colour(p.base ?? "bg-1", theme);
|
|
330
|
+
if (!fg || !bg || !base) continue;
|
|
331
|
+
const ratio = contrastRatio(fg, bg, base);
|
|
332
|
+
const need = p.kind === "text" ? 4.5 : 3;
|
|
333
|
+
out.push({ fg: p.fg, bg: p.bg, kind: p.kind, theme, ratio, need, pass: ratio >= need, level: p.level ?? "error" });
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
return out;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// Where ai-manifest.json can be: the installed package of the scanned project (walking up from the
|
|
340
|
+
// scanned dir and the cwd), then the package this script ships in (skills/<name>/scripts -> dist or generated).
|
|
341
|
+
function findManifest(root) {
|
|
342
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
343
|
+
const found = [];
|
|
344
|
+
for (const start of [root, process.cwd()]) {
|
|
345
|
+
for (let dir = start; ; dir = dirname(dir)) {
|
|
346
|
+
found.push(join(dir, "node_modules/@xdev-asia/ui/dist/ai-manifest.json"));
|
|
347
|
+
if (dirname(dir) === dir) break;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
found.push(resolve(here, "../../../dist/ai-manifest.json"), resolve(here, "../../../generated/ai-manifest.json"));
|
|
351
|
+
return found.find((p) => existsSync(p)) ?? found[0];
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
export function audit(dir, opts = {}) {
|
|
355
|
+
const root = resolve(dir);
|
|
356
|
+
const findings = [];
|
|
357
|
+
const add = (file, line, rule, level, message) => findings.push({ file: relative(root, file) || file, line, rule, level, message });
|
|
358
|
+
const notes = [];
|
|
359
|
+
|
|
360
|
+
let tokens = null;
|
|
361
|
+
let manifestTokens = [];
|
|
362
|
+
// Library components whose props take `labels` (their English defaults need the app's words in other languages).
|
|
363
|
+
let labelled = null;
|
|
364
|
+
const manifestPath = opts.manifest ? resolve(opts.manifest) : findManifest(root);
|
|
365
|
+
if (existsSync(manifestPath)) {
|
|
366
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf8"));
|
|
367
|
+
manifestTokens = manifest.tokens;
|
|
368
|
+
tokens = new Set(manifestTokens.map((t) => t.name));
|
|
369
|
+
labelled = new Set((manifest.components ?? []).filter((c) => /\blabels\?\s*:/.test(c.types ?? "")).map((c) => c.name));
|
|
370
|
+
} else notes.push(`unknown-token skipped: no manifest at ${manifestPath} (pass --manifest)`);
|
|
371
|
+
if (opts.i18n && !labelled) notes.push("i18n-labels skipped: no manifest (pass --manifest)");
|
|
372
|
+
const sizes = new Map(manifestTokens.filter((t) => typeof t.value === "string" && /^\d*\.?\d+(px|rem)$/.test(t.value)).map((t) => [t.name, t.value]));
|
|
373
|
+
|
|
374
|
+
const files = walk(root);
|
|
375
|
+
const sources = files.map((file) => ({ file, text: readFileSync(file, "utf8").replace(/\r\n/g, "\n") }));
|
|
376
|
+
const local = new Set();
|
|
377
|
+
for (const { text } of sources) for (const m of text.matchAll(/(--[a-z0-9-]+)\s*:/gi)) local.add(m[1].slice(2));
|
|
378
|
+
for (const { text } of sources) for (const m of text.matchAll(/["'`](--[a-z0-9-]+)["'`]/g)) local.add(m[1].slice(2));
|
|
379
|
+
|
|
380
|
+
// CSS pass inputs shared across files: which @keyframes move things, and whether a universal reduced-motion guard exists.
|
|
381
|
+
const parsed = new Map(sources.filter((s) => s.file.endsWith(".css")).map((s) => [s.file, cssRules(s.text)]));
|
|
382
|
+
const moving = new Map();
|
|
383
|
+
const layoutFrames = new Set();
|
|
384
|
+
for (const { file, text } of sources) {
|
|
385
|
+
if (!parsed.has(file)) continue;
|
|
386
|
+
for (const m of text.matchAll(/@keyframes\s+([-\w]+)\s*\{/g)) {
|
|
387
|
+
let depth = 1;
|
|
388
|
+
let i = m.index + m[0].length;
|
|
389
|
+
for (; i < text.length && depth; i++) depth += text[i] === "{" ? 1 : text[i] === "}" ? -1 : 0;
|
|
390
|
+
const frames = text.slice(m.index + m[0].length, i);
|
|
391
|
+
moving.set(m[1], (moving.get(m[1]) ?? false) || MOTION.test(frames));
|
|
392
|
+
if (LAYOUT_FRAME.test(frames)) layoutFrames.add(m[1]);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
const universalGuard = [...parsed.values()].some((rules) =>
|
|
396
|
+
rules.some((r) => r.at.some((a) => REDUCED.test(a)) && splitList(r.selector).some((s) => /^\*|[\s>]\*/.test(s)) && r.decls.some((d) => /^(animation|animation-duration|animation-name)$/.test(d.prop))),
|
|
397
|
+
);
|
|
398
|
+
|
|
399
|
+
// Classes the scanned TSX puts on a <button>, a checkbox or radio <input>, or an element with a widget role.
|
|
400
|
+
const controlClasses = new Set();
|
|
401
|
+
for (const { file, text } of sources) {
|
|
402
|
+
if (!file.endsWith(".tsx")) continue;
|
|
403
|
+
const tags = [...openingTags(text, "button"), ...openingTags(text, "input").filter((t) => /\btype=["'](checkbox|radio)["']/.test(t.text))];
|
|
404
|
+
for (const m of text.matchAll(/<[a-z]+\b[^<>]*?\brole=["'](?:button|tab|menuitem|menuitemcheckbox|menuitemradio|option|checkbox|radio|switch|treeitem)["']/g)) {
|
|
405
|
+
tags.push(...openingTags(text.slice(m.index), m[0].slice(1).split(/[\s/>]/)[0]).slice(0, 1));
|
|
406
|
+
}
|
|
407
|
+
for (const t of tags) {
|
|
408
|
+
const cls = /\bclassName=(?:"([^"]*)"|\{\s*"([^"]*)"\s*\}|\{\s*`([^`]*)`\s*\})/.exec(t.text);
|
|
409
|
+
const raw = cls ? (cls[1] ?? cls[2] ?? cls[3]).replace(/\$\{[^}]*\}/g, " ") : "";
|
|
410
|
+
for (const c of raw.split(/\s+/)) if (/^[a-z][\w-]*$/i.test(c)) controlClasses.add(c);
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
const isControl = (subj) => INTERACTIVE.test(subj) || [...subj.matchAll(/\.([\w-]+)/g)].some((m) => controlClasses.has(m[1]));
|
|
414
|
+
|
|
415
|
+
const focusBase = (s) => s.replace(/:focus(?:-visible)?(?![-\w])/g, "").replace(/\s+/g, " ").trim();
|
|
416
|
+
// How a rule draws focus: "outline" survives forced colors; "paint" (box-shadow, border colour) does not.
|
|
417
|
+
const ring = (r) => {
|
|
418
|
+
if (r.decls.some((d) => /^outline(-style|-width|-color)?$/.test(d.prop) && !/^(none|0)(\s|!|$)/.test(d.value))) return "outline";
|
|
419
|
+
const paints = (d) => (d.prop === "box-shadow" && !/^none\b/.test(d.value)) || (/^border(-[a-z]+)*-color$|^border$/.test(d.prop) && !/^(none|0|transparent)\b/.test(d.value));
|
|
420
|
+
return r.decls.some(paints) ? "paint" : "";
|
|
421
|
+
};
|
|
422
|
+
|
|
423
|
+
function cssChecks(file, rules, text) {
|
|
424
|
+
const hasForced = /forced-colors\s*:\s*active/.test(text);
|
|
425
|
+
const replaced = new Map();
|
|
426
|
+
for (const r of rules) {
|
|
427
|
+
const kind = ring(r);
|
|
428
|
+
if (!kind) continue;
|
|
429
|
+
for (const s of splitList(r.selector)) {
|
|
430
|
+
if (/:focus(?:-visible)?(?![-\w])/.test(s) && replaced.get(focusBase(s)) !== "outline") replaced.set(focusBase(s), kind);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
for (const r of rules) {
|
|
434
|
+
const parts = splitList(r.selector);
|
|
435
|
+
for (const d of r.decls) {
|
|
436
|
+
// focus-outline: outline removed with no :focus-visible (or :focus) rule for the same selector that draws one.
|
|
437
|
+
if (d.prop === "outline" && /^(none|0)(\s|!|$)/.test(d.value)) {
|
|
438
|
+
const here = /:focus/.test(r.selector) ? ring(r) : "";
|
|
439
|
+
const kinds = parts.filter((s) => !s.includes(":not(:focus-visible)")).map((s) => here || replaced.get(focusBase(s)) || "");
|
|
440
|
+
if (kinds.some((k) => !k)) add(file, d.line, "focus-outline", "error", "Do not remove the focus outline; restyle it with --x-color-signal.");
|
|
441
|
+
else if (kinds.includes("paint") && !hasForced)
|
|
442
|
+
add(file, d.line, "forced-colors", "warn", "Focus shown only by box-shadow or border colour, which forced colors overrides; keep outline: 2px solid transparent.");
|
|
443
|
+
}
|
|
444
|
+
// fixed-width: a width or min-width over 320px that is not capped and not behind a min-width query
|
|
445
|
+
// pushes a phone page sideways.
|
|
446
|
+
if (/^(width|min-width|inline-size|min-inline-size)$/.test(d.prop)) {
|
|
447
|
+
const px = pxOf(d.value, sizes);
|
|
448
|
+
const wide = r.at.some((a) => /min-width|width\s*>=?/.test(a));
|
|
449
|
+
const capped = r.decls.some((x) => /^max-(width|inline-size)$/.test(x.prop) && /%|vw|vi|cqi|min\(/.test(x.value));
|
|
450
|
+
if (px !== null && px > 320 && !wide && !capped)
|
|
451
|
+
add(file, d.line, "fixed-width", "warn", `${d.prop}: ${d.value} is wider than a 320px phone; use max-width, min(…, 100%) or a min-width media query.`);
|
|
452
|
+
}
|
|
453
|
+
// nowrap: a container that never wraps and does not scroll or clip pushes the page sideways on a phone.
|
|
454
|
+
if (d.prop === "white-space" && /^nowrap\b/.test(d.value)) {
|
|
455
|
+
const handled = r.decls.some((x) => /^(overflow|overflow-x|text-overflow)$/.test(x.prop) && !/^visible\b/.test(x.value));
|
|
456
|
+
const control = parts.map(subject).some((s) => isControl(s));
|
|
457
|
+
if (!handled && !control) add(file, d.line, "nowrap", "warn", "white-space: nowrap with no overflow or text-overflow; long text widens the page at 320px.");
|
|
458
|
+
}
|
|
459
|
+
// layout-motion: a transition or animation of a layout property (or `all`) runs layout every frame; move with transform and opacity.
|
|
460
|
+
if (d.prop === "transition" || d.prop === "transition-property") {
|
|
461
|
+
const hit = transitioned(d.prop, d.value).find((p) => p === "all" || LAYOUT_PROP.test(p));
|
|
462
|
+
if (hit && !GLOBAL_KEYWORDS.has(hit))
|
|
463
|
+
add(file, d.line, "layout-motion", "warn", `transition of ${hit} runs layout on every frame; transition transform or opacity, or name only the paint properties you change.`);
|
|
464
|
+
}
|
|
465
|
+
if (d.prop === "animation" || d.prop === "animation-name") {
|
|
466
|
+
const name = d.value.split(/[\s,]+/).find((t) => layoutFrames.has(t));
|
|
467
|
+
if (name) add(file, d.line, "layout-motion", "warn", `Animation ${name} changes a size, position or spacing property; animate transform and opacity instead.`);
|
|
468
|
+
}
|
|
469
|
+
// will-change: a layer promoted for good costs memory and keeps text rasterised at one scale; set it only while the motion runs.
|
|
470
|
+
if (d.prop === "will-change" && !/^auto\b/.test(d.value) && !parts.some((s) => /:(?:hover|active|focus|focus-within|focus-visible)\b|\[(?:data|aria)-/.test(s)))
|
|
471
|
+
add(file, d.line, "will-change", "warn", "will-change on a resting element; add it under the state that animates (a [data-*] set during the gesture) and drop it after.");
|
|
472
|
+
// viewport-height: 100vh is taller than the visible area on phones while the address bar shows.
|
|
473
|
+
if (/^(?:min-|max-)?(?:height|block-size)$/.test(d.prop) && /\b\d*\.?\d+vh\b/.test(d.value)) {
|
|
474
|
+
const after = r.decls.slice(r.decls.indexOf(d) + 1).some((x) => x.prop === d.prop && /\d(?:d|s|l)vh\b/.test(x.value));
|
|
475
|
+
if (!after) add(file, d.line, "viewport-height", "warn", `${d.prop}: ${d.value} hides content behind the phone address bar; follow it with the same value in dvh (or svh).`);
|
|
476
|
+
}
|
|
477
|
+
// raw-z-index: stacking outside the token scale fights menus, dialogs and toasts; 0, 1 and -1 order siblings locally.
|
|
478
|
+
if (d.prop === "z-index" && /^-?\d+$/.test(d.value) && Math.abs(Number(d.value)) > 1)
|
|
479
|
+
add(file, d.line, "raw-z-index", "warn", `z-index: ${d.value} is outside the scale; use var(--x-z-*) (dropdown, sticky, modal, toast) or 0, 1 and -1 inside a part.`);
|
|
480
|
+
// target-size: a fixed or max size under 24px on the subject of an interactive selector (SC 2.5.8).
|
|
481
|
+
if (/^(width|height|inline-size|block-size|max-width|max-height|max-inline-size|max-block-size)$/.test(d.prop)) {
|
|
482
|
+
const px = pxOf(d.value, sizes);
|
|
483
|
+
if (px === null || px <= 1 || px >= 24) continue;
|
|
484
|
+
if (r.decls.some((x) => (x.prop === "opacity" && /^0(\.0*)?$/.test(x.value)) || /^(clip|clip-path)$/.test(x.prop) || (x.prop === "visibility" && x.value === "hidden"))) continue;
|
|
485
|
+
const axis = /width|inline/.test(d.prop) ? /^min-(width|inline-size)$/ : /^min-(height|block-size)$/;
|
|
486
|
+
if (r.decls.some((x) => axis.test(x.prop) && (pxOf(x.value, sizes) ?? 0) >= 24)) continue;
|
|
487
|
+
const hit = parts.map(subject).find((s) => !s.includes("::") && isControl(s));
|
|
488
|
+
if (hit) add(file, d.line, "target-size", "warn", `${d.prop}: ${d.value} on ${hit} is under 24px; passes only with 24px spacing (SC 2.5.8).`);
|
|
489
|
+
}
|
|
490
|
+
// reduced-motion: an animation whose @keyframes moves the element, in a file with no reduced-motion query.
|
|
491
|
+
if ((d.prop === "animation" || d.prop === "animation-name") && !universalGuard && !/prefers-reduced-motion/.test(text)) {
|
|
492
|
+
const name = d.value.split(/[\s,]+/).find((t) => !GLOBAL_KEYWORDS.has(t) && moving.get(t) === true);
|
|
493
|
+
if (name) add(file, d.line, "reduced-motion", "warn", `Animation ${name} moves content with no prefers-reduced-motion guard (technique C39).`);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
// An icon is named when it carries label, aria-label, aria-labelledby or title.
|
|
500
|
+
const ICON_START = /^<(Icon|[A-Z]\w*Icon)(?=[\s/>])/;
|
|
501
|
+
const NAMED = /\b(?:aria-label|aria-labelledby|title|label)\s*=/;
|
|
502
|
+
function iconOnly(content) {
|
|
503
|
+
let rest = content.replace(/\{\/\*[\s\S]*?\*\/\}/g, "").trim();
|
|
504
|
+
let icons = 0;
|
|
505
|
+
while (rest) {
|
|
506
|
+
if (rest.startsWith("<svg")) {
|
|
507
|
+
const end = rest.indexOf("</svg>");
|
|
508
|
+
if (end < 0 || /<title|aria-label/.test(rest.slice(0, end))) return false;
|
|
509
|
+
rest = rest.slice(end + 6).trim();
|
|
510
|
+
} else if (ICON_START.test(rest)) {
|
|
511
|
+
const tag = openingTags(rest, ICON_START.exec(rest)[1])[0].text;
|
|
512
|
+
if (!tag.endsWith("/>") || NAMED.test(tag)) return false;
|
|
513
|
+
rest = rest.slice(tag.length).trim();
|
|
514
|
+
} else return false;
|
|
515
|
+
icons++;
|
|
516
|
+
}
|
|
517
|
+
return icons > 0;
|
|
518
|
+
}
|
|
519
|
+
function iconButtonChecks(file, text) {
|
|
520
|
+
const unnamed = (t) => !/\{\s*\.\.\./.test(t) && !/\b(?:aria-label|aria-labelledby|title|children)\s*=/.test(t);
|
|
521
|
+
for (const t of openingTags(text, "button")) {
|
|
522
|
+
if (t.text.endsWith("/>") || !unnamed(t.text)) continue;
|
|
523
|
+
const close = text.indexOf("</button>", t.end);
|
|
524
|
+
if (close > 0 && iconOnly(text.slice(t.end, close))) add(file, t.line, "icon-button-name", "error", "Icon-only button has no accessible name; add aria-label or use IconButton (SC 4.1.2).");
|
|
525
|
+
}
|
|
526
|
+
for (const t of openingTags(text, "Button")) {
|
|
527
|
+
if (t.text.endsWith("/>") && /\bicon\s*=/.test(t.text) && unnamed(t.text)) add(file, t.line, "icon-button-name", "error", "Button with only an icon has no accessible name; use IconButton with label (SC 4.1.2).");
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
// A sign-in frame needs a product line, the language and theme controls, a footer, and one page title.
|
|
532
|
+
function signInChecks(file, text) {
|
|
533
|
+
const shells = openingTags(text, "AuthShell");
|
|
534
|
+
if (!shells.length) return;
|
|
535
|
+
for (const t of shells) {
|
|
536
|
+
const spread = /\{\s*\.\.\./.test(t.text);
|
|
537
|
+
const missing = spread ? [] : ["headline", "actions", "footer"].filter((p) => !new RegExp(`\\s${p}\\s*=`).test(t.text));
|
|
538
|
+
if (missing.length) add(file, t.line, "sign-in-shell", "warn", `AuthShell has no ${missing.join(", ")}; give it a headline, the language and theme controls and a footer (see xdev-ui-admin references/sign-in.md).`);
|
|
539
|
+
if (/\sactions\s*=\s*\{\s*</.test(t.text) && !/\bThemeSwitch\b/.test(t.text)) add(file, t.line, "sign-in-shell", "warn", "AuthShell actions have no ThemeSwitch; a person picks the theme before signing in.");
|
|
540
|
+
if (/\sheadline\s*=\s*\{\s*<h[1-6]\b/.test(t.text)) add(file, t.line, "sign-in-shell", "warn", "The AuthShell headline is a heading; pass text, the form holds the page's only h1.");
|
|
541
|
+
}
|
|
542
|
+
const h1 = openingTags(text, "h1");
|
|
543
|
+
if (h1.length > 1) add(file, h1[1].line, "sign-in-shell", "warn", `${h1.length} h1 in a sign-in page; the form holds one ("Welcome back", "Sign in").`);
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// Page rules: the parts of a list, dashboard, dialog, form and grid that the page reviews (references/pages/*.md) can read from code.
|
|
547
|
+
const PAGES = "xdev-ui-review references/pages";
|
|
548
|
+
function pageChecks(file, text) {
|
|
549
|
+
const each = (name, fn) => {
|
|
550
|
+
for (const t of openingTags(text, name)) {
|
|
551
|
+
const { props, spread } = propsOf(t.text);
|
|
552
|
+
if (!spread) fn(t, props);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
each("DataTable", (t, p) => {
|
|
556
|
+
// rows={RESOURCES}: a fixed set in a constant is never empty.
|
|
557
|
+
if (/^\{\s*[A-Z][A-Z0-9_]*\s*\}$/.test(String(p.get("rows") ?? ""))) return;
|
|
558
|
+
if (!p.has("empty")) add(file, t.line, "list-empty", "warn", `DataTable has no empty state; pass empty={<EmptyState …/>}, with a second one when filters hide every row (${PAGES}/list.md).`);
|
|
559
|
+
});
|
|
560
|
+
each("Dialog", (t, p) => {
|
|
561
|
+
const destructive = isOn(p, "alert") || p.get("tone") === '"danger"';
|
|
562
|
+
if (!destructive) return;
|
|
563
|
+
if (!isOn(p, "modal")) add(file, t.line, "confirm-dialog", "warn", `Destructive Dialog is not modal; without modal there is no focus trap, Esc or return of focus (${PAGES}/dialogs-forms.md).`);
|
|
564
|
+
if (!p.has("busy") && !p.has("confirmDisabled")) add(file, t.line, "confirm-dialog", "warn", `Destructive Dialog does not lock while the request runs; pass busy or confirmDisabled so it cannot be confirmed twice (${PAGES}/dialogs-forms.md).`);
|
|
565
|
+
if (!isOn(p, "alert")) add(file, t.line, "confirm-dialog", "warn", `Destructive Dialog has no alert; a confirm that destroys something is an alertdialog (${PAGES}/dialogs-forms.md).`);
|
|
566
|
+
});
|
|
567
|
+
each("FormDialog", (t, p) => {
|
|
568
|
+
if (!p.has("busy")) add(file, t.line, "form-busy", "warn", `FormDialog has no busy; it can be sent twice or closed mid-request (${PAGES}/dialogs-forms.md).`);
|
|
569
|
+
});
|
|
570
|
+
for (const name of ["Field", "input"]) {
|
|
571
|
+
each(name, (t, p) => {
|
|
572
|
+
const type = /^["']([\w-]+)["']$/.exec(String(p.get("type") ?? ""))?.[1];
|
|
573
|
+
if (["password", "email", "tel"].includes(type) && !p.has("autoComplete") && !p.has("autocomplete"))
|
|
574
|
+
add(file, t.line, "autocomplete", "warn", `A ${type} field has no autoComplete; say what the browser may fill (current-password, new-password, email, tel, or off) (SC 1.3.5).`);
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
each("img", (t, p) => {
|
|
578
|
+
if (!p.has("alt")) add(file, t.line, "img-alt", "error", 'img has no alt; give it the name, or alt="" when the words next to it already say it (SC 1.1.1).');
|
|
579
|
+
});
|
|
580
|
+
each("StatTile", (t, p) => {
|
|
581
|
+
if (p.has("delta") && !p.has("hint")) add(file, t.line, "stat-delta", "warn", `StatTile shows a delta with no hint; say what it is compared with ("vs last 7 days") (${PAGES}/dashboard.md).`);
|
|
582
|
+
});
|
|
583
|
+
each("ResourceCard", (t, p) => {
|
|
584
|
+
const face = p.get("leading");
|
|
585
|
+
if (!face) add(file, t.line, "resource-face", "warn", `ResourceCard has no leading; lead each thing with an Emblem so the grid reads by face (${PAGES}/provider-grid.md).`);
|
|
586
|
+
else if (/<(Avatar|img)\b/.test(String(face))) add(file, t.line, "resource-face", "warn", `ResourceCard leads with an Avatar or img; a thing's face is an Emblem (name, logo, colour), Avatar is for people (${PAGES}/provider-grid.md).`);
|
|
587
|
+
});
|
|
588
|
+
if (!opts.i18n || !labelled) return;
|
|
589
|
+
// Parts whose built-in words show only with one prop set; ShellTitle's default is built from the app's own words.
|
|
590
|
+
const shownWith = { EmptyState: "steps", Label: "required" };
|
|
591
|
+
for (const name of labelled) {
|
|
592
|
+
if (name === "ShellTitle") continue;
|
|
593
|
+
each(name, (t, p) => {
|
|
594
|
+
if (p.has("labels")) return;
|
|
595
|
+
if (shownWith[name] && !isOn(p, shownWith[name])) return;
|
|
596
|
+
// Field's only words are the password toggle: a literal type other than "password", or reveal={false}, has none.
|
|
597
|
+
if (name === "Field") {
|
|
598
|
+
const type = String(p.get("type") ?? "");
|
|
599
|
+
if (!p.has("type") || (/^["']/.test(type) && !/^["']password["']$/.test(type)) || !isOn(p, "reveal") && p.has("reveal")) return;
|
|
600
|
+
}
|
|
601
|
+
if (name === "Dialog" && p.has("confirmLabel") && p.has("cancelLabel")) return;
|
|
602
|
+
if (name === "Spinner" && p.has("label")) return;
|
|
603
|
+
add(file, t.line, "i18n-labels", "warn", `${name} has no labels; its built-in words are English, pass them from the strings files.`);
|
|
604
|
+
});
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
for (const { file, text } of sources) {
|
|
609
|
+
const css = file.endsWith(".css");
|
|
610
|
+
const lines = text.split("\n");
|
|
611
|
+
let inStyle = false;
|
|
612
|
+
let inBlockComment = false;
|
|
613
|
+
lines.forEach((raw, idx) => {
|
|
614
|
+
const n = idx + 1;
|
|
615
|
+
let line = raw;
|
|
616
|
+
if (css) {
|
|
617
|
+
if (inBlockComment) {
|
|
618
|
+
if (line.includes("*/")) inBlockComment = false;
|
|
619
|
+
return;
|
|
620
|
+
}
|
|
621
|
+
if (line.includes("/*") && !line.includes("*/")) {
|
|
622
|
+
inBlockComment = true;
|
|
623
|
+
line = line.slice(0, line.indexOf("/*"));
|
|
624
|
+
}
|
|
625
|
+
line = stripCssComments(line);
|
|
626
|
+
} else if (isComment(line)) return;
|
|
627
|
+
const opens = /style=\{\{|style:\s*\{/.test(line);
|
|
628
|
+
const style = css || inStyle || opens;
|
|
629
|
+
if (!css) {
|
|
630
|
+
if (opens && !/\}\}/.test(line)) inStyle = true;
|
|
631
|
+
else if (inStyle && /\}\}/.test(line)) inStyle = false;
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
if (HEX.test(line) || COLOUR_FN.test(line)) add(file, n, "raw-colour", "error", "Colour literal; use var(--token).");
|
|
635
|
+
if (style && !/@media|@container|outline/.test(line)) {
|
|
636
|
+
for (const m of line.matchAll(PX)) {
|
|
637
|
+
if (Number(m[1]) > 1) {
|
|
638
|
+
add(file, n, "raw-px", "error", `${m[0]} is a raw size; use var(--x-space-*), rem, ch or %.`);
|
|
639
|
+
break;
|
|
640
|
+
}
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
if (style) {
|
|
644
|
+
const cssFont = /(?:^|[\s;{])font-size\s*:/.test(line) || /\bfontSize\b/.test(line);
|
|
645
|
+
const shorthand = /(?:^|[\s;{"'])font\s*:\s*([^;]*)/.exec(line);
|
|
646
|
+
if (cssFont || (shorthand && !/var\(--type-|inherit|unset/.test(shorthand[1]))) add(file, n, "raw-font", "error", "Raw font size; use font: var(--type-*).");
|
|
647
|
+
}
|
|
648
|
+
const side = /(?:border-left|border-inline-start|borderLeft|borderInlineStart)(?:-width|Width)?\s*:\s*([^;}]*)/.exec(line);
|
|
649
|
+
if (side && style) {
|
|
650
|
+
const v = side[1].trim().replace(/^["'`]|["'`],?$/g, "");
|
|
651
|
+
const num = /(-?\d*\.?\d+)\s*(?:px|rem|em)?/.exec(v);
|
|
652
|
+
const none = /^(none|medium none|initial|unset)\b/.test(v) || (num && Number(num[1]) === 0 && !/solid|dashed|double/.test(v));
|
|
653
|
+
const colourOnly = /(?:border-left-color|borderLeftColor|border-inline-start-color)/.test(side[0]);
|
|
654
|
+
if (!none && !colourOnly && v) add(file, n, "left-stripe", "error", "Coloured left stripe; state is a tint, a 1px border or a StatusDot.");
|
|
655
|
+
} else if (style && /box-shadow|boxShadow/.test(line) && /inset\s+-?(?:0?\.\d+|[1-9]\d*(?:\.\d+)?)(?:px|rem|em)?\s+0(?:px|rem|em)?\s+0/.test(line)) {
|
|
656
|
+
add(file, n, "left-stripe", "error", "Inset box-shadow stripe on the left edge.");
|
|
657
|
+
}
|
|
658
|
+
if (!css && /\b(?:min-|max-)?h-screen\b/.test(line)) add(file, n, "viewport-height", "warn", "h-screen is 100vh, taller than the visible area on phones; use h-dvh (min-h-dvh, max-h-dvh).");
|
|
659
|
+
if (!css && style && /\b(?:height|minHeight|maxHeight|blockSize|minBlockSize)\s*:\s*["'`]\d*\.?\d+vh\b/.test(line))
|
|
660
|
+
add(file, n, "viewport-height", "warn", "A vh height in a style prop hides content behind the phone address bar; use dvh.");
|
|
661
|
+
if (!css && style && /\bzIndex\s*:\s*-?\d+/.test(line) && Math.abs(Number(/\bzIndex\s*:\s*(-?\d+)/.exec(line)[1])) > 1)
|
|
662
|
+
add(file, n, "raw-z-index", "warn", "A numeric zIndex is outside the scale; use var(--x-z-*) or 0, 1 and -1 inside a part.");
|
|
663
|
+
if (!css && /tabindex\s*=\s*(?:\{\s*|["'])\+?0*[1-9]\d*\s*[}"']/i.test(line)) add(file, n, "positive-tabindex", "error", "Positive tabIndex reorders focus (WCAG F44); use 0 or -1 and DOM order.");
|
|
664
|
+
if (!css && style && /outline\s*:\s*["']?(none|0)\b/.test(line)) add(file, n, "focus-outline", "error", "Do not remove the focus outline; restyle it with --x-color-signal.");
|
|
665
|
+
if (tokens) {
|
|
666
|
+
for (const m of line.matchAll(/var\(\s*--([a-z0-9-]+)/g)) {
|
|
667
|
+
if (!tokens.has(m[1]) && !local.has(m[1])) add(file, n, "unknown-token", "error", `--${m[1]} is not a design token.`);
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
if (file.endsWith(".tsx")) {
|
|
671
|
+
// (?<!=): the > of an arrow function (`=> !x.map<T>`) is not the end of a tag.
|
|
672
|
+
for (const m of line.matchAll(/(?<!=)>([^<>{}=]+)</g)) {
|
|
673
|
+
const text = m[1].trim();
|
|
674
|
+
if (!/[A-Za-z]/.test(text)) continue;
|
|
675
|
+
if (/!/.test(text) || EMOJI.test(text) || TITLE_CASE.test(text)) add(file, n, "label-voice", "warn", `"${text}": sentence case, no emoji, no exclamation marks.`);
|
|
676
|
+
if (/\.\.\./.test(text)) add(file, n, "ellipsis", "warn", `"${text}": use the ellipsis character … instead of three dots.`);
|
|
677
|
+
}
|
|
678
|
+
for (const m of line.matchAll(/\bplaceholder=["']([^"']*\.\.\.)["']/g)) add(file, n, "ellipsis", "warn", `placeholder "${m[1]}": use … instead of three dots.`);
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
if (parsed.has(file)) cssChecks(file, parsed.get(file), text);
|
|
682
|
+
if (file.endsWith(".tsx")) iconButtonChecks(file, text);
|
|
683
|
+
if (file.endsWith(".tsx")) {
|
|
684
|
+
// click-div: a div, span, li, p or td that takes clicks is not a control for keyboard or assistive technology.
|
|
685
|
+
for (const tagName of ["div", "span", "li", "p", "td", "img"]) {
|
|
686
|
+
for (const tg of openingTags(text, tagName)) {
|
|
687
|
+
const { props } = propsOf(tg.text);
|
|
688
|
+
if (props.has("onClick") && !props.has("role")) add(file, tg.line, "click-div", "error", `<${tagName} onClick> is not reachable by keyboard; use a <button> (an action) or <a href> (a place).`);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
// nav-onclick: a button that only navigates loses Cmd/Ctrl+click, middle-click and the link role.
|
|
692
|
+
for (const m of text.matchAll(/\bonClick=\{\s*\(\)\s*=>\s*(?:navigate|router\.push|router\.navigate)\(|\bonClick=\{\s*\(\)\s*=>\s*\{?\s*(?:window\.)?location\.(?:href\s*=|assign\()/g))
|
|
693
|
+
add(file, text.slice(0, m.index).split("\n").length, "nav-onclick", "warn", "A click that only goes to a page should be a link: Button href, <a href> or the router's Link.");
|
|
694
|
+
for (const m of text.matchAll(/\bonPaste\s*=\s*\{[^}]{0,120}?preventDefault/g))
|
|
695
|
+
add(file, text.slice(0, m.index).split("\n").length, "paste-block", "error", "Blocking paste breaks password managers and copied codes and can fail SC 3.3.8; let people paste and validate the value instead.");
|
|
696
|
+
}
|
|
697
|
+
if (file.endsWith(".tsx")) signInChecks(file, text);
|
|
698
|
+
if (file.endsWith(".tsx")) pageChecks(file, text);
|
|
699
|
+
if (file.endsWith(".tsx")) {
|
|
700
|
+
const tags = openingTags(text, "Button").filter((t) => /variant\s*=\s*["{]\s*["']?primary/.test(t.text));
|
|
701
|
+
if (tags.length > 1) add(file, tags[1].line, "primary-count", "warn", `${tags.length} primary Buttons in one file; one primary per surface, the rest secondary (the default).`);
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
// zoom-block: a viewport that forbids pinch zoom (SC 1.4.4). The page lives in index.html next to src.
|
|
706
|
+
for (const html of [join(root, "index.html"), join(dirname(root), "index.html")]) {
|
|
707
|
+
if (!existsSync(html)) continue;
|
|
708
|
+
readFileSync(html, "utf8").split("\n").forEach((l, i) => {
|
|
709
|
+
if (/name=["']viewport["']/.test(l) && /user-scalable\s*=\s*(no|0)|maximum-scale\s*=\s*1(\.0*)?\b/.test(l))
|
|
710
|
+
add(html, i + 1, "zoom-block", "error", "The viewport blocks zoom; drop user-scalable=no and maximum-scale=1 (SC 1.4.4).");
|
|
711
|
+
});
|
|
712
|
+
}
|
|
713
|
+
|
|
714
|
+
if (opts.i18n) {
|
|
715
|
+
const dir2 = resolve(opts.i18n);
|
|
716
|
+
const en = join(dir2, "en.ts");
|
|
717
|
+
const vi = join(dir2, "vi.ts");
|
|
718
|
+
if (existsSync(en) && existsSync(vi)) {
|
|
719
|
+
const a = dictKeys(readFileSync(en, "utf8"));
|
|
720
|
+
const b = dictKeys(readFileSync(vi, "utf8"));
|
|
721
|
+
for (const [k, v] of a) if (!b.has(k)) add(vi, 1, "i18n-parity", "error", `key ${k} is in en but not in vi.`);
|
|
722
|
+
for (const [k, v] of b) if (!a.has(k)) add(en, 1, "i18n-parity", "error", `key ${k} is in vi but not in en.`);
|
|
723
|
+
for (const [file, d] of [[en, a], [vi, b]]) {
|
|
724
|
+
for (const [k, v] of d) {
|
|
725
|
+
if (v.empty) add(file, v.line, "i18n-parity", "error", `key ${k} is empty.`);
|
|
726
|
+
const s = strValue(v.value);
|
|
727
|
+
if (s && (/!/.test(s) || EMOJI.test(s) || TITLE_CASE.test(s))) add(file, v.line, "label-voice", "warn", `"${s}": sentence case, no emoji, no exclamation marks.`);
|
|
728
|
+
if (s && /\.\.\./.test(s)) add(file, v.line, "ellipsis", "warn", `"${s}": use the ellipsis character … instead of three dots.`);
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
} else notes.push(`i18n-parity skipped: ${dir2} needs en.ts and vi.ts`);
|
|
732
|
+
}
|
|
733
|
+
if (opts.contrast) {
|
|
734
|
+
if (!manifestTokens.length) notes.push("contrast skipped: no manifest (pass --manifest)");
|
|
735
|
+
for (const p of contrastReport(manifestTokens).filter((x) => !x.pass)) {
|
|
736
|
+
const sc = p.kind === "text" ? "1.4.3" : "1.4.11";
|
|
737
|
+
add(manifestPath, 1, "contrast", p.level, `${p.fg} on ${p.bg} (${p.theme}) is ${Math.floor(p.ratio * 100) / 100}:1; ${p.kind} needs ${p.need}:1 (SC ${sc}).`);
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
findings.sort((x, y) => x.file.localeCompare(y.file) || x.line - y.line);
|
|
741
|
+
return { findings, notes, files: files.length };
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
// Compare real paths: pnpm puts the package behind a symlink, and the URL of this module is the resolved one.
|
|
745
|
+
const isMain = (() => {
|
|
746
|
+
try {
|
|
747
|
+
return !!process.argv[1] && realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url));
|
|
748
|
+
} catch {
|
|
749
|
+
return false;
|
|
750
|
+
}
|
|
751
|
+
})();
|
|
752
|
+
if (isMain) {
|
|
753
|
+
const args = process.argv.slice(2);
|
|
754
|
+
const opts = {};
|
|
755
|
+
let dir;
|
|
756
|
+
for (let i = 0; i < args.length; i++) {
|
|
757
|
+
if (args[i] === "--i18n") opts.i18n = args[++i];
|
|
758
|
+
else if (args[i] === "--manifest") opts.manifest = args[++i];
|
|
759
|
+
else if (args[i] === "--contrast") opts.contrast = true;
|
|
760
|
+
else if (args[i].startsWith("--")) {
|
|
761
|
+
console.error(`unknown option ${args[i]}`);
|
|
762
|
+
process.exit(2);
|
|
763
|
+
} else dir = args[i];
|
|
764
|
+
}
|
|
765
|
+
if (!dir || !existsSync(dir)) {
|
|
766
|
+
console.error("usage: audit.mjs <src-dir> [--i18n <dir>] [--manifest <path>] [--contrast]");
|
|
767
|
+
process.exit(2);
|
|
768
|
+
}
|
|
769
|
+
const { findings, notes, files } = audit(dir, opts);
|
|
770
|
+
for (const f of findings) console.log(`${f.file}:${f.line} ${f.rule} ${f.level === "warn" ? "(warn) " : ""}${f.message}`);
|
|
771
|
+
for (const n of notes) console.log(`note: ${n}`);
|
|
772
|
+
const errors = findings.filter((f) => f.level === "error").length;
|
|
773
|
+
console.log(`audit: ${files} files, ${errors} errors, ${findings.length - errors} warnings`);
|
|
774
|
+
process.exit(errors ? 1 : 0);
|
|
775
|
+
}
|