@techsio/ui-kit 0.57.0 → 0.59.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +128 -133
- package/dist/atoms/action-icon.js +9 -8
- package/dist/atoms/button.js +114 -18
- package/dist/atoms/checkbox.js +77 -17
- package/dist/atoms/hotkeys.js +26 -7
- package/dist/atoms/icon.js +5 -5
- package/dist/atoms/image.js +118 -3
- package/dist/atoms/input.js +57 -9
- package/dist/atoms/label.js +13 -4
- package/dist/atoms/link-button.js +15 -12
- package/dist/atoms/link.js +18 -4
- package/dist/atoms/numeric-input.js +362 -84
- package/dist/atoms/rating.js +306 -73
- package/dist/atoms/skeleton.js +18 -14
- package/dist/atoms/status-text.js +31 -18
- package/dist/atoms/textarea.js +59 -12
- package/dist/atoms/tooltip.js +64 -43
- package/dist/hotkeys.js +1 -0
- package/dist/internal/choice-control.js +173 -0
- package/dist/internal/combobox-query-sync.js +11 -0
- package/dist/internal/date-picker-coordinator.js +56 -40
- package/dist/internal/date-picker-dom.js +44 -0
- package/dist/internal/date-picker-input.js +30 -0
- package/dist/internal/described-by.js +23 -18
- package/dist/internal/form-control-lifecycle.js +122 -0
- package/dist/internal/molecules/command.context.js +1 -0
- package/dist/internal/molecules/drawer.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.context.js +1 -0
- package/dist/internal/molecules/vertical-navigation.styles.js +9 -2
- package/dist/internal/numeric-input-editing.js +87 -0
- package/dist/internal/organisms/sidebar.context.js +1 -0
- package/dist/internal/organisms/sidebar.focus.js +1 -0
- package/dist/internal/overlay-portal.js +72 -0
- package/dist/internal/reduced-motion.js +1 -0
- package/dist/internal/use-effective-disabled.js +8 -0
- package/dist/molecules/accordion.js +44 -30
- package/dist/molecules/availability-status.js +1 -0
- package/dist/molecules/breadcrumb.js +11 -11
- package/dist/molecules/carousel.js +279 -97
- package/dist/molecules/cascade-select.js +327 -81
- package/dist/molecules/chart.js +427 -78
- package/dist/molecules/color-select.js +181 -62
- package/dist/molecules/combobox.js +537 -182
- package/dist/molecules/command.js +2 -1
- package/dist/molecules/date-picker.js +629 -119
- package/dist/molecules/dialog.js +89 -48
- package/dist/molecules/drawer.js +63 -6
- package/dist/molecules/file-upload.js +373 -37
- package/dist/molecules/form-checkbox.js +65 -22
- package/dist/molecules/form-error-summary.js +29 -5
- package/dist/molecules/form-input.js +26 -30
- package/dist/molecules/form-numeric-input.js +11 -9
- package/dist/molecules/form-textarea.js +26 -23
- package/dist/molecules/menu.js +170 -47
- package/dist/molecules/pagination.js +100 -28
- package/dist/molecules/phone-input.js +172 -37
- package/dist/molecules/popover.js +53 -26
- package/dist/molecules/price-block.js +1 -0
- package/dist/molecules/product-card.js +85 -23
- package/dist/molecules/quantity-field.js +4 -2
- package/dist/molecules/radio-card.js +102 -30
- package/dist/molecules/radio-group.js +108 -31
- package/dist/molecules/search-form.js +116 -13
- package/dist/molecules/select.js +226 -81
- package/dist/molecules/slider.js +141 -30
- package/dist/molecules/steps.js +181 -50
- package/dist/molecules/switch.js +86 -20
- package/dist/molecules/tabs.js +227 -31
- package/dist/molecules/toast.js +155 -53
- package/dist/molecules/totals-summary.js +2 -1
- package/dist/molecules/tour.js +9 -5
- package/dist/molecules/tree-view.js +255 -109
- package/dist/molecules/vertical-navigation.js +8 -4
- package/dist/organisms/data-table.fields.js +26 -5
- package/dist/organisms/data-table.helpers.js +6 -2
- package/dist/organisms/data-table.js +587 -154
- package/dist/organisms/footer.js +18 -11
- package/dist/organisms/gallery.js +61 -24
- package/dist/organisms/header.js +106 -32
- package/dist/organisms/line-item.js +1 -0
- package/dist/organisms/sidebar.js +1 -0
- package/dist/organisms/table.js +22 -7
- package/dist/src/atoms/action-icon.d.ts +10 -10
- package/dist/src/atoms/action-icon.d.ts.map +1 -1
- package/dist/src/atoms/badge.d.ts +3 -3
- package/dist/src/atoms/badge.d.ts.map +1 -1
- package/dist/src/atoms/button.d.ts +47 -24
- package/dist/src/atoms/button.d.ts.map +1 -1
- package/dist/src/atoms/checkbox.d.ts +6 -5
- package/dist/src/atoms/checkbox.d.ts.map +1 -1
- package/dist/src/atoms/hotkeys.d.ts +3 -2
- package/dist/src/atoms/hotkeys.d.ts.map +1 -1
- package/dist/src/atoms/icon.d.ts +18 -17
- package/dist/src/atoms/icon.d.ts.map +1 -1
- package/dist/src/atoms/image.d.ts +38 -7
- package/dist/src/atoms/image.d.ts.map +1 -1
- package/dist/src/atoms/input.d.ts +23 -14
- package/dist/src/atoms/input.d.ts.map +1 -1
- package/dist/src/atoms/label.d.ts +4 -4
- package/dist/src/atoms/label.d.ts.map +1 -1
- package/dist/src/atoms/link-button.d.ts +78 -31
- package/dist/src/atoms/link-button.d.ts.map +1 -1
- package/dist/src/atoms/link.d.ts +30 -9
- package/dist/src/atoms/link.d.ts.map +1 -1
- package/dist/src/atoms/numeric-input.d.ts +24 -19
- package/dist/src/atoms/numeric-input.d.ts.map +1 -1
- package/dist/src/atoms/rating.d.ts +54 -26
- package/dist/src/atoms/rating.d.ts.map +1 -1
- package/dist/src/atoms/skeleton.d.ts +9 -9
- package/dist/src/atoms/skeleton.d.ts.map +1 -1
- package/dist/src/atoms/status-text.d.ts +21 -13
- package/dist/src/atoms/status-text.d.ts.map +1 -1
- package/dist/src/atoms/textarea.d.ts +22 -20
- package/dist/src/atoms/textarea.d.ts.map +1 -1
- package/dist/src/atoms/tooltip.d.ts +5 -5
- package/dist/src/atoms/tooltip.d.ts.map +1 -1
- package/dist/src/hotkeys.d.ts +1 -1
- package/dist/src/hotkeys.d.ts.map +1 -1
- package/dist/src/internal/choice-control.d.ts +18 -0
- package/dist/src/internal/choice-control.d.ts.map +1 -0
- package/dist/src/internal/combobox-query-sync.d.ts +4 -0
- package/dist/src/internal/combobox-query-sync.d.ts.map +1 -0
- package/dist/src/internal/date-picker-coordinator.d.ts +7 -1
- package/dist/src/internal/date-picker-coordinator.d.ts.map +1 -1
- package/dist/src/internal/date-picker-dom.d.ts +10 -0
- package/dist/src/internal/date-picker-dom.d.ts.map +1 -0
- package/dist/src/internal/date-picker-input.d.ts +7 -0
- package/dist/src/internal/date-picker-input.d.ts.map +1 -0
- package/dist/src/internal/described-by.d.ts +7 -1
- package/dist/src/internal/described-by.d.ts.map +1 -1
- package/dist/src/internal/form-control-lifecycle.d.ts +22 -0
- package/dist/src/internal/form-control-lifecycle.d.ts.map +1 -0
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts +1 -1
- package/dist/src/internal/molecules/vertical-navigation.context.d.ts.map +1 -1
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts +21 -0
- package/dist/src/internal/molecules/vertical-navigation.styles.d.ts.map +1 -1
- package/dist/src/internal/numeric-input-editing.d.ts +13 -0
- package/dist/src/internal/numeric-input-editing.d.ts.map +1 -0
- package/dist/src/internal/overlay-portal.d.ts +18 -0
- package/dist/src/internal/overlay-portal.d.ts.map +1 -0
- package/dist/src/internal/use-effective-disabled.d.ts +4 -0
- package/dist/src/internal/use-effective-disabled.d.ts.map +1 -0
- package/dist/src/molecules/accordion.d.ts +25 -19
- package/dist/src/molecules/accordion.d.ts.map +1 -1
- package/dist/src/molecules/availability-status.d.ts +4 -1
- package/dist/src/molecules/availability-status.d.ts.map +1 -1
- package/dist/src/molecules/breadcrumb.d.ts +2 -2
- package/dist/src/molecules/breadcrumb.d.ts.map +1 -1
- package/dist/src/molecules/carousel.d.ts +51 -52
- package/dist/src/molecules/carousel.d.ts.map +1 -1
- package/dist/src/molecules/cascade-select.d.ts +23 -8
- package/dist/src/molecules/cascade-select.d.ts.map +1 -1
- package/dist/src/molecules/chart.d.ts +18 -1
- package/dist/src/molecules/chart.d.ts.map +1 -1
- package/dist/src/molecules/color-select.d.ts +19 -3
- package/dist/src/molecules/color-select.d.ts.map +1 -1
- package/dist/src/molecules/combobox.d.ts +27 -5
- package/dist/src/molecules/combobox.d.ts.map +1 -1
- package/dist/src/molecules/command.d.ts +1 -1
- package/dist/src/molecules/date-picker.d.ts +30 -4
- package/dist/src/molecules/date-picker.d.ts.map +1 -1
- package/dist/src/molecules/dialog.d.ts +17 -4
- package/dist/src/molecules/dialog.d.ts.map +1 -1
- package/dist/src/molecules/drawer.d.ts +4 -4
- package/dist/src/molecules/drawer.d.ts.map +1 -1
- package/dist/src/molecules/file-upload.d.ts +11 -6
- package/dist/src/molecules/file-upload.d.ts.map +1 -1
- package/dist/src/molecules/form-checkbox.d.ts +7 -2
- package/dist/src/molecules/form-checkbox.d.ts.map +1 -1
- package/dist/src/molecules/form-error-summary.d.ts +4 -3
- package/dist/src/molecules/form-error-summary.d.ts.map +1 -1
- package/dist/src/molecules/form-input.d.ts +5 -6
- package/dist/src/molecules/form-input.d.ts.map +1 -1
- package/dist/src/molecules/form-numeric-input.d.ts +5 -5
- package/dist/src/molecules/form-numeric-input.d.ts.map +1 -1
- package/dist/src/molecules/form-textarea.d.ts +5 -6
- package/dist/src/molecules/form-textarea.d.ts.map +1 -1
- package/dist/src/molecules/menu.d.ts +17 -3
- package/dist/src/molecules/menu.d.ts.map +1 -1
- package/dist/src/molecules/pagination.d.ts +1 -1
- package/dist/src/molecules/pagination.d.ts.map +1 -1
- package/dist/src/molecules/phone-input.d.ts +4 -1
- package/dist/src/molecules/phone-input.d.ts.map +1 -1
- package/dist/src/molecules/popover.d.ts +7 -1
- package/dist/src/molecules/popover.d.ts.map +1 -1
- package/dist/src/molecules/price-block.d.ts +1 -1
- package/dist/src/molecules/price-block.d.ts.map +1 -1
- package/dist/src/molecules/product-card.d.ts +127 -27
- package/dist/src/molecules/product-card.d.ts.map +1 -1
- package/dist/src/molecules/quantity-field.d.ts +1 -1
- package/dist/src/molecules/quantity-field.d.ts.map +1 -1
- package/dist/src/molecules/radio-card.d.ts +10 -3
- package/dist/src/molecules/radio-card.d.ts.map +1 -1
- package/dist/src/molecules/radio-group.d.ts +15 -6
- package/dist/src/molecules/radio-group.d.ts.map +1 -1
- package/dist/src/molecules/search-form.d.ts +37 -12
- package/dist/src/molecules/search-form.d.ts.map +1 -1
- package/dist/src/molecules/select.d.ts +34 -29
- package/dist/src/molecules/select.d.ts.map +1 -1
- package/dist/src/molecules/slider.d.ts +23 -2
- package/dist/src/molecules/slider.d.ts.map +1 -1
- package/dist/src/molecules/steps.d.ts +30 -10
- package/dist/src/molecules/steps.d.ts.map +1 -1
- package/dist/src/molecules/switch.d.ts +54 -33
- package/dist/src/molecules/switch.d.ts.map +1 -1
- package/dist/src/molecules/tabs.d.ts +11 -11
- package/dist/src/molecules/tabs.d.ts.map +1 -1
- package/dist/src/molecules/toast.d.ts +38 -14
- package/dist/src/molecules/toast.d.ts.map +1 -1
- package/dist/src/molecules/totals-summary.d.ts +1 -1
- package/dist/src/molecules/totals-summary.d.ts.map +1 -1
- package/dist/src/molecules/tour.d.ts +1 -1
- package/dist/src/molecules/tour.d.ts.map +1 -1
- package/dist/src/molecules/tree-view.d.ts +16 -20
- package/dist/src/molecules/tree-view.d.ts.map +1 -1
- package/dist/src/molecules/vertical-navigation.d.ts +2 -2
- package/dist/src/molecules/vertical-navigation.d.ts.map +1 -1
- package/dist/src/organisms/data-table.d.ts +28 -3
- package/dist/src/organisms/data-table.d.ts.map +1 -1
- package/dist/src/organisms/data-table.fields.d.ts +4 -1
- package/dist/src/organisms/data-table.fields.d.ts.map +1 -1
- package/dist/src/organisms/data-table.helpers.d.ts +5 -12
- package/dist/src/organisms/data-table.helpers.d.ts.map +1 -1
- package/dist/src/organisms/footer.d.ts +5 -5
- package/dist/src/organisms/footer.d.ts.map +1 -1
- package/dist/src/organisms/gallery.d.ts +11 -9
- package/dist/src/organisms/gallery.d.ts.map +1 -1
- package/dist/src/organisms/header.d.ts +24 -22
- package/dist/src/organisms/header.d.ts.map +1 -1
- package/dist/src/organisms/table.d.ts +14 -14
- package/dist/src/organisms/table.d.ts.map +1 -1
- package/dist/src/templates/accordion.d.ts +8 -6
- package/dist/src/templates/accordion.d.ts.map +1 -1
- package/dist/src/templates/breadcrumb.d.ts +1 -1
- package/dist/src/templates/breadcrumb.d.ts.map +1 -1
- package/dist/src/templates/carousel.d.ts +3 -3
- package/dist/src/templates/carousel.d.ts.map +1 -1
- package/dist/src/templates/facet-filter-panel.d.ts +9 -3
- package/dist/src/templates/facet-filter-panel.d.ts.map +1 -1
- package/dist/src/templates/gallery.d.ts +2 -2
- package/dist/src/templates/gallery.d.ts.map +1 -1
- package/dist/src/templates/numeric-input.d.ts +1 -1
- package/dist/src/templates/numeric-input.d.ts.map +1 -1
- package/dist/src/templates/popover.d.ts +4 -2
- package/dist/src/templates/popover.d.ts.map +1 -1
- package/dist/src/templates/product-card.d.ts +12 -4
- package/dist/src/templates/product-card.d.ts.map +1 -1
- package/dist/src/templates/search-suggestions.d.ts +1 -1
- package/dist/src/templates/select.d.ts +7 -2
- package/dist/src/templates/select.d.ts.map +1 -1
- package/dist/src/templates/tabs.d.ts +8 -7
- package/dist/src/templates/tabs.d.ts.map +1 -1
- package/dist/src/theme/theme-config.d.ts +9 -16
- package/dist/src/theme/theme-config.d.ts.map +1 -1
- package/dist/src/theme/theme-provider.d.ts +16 -21
- package/dist/src/theme/theme-provider.d.ts.map +1 -1
- package/dist/src/theme/theme-toggle.d.ts.map +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/templates/accordion.js +3 -1
- package/dist/templates/breadcrumb.js +11 -4
- package/dist/templates/carousel.js +3 -6
- package/dist/templates/facet-filter-panel.js +121 -52
- package/dist/templates/gallery.js +6 -2
- package/dist/templates/numeric-input.js +6 -1
- package/dist/templates/popover.js +6 -1
- package/dist/templates/product-card.js +52 -26
- package/dist/templates/select.js +6 -1
- package/dist/templates/tabs.js +4 -2
- package/dist/theme/theme-config.js +8 -16
- package/dist/theme/theme-provider.js +89 -63
- package/dist/theme/theme-toggle.js +17 -9
- package/dist/utils.js +11 -1
- package/package.json +9 -5
- package/src/tokens/_base.css +4 -3
- package/src/tokens/_business-atoms.css +96 -0
- package/src/tokens/_foundation-overrides.css +251 -0
- package/src/tokens/_reset.css +10 -10
- package/src/tokens/_scheme-scopes.css +4194 -0
- package/src/tokens/_semantic.css +1 -23
- package/src/tokens/_tokens-base.css +36 -32
- package/src/tokens/_typography.css +2 -1
- package/src/tokens/components/_form-control.css +149 -6
- package/src/tokens/components/_popup-surface.css +15 -29
- package/src/tokens/components/atoms/_action-icon.css +49 -0
- package/src/tokens/components/atoms/_button.css +77 -0
- package/src/tokens/components/atoms/_checkbox.css +47 -4
- package/src/tokens/components/atoms/_hotkeys.css +2 -0
- package/src/tokens/components/atoms/_icon.css +60 -7
- package/src/tokens/components/atoms/_image.css +18 -0
- package/src/tokens/components/atoms/_input.css +20 -0
- package/src/tokens/components/atoms/_label.css +3 -7
- package/src/tokens/components/atoms/_link.css +47 -5
- package/src/tokens/components/atoms/_numeric-input.css +121 -2
- package/src/tokens/components/atoms/_rating.css +55 -6
- package/src/tokens/components/atoms/_skeleton.css +12 -2
- package/src/tokens/components/atoms/_status-text.css +35 -5
- package/src/tokens/components/atoms/_textarea.css +32 -3
- package/src/tokens/components/atoms/_tooltip.css +25 -0
- package/src/tokens/components/molecules/_accordion.css +46 -5
- package/src/tokens/components/molecules/_breadcrumb.css +15 -4
- package/src/tokens/components/molecules/_carousel.css +67 -0
- package/src/tokens/components/molecules/_cascade-select.css +104 -0
- package/src/tokens/components/molecules/_chart.css +32 -16
- package/src/tokens/components/molecules/_color-select.css +21 -0
- package/src/tokens/components/molecules/_combobox.css +81 -0
- package/src/tokens/components/molecules/_command.css +1 -0
- package/src/tokens/components/molecules/_date-picker.css +66 -10
- package/src/tokens/components/molecules/_dialog.css +36 -4
- package/src/tokens/components/molecules/_drawer.css +39 -3
- package/src/tokens/components/molecules/_file-upload.css +16 -1
- package/src/tokens/components/molecules/_menu.css +17 -0
- package/src/tokens/components/molecules/_pagination.css +19 -0
- package/src/tokens/components/molecules/_phone-input.css +20 -5
- package/src/tokens/components/molecules/_popover.css +34 -0
- package/src/tokens/components/molecules/_product-card.css +70 -0
- package/src/tokens/components/molecules/_radio-card.css +35 -0
- package/src/tokens/components/molecules/_radio-group.css +8 -0
- package/src/tokens/components/molecules/_select.css +33 -0
- package/src/tokens/components/molecules/_slider.css +5 -0
- package/src/tokens/components/molecules/_steps.css +52 -0
- package/src/tokens/components/molecules/_switch.css +59 -10
- package/src/tokens/components/molecules/_tabs.css +61 -3
- package/src/tokens/components/molecules/_toast.css +60 -0
- package/src/tokens/components/molecules/_totals-summary.css +22 -22
- package/src/tokens/components/molecules/_tour.css +16 -1
- package/src/tokens/components/molecules/_tree-view.css +27 -3
- package/src/tokens/components/molecules/_vertical-navigation.css +21 -3
- package/src/tokens/components/organisms/_data-table.css +97 -0
- package/src/tokens/components/organisms/_footer.css +9 -0
- package/src/tokens/components/organisms/_gallery.css +11 -0
- package/src/tokens/components/organisms/_header.css +22 -0
- package/src/tokens/components/organisms/_sidebar.css +1 -1
- package/src/tokens/components/organisms/_table.css +31 -0
- package/src/tokens/components/templates/_facet-filter-panel.css +11 -1
- package/src/tokens/figma/akros/variables.css +15 -6
- package/src/tokens/figma/brand-overrides.css +171 -57
- package/src/tokens/figma/business/variables.css +15 -6
- package/src/tokens/figma/cyber/variables.css +115 -38
- package/src/tokens/figma/cyber-dark/variables.css +115 -38
- package/src/tokens/figma/dark/variables.css +13 -4
- package/src/tokens/figma/light/variables.css +62 -49
- package/src/tokens/figma/{neo → n1}/variables.css +123 -114
- package/src/tokens/figma/variables.css +658 -249
- package/src/tokens/theme.css +24 -4
- package/src/tokens/_colors.css +0 -5
- package/src/tokens/figma/neo-dark/variables.css +0 -457
package/README.md
CHANGED
|
@@ -1,108 +1,138 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @techsio/ui-kit
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
React 19 components, Zag.js interactions and Tailwind v4 design tokens.
|
|
4
|
+
Start with **Guide / Getting Started** in Storybook (source:
|
|
5
|
+
[getting-started.mdx](.storybook/getting-started.mdx)).
|
|
6
|
+
[AGENTS.md](AGENTS.md) is the canonical contributor rulebook, and
|
|
7
|
+
[component contracts](docs/component-contracts.md) define shared behavior.
|
|
4
8
|
|
|
5
|
-
|
|
9
|
+
## Install and initialize
|
|
6
10
|
|
|
7
|
-
|
|
11
|
+
Use React and React DOM 19.2 or newer. The package has public subpath exports,
|
|
12
|
+
not a root barrel.
|
|
8
13
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
- **Multi-layered design tokens:** We separate tokens into three layers: global, semantic, and component.
|
|
14
|
-
- **Single UI library:** All shared components live in one library (e.g. `ui`).
|
|
15
|
-
- **Centralized CSS Variables:** All design tokens (CSS variables) are defined in one central place.
|
|
16
|
-
- **Hybrid Structure:** Our UI library is organized into atoms, molecules, and domain-based organisms. Basic components (like buttons) are atoms or molecules; only composite, domain-specific components go into organisms.
|
|
17
|
-
- **Clear Boundaries:** For example, a button is an atom or molecule. We never export a button from an organism.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## 2. Design Tokens
|
|
22
|
-
|
|
23
|
-
### Multi-Layered Tokens
|
|
24
|
-
|
|
25
|
-
1. **Global Tokens:**
|
|
26
|
-
- These are the raw design values (like our base color palette, spacing scales, etc.).
|
|
27
|
-
- They are defined in our central tokens files (e.g. `_colors.css`, `_spacing.css`).
|
|
28
|
-
2. **Semantic Tokens:**
|
|
29
|
-
- These give meaning to global tokens by mapping them to their design role.
|
|
30
|
-
- For example, `-color-brand-primary` maps to a global blue value.
|
|
31
|
-
- All components will use semantic tokens rather than raw values.
|
|
32
|
-
3. **Component Tokens:**
|
|
33
|
-
- These are defined for each component and act as a layer between the component and semantic tokens.
|
|
34
|
-
- For example, a Button component uses `-button-bg` which is set to `var(--color-brand-primary)`.
|
|
35
|
-
- **Important:** All component tokens are defined centrally, not near the component code.
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## 3. Folder Structure
|
|
40
|
-
|
|
41
|
-
Our UI library follows a hybrid approach with three main parts:
|
|
14
|
+
```sh
|
|
15
|
+
pnpm add @techsio/ui-kit react react-dom
|
|
16
|
+
pnpm add -D tailwindcss @tailwindcss/postcss postcss
|
|
17
|
+
```
|
|
42
18
|
|
|
43
|
-
|
|
19
|
+
Process global CSS once through Tailwind v4's PostCSS plugin:
|
|
44
20
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
21
|
+
```js
|
|
22
|
+
// postcss.config.mjs
|
|
23
|
+
export default { plugins: { '@tailwindcss/postcss': {} } }
|
|
24
|
+
```
|
|
49
25
|
|
|
50
|
-
|
|
26
|
+
Choose **one** stylesheet recipe:
|
|
51
27
|
|
|
28
|
+
```css
|
|
29
|
+
/* App does not already import Tailwind: */
|
|
30
|
+
@import "@techsio/ui-kit/tokens-with-tailwind";
|
|
52
31
|
```
|
|
53
|
-
ui/atoms/
|
|
54
|
-
ui/molecules/
|
|
55
32
|
|
|
33
|
+
```css
|
|
34
|
+
/* App owns its Tailwind import: */
|
|
35
|
+
@import "tailwindcss";
|
|
36
|
+
@import "@techsio/ui-kit/tokens";
|
|
56
37
|
```
|
|
57
38
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
-
|
|
61
|
-
|
|
39
|
+
Both entries register the shipped component JavaScript with a package-relative
|
|
40
|
+
`@source`. Tailwind otherwise excludes dependencies under `node_modules`; an
|
|
41
|
+
unprocessed CSS link or a token-variable import alone cannot generate utilities.
|
|
42
|
+
Do not copy component classes into app source or import both recipes together.
|
|
62
43
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
```
|
|
66
|
-
ui/organisms/cart/
|
|
67
|
-
ui/organisms/checkout/
|
|
68
|
-
ui/organisms/navigation/
|
|
44
|
+
```tsx
|
|
45
|
+
import { Button } from '@techsio/ui-kit/atoms/button'
|
|
69
46
|
|
|
47
|
+
export function CheckoutAction() {
|
|
48
|
+
return <Button>Continue to checkout</Button>
|
|
49
|
+
}
|
|
70
50
|
```
|
|
71
51
|
|
|
72
|
-
|
|
52
|
+
## Brands and modes
|
|
73
53
|
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
54
|
+
Brand selection uses `data-theme` on `html`; mode uses one `.light` or `.dark`
|
|
55
|
+
class. Every brand sets `data-theme`; Business is the default. The
|
|
56
|
+
attribute-less `:root` / `@theme` layer is the shared token foundation the
|
|
57
|
+
brands override, not a brand. The source registry is
|
|
58
|
+
[src/theme/theme-config.ts](src/theme/theme-config.ts).
|
|
77
59
|
|
|
78
|
-
|
|
79
|
-
|
|
60
|
+
| Brand | Root attribute | Modes |
|
|
61
|
+
| --- | --- | --- |
|
|
62
|
+
| business (default) | `data-theme="business"` | light only |
|
|
63
|
+
| akros | `data-theme="akros"` | light only |
|
|
64
|
+
| n1 | `data-theme="n1"` | light only |
|
|
80
65
|
|
|
81
|
-
|
|
66
|
+
For a fixed Akros app, use `<html lang="en" class="light" data-theme="akros">`.
|
|
67
|
+
No provider is needed for a fixed theme. Do not create an Akros dark scheme.
|
|
82
68
|
|
|
69
|
+
For optional persisted switching, create an app client wrapper:
|
|
83
70
|
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
```tsx
|
|
72
|
+
'use client'
|
|
86
73
|
|
|
87
|
-
|
|
74
|
+
import type { PropsWithChildren } from 'react'
|
|
75
|
+
import { AppThemeProvider, BrandThemeScript } from '@techsio/ui-kit/theme/theme-provider'
|
|
88
76
|
|
|
89
|
-
|
|
77
|
+
export function ThemeSetup({ children }: PropsWithChildren) {
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<BrandThemeScript defaultBrand="akros" />
|
|
81
|
+
<AppThemeProvider defaultBrand="akros" defaultMode="light">
|
|
82
|
+
{children}
|
|
83
|
+
</AppThemeProvider>
|
|
84
|
+
</>
|
|
85
|
+
)
|
|
86
|
+
}
|
|
87
|
+
```
|
|
90
88
|
|
|
91
|
-
|
|
89
|
+
Render the script before visible body content. The provider applies mode
|
|
90
|
+
initialization and locks light-only brands to light. Defaults are fallbacks to
|
|
91
|
+
persisted preferences, not forced-brand configuration. `useAppTheme()` from the
|
|
92
|
+
same subpath exposes selection, allowed modes and `mounted`; gate
|
|
93
|
+
preference-dependent markup on `mounted` during SSR. Next App Router layouts
|
|
94
|
+
place the wrapper in `body` and use `suppressHydrationWarning` on `html` because
|
|
95
|
+
pre-hydration scripts update its attributes.
|
|
96
|
+
|
|
97
|
+
Hook/context/event-owning published entrypoints are client boundaries. Compose
|
|
98
|
+
compound static members such as `Dialog.Trigger` inside an app client wrapper;
|
|
99
|
+
do not access those members on a client reference from a server page. Callbacks
|
|
100
|
+
and render functions belong in client code. Ordinary SSR and RSC are separate
|
|
101
|
+
integration contracts.
|
|
102
|
+
|
|
103
|
+
## Source layout and token ownership
|
|
104
|
+
|
|
105
|
+
```text
|
|
106
|
+
libs/ui/
|
|
107
|
+
src/{atoms,molecules,organisms,templates}/ component modules (flat files)
|
|
108
|
+
src/theme/ registry, provider, togglers
|
|
109
|
+
src/tokens/ primitive and semantic layers
|
|
110
|
+
src/tokens/components/{atoms,molecules}/ component reference/derived aliases
|
|
111
|
+
src/tokens/figma/ generated exports; do not hand-edit
|
|
112
|
+
stories/{atoms,molecules,organisms,templates,pages}/
|
|
113
|
+
.storybook/ catalog and consumer onboarding
|
|
114
|
+
```
|
|
92
115
|
|
|
93
|
-
-
|
|
94
|
-
|
|
95
|
-
-
|
|
96
|
-
|
|
97
|
-
- **Using Tailwind’s `@theme`:**
|
|
98
|
-
Our CSS token files use Tailwind’s `@theme` block to generate CSS variables, ensuring consistency with our Tailwind utilities.
|
|
116
|
+
Public imports use `@techsio/ui-kit/<category>/<component>`, not these source
|
|
117
|
+
paths. Built-in brands come from the registry and generated theme mappings;
|
|
118
|
+
there is no library `brands/customer-a` directory. Product-specific composites
|
|
119
|
+
and app-only overrides stay in the consuming app.
|
|
99
120
|
|
|
100
|
-
|
|
121
|
+
Token flow is primitive → semantic → component reference → derived utility.
|
|
122
|
+
Components use component token classes in `tv()`; stories can use semantic
|
|
123
|
+
layout tokens. Keep changes general rather than adding brand-specific component
|
|
124
|
+
branches. App-owned CSS loads **after** the kit and overrides the active root
|
|
125
|
+
selector or a descendant scope with adequate specificity:
|
|
101
126
|
|
|
102
|
-
|
|
103
|
-
-
|
|
127
|
+
```css
|
|
128
|
+
.order-form {
|
|
129
|
+
--font-weight-button: var(--font-weight-bold);
|
|
130
|
+
}
|
|
131
|
+
```
|
|
104
132
|
|
|
105
|
-
|
|
133
|
+
Do not edit generated Figma CSS or copy all kit variables into app overrides.
|
|
134
|
+
See [app token initialization](skills/app-token-initialization/SKILL.md) and
|
|
135
|
+
[framework integration](skills/framework-consumer-integration/SKILL.md).
|
|
106
136
|
|
|
107
137
|
### Component font-weight overrides
|
|
108
138
|
|
|
@@ -134,52 +164,8 @@ When Figma exports the aliases, transfer ownership through the export pipeline
|
|
|
134
164
|
and remove the duplicate bridge declarations. Do not edit generated
|
|
135
165
|
`tokens/figma/variables.css` by hand.
|
|
136
166
|
|
|
137
|
-
## 5. Development Guidelines
|
|
138
|
-
|
|
139
|
-
### Component Development
|
|
140
|
-
|
|
141
|
-
- **Use Tokens Exclusively:**
|
|
142
|
-
Always use component tokens (e.g. `-button-bg`) in your styles. Do not use semantic tokens directly in component code.
|
|
143
|
-
- **Keep It Simple:**
|
|
144
|
-
Build your atoms and molecules first. Organisms are domain-specific composites and should use the shared atoms/molecules.
|
|
145
|
-
- **Export Only Where Appropriate:**
|
|
146
|
-
For example, if a component is basic (like a Button), it belongs in atoms or molecules. Never export a Button from an organism.
|
|
147
|
-
|
|
148
|
-
### Brand Customizations
|
|
149
|
-
|
|
150
|
-
- **Custom Components:**
|
|
151
|
-
If a customer needs a completely custom component, add it to the `brands/` folder. Do not modify the core shared components.
|
|
152
|
-
- **Override Process:**
|
|
153
|
-
When overriding, create a file in the brand folder and map the semantic tokens to the custom values. This way, the core remains untouched.
|
|
154
|
-
|
|
155
|
-
### Documentation
|
|
156
|
-
|
|
157
|
-
- We use **Storybook** for our component documentation and previews (for now). We may add other documentation tools later.
|
|
158
|
-
- Our documentation explains all tokens, component usage, and override guidelines. Please refer to Storybook for live examples and further details.
|
|
159
167
|
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
## 6. Quick Reference
|
|
163
|
-
|
|
164
|
-
- **Design Tokens:**
|
|
165
|
-
- Global Tokens: Defined in `tokens/_*.css` files.
|
|
166
|
-
- Semantic Tokens: Map global tokens to design roles (e.g. `-color-brand-primary`).
|
|
167
|
-
- Component Tokens: Defined centrally; used in component styling (e.g. `-button-bg`).
|
|
168
|
-
- **Folder Organization:**
|
|
169
|
-
- **Atoms/Molecules:** `ui/atoms/` and `ui/molecules/`
|
|
170
|
-
- **Organisms:** Domain-based (e.g. `ui/organisms/cart/`)
|
|
171
|
-
- **Brands:** Overrides and customizations (e.g. `ui/brands/customer-a/`)
|
|
172
|
-
- **Theming:**
|
|
173
|
-
|
|
174
|
-
Import tokens first, then any default or brand-specific theme overrides in your main CSS file.
|
|
175
|
-
|
|
176
|
-
- **Guidelines:**
|
|
177
|
-
- Always use the token system.
|
|
178
|
-
- Never mix token definitions with component code.
|
|
179
|
-
- Keep overrides in dedicated brand folders.
|
|
180
|
-
- Basic components (e.g., Button) belong only in atoms/molecules.
|
|
181
|
-
|
|
182
|
-
## 7. Visual Regression Tests (Playwright + Docker)
|
|
168
|
+
## Visual regression tests (Playwright + Docker)
|
|
183
169
|
|
|
184
170
|
To keep screenshots stable across machines, run component tests inside Docker.
|
|
185
171
|
|
|
@@ -211,16 +197,16 @@ Optional environment overrides:
|
|
|
211
197
|
- `TEST_BASE_URL` (default: `http://127.0.0.1:6006` inside the container)
|
|
212
198
|
- `PLAYWRIGHT_STORYBOOK_REBUILD` (default: `1`, rebuilds `storybook-static`; set to `0` to reuse an existing build)
|
|
213
199
|
- `VISUAL_STORYBOOK_STATIC_DIR` (absolute path to another Storybook build, e.g. one built from `master`, to test against the committed baselines; skips the rebuild)
|
|
214
|
-
- `VISUAL_BRANDS` (default: `
|
|
200
|
+
- `VISUAL_BRANDS` (default: `business,akros,n1`; focused development only)
|
|
215
201
|
- `TEST_STORIES` (comma-separated Storybook story ids to run, e.g. `atoms-button--states,molecules-productcard--layout-variants`)
|
|
216
202
|
- `PLAYWRIGHT_WORKERS` (override worker count for parallel runs)
|
|
217
203
|
- `VISUAL_ASSET_HAR_PATH` (absolute path to an alternative HAR; its directory and attachments mount read-only)
|
|
218
|
-
- `PLAYWRIGHT_DOCKER_IMAGE` (default: `new-engine-ui-playwright
|
|
204
|
+
- `PLAYWRIGHT_DOCKER_IMAGE` (default: `new-engine-ui-playwright:<Playwright version>-<Dockerfile hash>`)
|
|
219
205
|
- `PLAYWRIGHT_DOCKER_SHM_SIZE` (default: `2g`, improves Playwright stability in Docker)
|
|
220
206
|
- `PLAYWRIGHT_DOCKER_IPC` (default: `host`, improves Playwright stability in Docker)
|
|
221
207
|
- `PLAYWRIGHT_DOCKER_SEQUENTIAL` (default: `0`, runs projects in parallel; set to `1` to run one project at a time and reduce memory spikes)
|
|
222
208
|
|
|
223
|
-
Extra arguments are passed to `playwright test`, e.g. `pnpm -C libs/ui test:components -- --project=
|
|
209
|
+
Extra arguments are passed to `playwright test`, e.g. `pnpm -C libs/ui test:components -- --project=n1-mobile-light`.
|
|
224
210
|
Tests always run as `linux/amd64`, matching the committed baselines. A full run must cover every story in every visual project; component behavior specs (`test/*.spec.ts`) run once in the `desktop` and `mobile` projects.
|
|
225
211
|
|
|
226
212
|
### Recommendation for `PLAYWRIGHT_WORKERS` and parallelism
|
|
@@ -238,18 +224,27 @@ Example with parallel workers:
|
|
|
238
224
|
TEST_BASE_URL=http://127.0.0.1:6006 PLAYWRIGHT_WORKERS=6 pnpm -C libs/ui test:components
|
|
239
225
|
```
|
|
240
226
|
|
|
241
|
-
|
|
227
|
+
### Release coverage versus focused development
|
|
228
|
+
|
|
229
|
+
`pnpm -C libs/ui test:components:release` requires all stories across all 6
|
|
230
|
+
visual projects: business/Akros/N1 light, desktop+mobile.
|
|
231
|
+
It rejects brand overrides, story/project filters and snapshot updates, then
|
|
232
|
+
checks unique successful story/project identities. Focused `test:components`
|
|
233
|
+
runs remain available but are not release-readiness evidence. Review new or
|
|
234
|
+
changed baselines; never update them in the validation gate.
|
|
235
|
+
|
|
236
|
+
During a shared-browser overhaul, follow the assigned browser rules instead of
|
|
237
|
+
starting any local server, build or browser. Use the approved shared `ds-page`
|
|
238
|
+
and serial Docker wrapper, never concurrent ad hoc browser launches.
|
|
239
|
+
|
|
240
|
+
## Publishing and releases
|
|
242
241
|
|
|
243
242
|
- Build: `pnpm -C libs/ui build` creates the package without release-only validation.
|
|
244
|
-
- Package output checks: `pnpm -C libs/ui check:package` builds, runs publint against package structure and exports, and runs AreTheTypesWrong across TypeScript module-resolution modes. CI and the release workflow run this command automatically.
|
|
243
|
+
- Package output checks: `pnpm -C libs/ui check:package` builds, runs publint against package structure and exports, and runs AreTheTypesWrong across TypeScript module-resolution modes, verifies emitted client boundaries/compound declarations, and checks CSS generation, SSR and public callback types from a packed installation. CI and the release workflow run this command automatically.
|
|
245
244
|
- Exports only, no barrel: import from explicit subpaths (e.g. `@techsio/ui-kit/atoms/button`, `@techsio/ui-kit/templates/accordion`, `@techsio/ui-kit/utils`). The package root is intentionally not exported.
|
|
246
245
|
- Automated releases: `libs/ui/release.config.mjs` uses semantic-release (tag format `ui-kit-v<version>`) to publish to npm and create GitHub releases without pushing generated version/changelog commits back to the protected branch. While we are <1.0.0, `BREAKING CHANGE` commits are forced to “minor” bumps to stay in 0.x; remove that release rule when stabilizing for 1.0.0+ to restore SemVer majors.
|
|
247
246
|
- Security posture: releases are restricted to GitHub Actions (`GITHUB_ACTIONS` required), npm publishes use trusted publishing through GitHub OIDC (`id-token: write`) and do not require an npm token.
|
|
248
|
-
- CI
|
|
249
|
-
- Local dry
|
|
247
|
+
- CI and release share `.github/workflows/ui-quality.yml`: both TypeScript projects, unit/SSR/tooling tests, token/package checks, full Docker component visuals, and enforced three-theme accessibility. Publication depends on successful validation of the exact checked-out SHA. Manual `force_release` changes affected detection only; it cannot bypass quality checks.
|
|
248
|
+
- Local semantic-release (including `--dry-run`) is intentionally unsupported. Use `pnpm -C libs/ui typecheck`, `test`, and `check:package` locally; never set `GITHUB_ACTIONS=true` to impersonate CI.
|
|
250
249
|
- Commit format: follow Conventional Commits (`feat:`, `fix:`, `chore:`, `BREAKING CHANGE:`) so semantic-release can infer the correct version bump.
|
|
251
250
|
- Required CI secrets: none for npm publishing; npm trusted publishing must be configured on npmjs.com for this repository and workflow path.
|
|
252
|
-
|
|
253
|
-
## 9. Conclusion
|
|
254
|
-
|
|
255
|
-
This README serves as the single source of truth for building and maintaining our design system. By adhering to these guidelines, you ensure that our UI remains consistent, flexible, and scalable across multiple brands. If you have any questions or suggestions, please reach out to the design system team.
|
|
@@ -4,7 +4,7 @@ import { Icon } from "./icon.js";
|
|
|
4
4
|
const actionIconVariants = tv({
|
|
5
5
|
base: [
|
|
6
6
|
"inline-flex shrink-0 cursor-pointer items-center justify-center",
|
|
7
|
-
"rounded-icon-control text-icon-control-fg",
|
|
7
|
+
"action-icon-surface rounded-icon-control text-icon-control-fg",
|
|
8
8
|
"transition-colors duration-200 motion-reduce:transition-none",
|
|
9
9
|
"focus-visible:outline-(style:--default-ring-style) focus-visible:outline-(length:--default-ring-width)",
|
|
10
10
|
"focus-visible:outline-offset-(length:--default-ring-offset) focus-visible:outline-icon-control-ring",
|
|
@@ -12,18 +12,19 @@ const actionIconVariants = tv({
|
|
|
12
12
|
],
|
|
13
13
|
variants: {
|
|
14
14
|
size: {
|
|
15
|
-
sm: "size-icon-control-sm text-icon-
|
|
16
|
-
md: "size-icon-control-md text-icon-
|
|
17
|
-
lg: "size-icon-
|
|
15
|
+
sm: "size-icon-control-sm text-action-icon-sm",
|
|
16
|
+
md: "size-icon-control-md text-action-icon-md",
|
|
17
|
+
lg: "size-action-icon-lg text-action-icon-lg"
|
|
18
18
|
},
|
|
19
19
|
tone: {
|
|
20
20
|
neutral: [
|
|
21
|
-
"hover:bg-icon-control-bg-hover",
|
|
22
|
-
"active:bg-icon-control-bg-active"
|
|
21
|
+
"not-disabled:hover:bg-icon-control-bg-hover",
|
|
22
|
+
"not-disabled:active:bg-icon-control-bg-active"
|
|
23
23
|
],
|
|
24
24
|
danger: [
|
|
25
|
-
"
|
|
26
|
-
"
|
|
25
|
+
"text-action-icon-fg-danger",
|
|
26
|
+
"not-disabled:hover:bg-icon-control-bg-danger-hover not-disabled:hover:text-icon-control-fg-danger-hover",
|
|
27
|
+
"not-disabled:active:bg-action-icon-bg-danger-active not-disabled:active:text-action-icon-fg-danger-active"
|
|
27
28
|
]
|
|
28
29
|
}
|
|
29
30
|
},
|
package/dist/atoms/button.js
CHANGED
|
@@ -1,19 +1,31 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useImperativeHandle, useRef } from "react";
|
|
2
4
|
import { tv } from "../utils.js";
|
|
3
5
|
import { Icon } from "./icon.js";
|
|
4
6
|
const buttonVariants = tv({
|
|
5
7
|
base: [
|
|
6
|
-
"relative",
|
|
8
|
+
"button-disabled relative",
|
|
7
9
|
"inline-flex cursor-pointer items-center justify-center",
|
|
8
|
-
"font-button",
|
|
9
10
|
"transition duration-200 motion-reduce:transition-none",
|
|
10
|
-
"motion-safe:not-disabled:active:scale-97",
|
|
11
11
|
"focus-visible:outline-(style:--default-ring-style) focus-visible:outline-(length:--default-ring-width)",
|
|
12
12
|
"focus-visible:outline-button-ring",
|
|
13
13
|
"focus-visible:outline-offset-(length:--default-ring-offset)",
|
|
14
|
-
"disabled:cursor-not-allowed disabled:text-button-fg-disabled"
|
|
14
|
+
"disabled:cursor-not-allowed disabled:text-button-fg-disabled",
|
|
15
|
+
"not-disabled:data-loading:cursor-progress"
|
|
15
16
|
],
|
|
16
17
|
variants: {
|
|
18
|
+
composition: {
|
|
19
|
+
true: "",
|
|
20
|
+
false: [
|
|
21
|
+
"font-button",
|
|
22
|
+
"motion-safe:not-disabled:not-data-disabled:not-data-loading:active:scale-97"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
density: {
|
|
26
|
+
default: "",
|
|
27
|
+
compact: ""
|
|
28
|
+
},
|
|
17
29
|
variant: {
|
|
18
30
|
primary: "",
|
|
19
31
|
secondary: "",
|
|
@@ -24,24 +36,54 @@ const buttonVariants = tv({
|
|
|
24
36
|
theme: {
|
|
25
37
|
solid: "disabled:bg-button-bg-disabled",
|
|
26
38
|
light: "disabled:bg-button-bg-disabled",
|
|
27
|
-
borderless: "bg-button-bg-borderless-base hover:bg-button-bg-borderless-hover active:bg-button-bg-borderless-active
|
|
28
|
-
outlined: "
|
|
39
|
+
borderless: "button-disabled-borderless bg-button-bg-borderless-base hover:bg-button-bg-borderless-hover hover:text-button-fg-interacting active:bg-button-bg-borderless-active active:text-button-fg-interacting",
|
|
40
|
+
outlined: "button-disabled-outlined border bg-button-bg-outlined",
|
|
29
41
|
unstyled: ""
|
|
30
42
|
},
|
|
31
43
|
uppercase: {
|
|
32
44
|
true: "uppercase"
|
|
33
45
|
},
|
|
34
46
|
size: {
|
|
35
|
-
sm: "
|
|
36
|
-
md: "
|
|
37
|
-
lg: "
|
|
38
|
-
current: "gap-button-md
|
|
47
|
+
sm: "min-w-0 gap-button-sm rounded-button-sm text-button-sm",
|
|
48
|
+
md: "min-w-0 gap-button-md rounded-button-md text-button-md",
|
|
49
|
+
lg: "min-w-0 gap-button-lg rounded-button-lg text-button-lg",
|
|
50
|
+
current: "button-current-size gap-button-md"
|
|
39
51
|
},
|
|
40
52
|
block: {
|
|
41
53
|
true: "w-full"
|
|
42
54
|
}
|
|
43
55
|
},
|
|
44
56
|
compoundVariants: [
|
|
57
|
+
{
|
|
58
|
+
density: "default",
|
|
59
|
+
size: "sm",
|
|
60
|
+
className: "button-size-sm p-button-sm"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
density: "default",
|
|
64
|
+
size: "md",
|
|
65
|
+
className: "button-size-md p-button-md"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
density: "default",
|
|
69
|
+
size: "lg",
|
|
70
|
+
className: "button-size-lg p-button-lg"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
density: "compact",
|
|
74
|
+
size: "sm",
|
|
75
|
+
className: "h-button-compact-sm p-button-compact-sm"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
density: "compact",
|
|
79
|
+
size: "md",
|
|
80
|
+
className: "h-button-compact-md p-button-compact-md"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
density: "compact",
|
|
84
|
+
size: "lg",
|
|
85
|
+
className: "h-button-compact-lg p-button-compact-lg"
|
|
86
|
+
},
|
|
45
87
|
{
|
|
46
88
|
variant: "primary",
|
|
47
89
|
theme: "solid",
|
|
@@ -217,7 +259,7 @@ const buttonVariants = tv({
|
|
|
217
259
|
variant: "warning",
|
|
218
260
|
theme: "borderless",
|
|
219
261
|
className: [
|
|
220
|
-
"text-button-fg-warning-
|
|
262
|
+
"text-button-fg-warning-readable"
|
|
221
263
|
]
|
|
222
264
|
},
|
|
223
265
|
{
|
|
@@ -244,43 +286,97 @@ const buttonVariants = tv({
|
|
|
244
286
|
}
|
|
245
287
|
],
|
|
246
288
|
defaultVariants: {
|
|
289
|
+
composition: false,
|
|
290
|
+
density: "default",
|
|
247
291
|
variant: "primary",
|
|
248
292
|
theme: "solid",
|
|
249
293
|
size: "md",
|
|
250
294
|
light: false
|
|
251
295
|
}
|
|
252
296
|
});
|
|
253
|
-
|
|
254
|
-
|
|
297
|
+
const buttonIconVariants = tv({
|
|
298
|
+
variants: {
|
|
299
|
+
size: {
|
|
300
|
+
sm: "text-button-icon-sm",
|
|
301
|
+
md: "text-button-icon-md",
|
|
302
|
+
lg: "text-button-icon-lg",
|
|
303
|
+
current: ""
|
|
304
|
+
}
|
|
305
|
+
},
|
|
306
|
+
defaultVariants: {
|
|
307
|
+
size: "md"
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
function Button({ density, variant, theme, size, block, isLoading, loadingText, icon, iconPosition = "left", iconSize, uppercase = false, children, className, disabled, composition, ref, onClick, type = "button", ...props }) {
|
|
311
|
+
const buttonRef = useRef(null);
|
|
312
|
+
useImperativeHandle(ref, ()=>buttonRef.current, []);
|
|
313
|
+
useEffect(()=>{
|
|
314
|
+
const button = buttonRef.current;
|
|
315
|
+
const form = button?.form;
|
|
316
|
+
if (!(isLoading && "submit" === type && form)) return;
|
|
317
|
+
function preventPendingSubmit(event) {
|
|
318
|
+
if (!event.submitter || event.submitter === button) {
|
|
319
|
+
event.preventDefault();
|
|
320
|
+
event.stopImmediatePropagation();
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
form.addEventListener("submit", preventPendingSubmit, true);
|
|
324
|
+
return ()=>form.removeEventListener("submit", preventPendingSubmit, true);
|
|
325
|
+
}, [
|
|
326
|
+
isLoading,
|
|
327
|
+
type,
|
|
328
|
+
props.form
|
|
329
|
+
]);
|
|
330
|
+
const iconClassName = buttonIconVariants({
|
|
331
|
+
size
|
|
332
|
+
});
|
|
255
333
|
return /*#__PURE__*/ jsx("button", {
|
|
334
|
+
...props,
|
|
335
|
+
"aria-busy": isLoading || void 0,
|
|
336
|
+
"aria-disabled": disabled || isLoading || props["aria-disabled"] || void 0,
|
|
256
337
|
className: buttonVariants({
|
|
338
|
+
density,
|
|
257
339
|
variant,
|
|
258
340
|
theme,
|
|
259
341
|
size,
|
|
260
342
|
block,
|
|
261
343
|
uppercase,
|
|
344
|
+
composition,
|
|
262
345
|
className
|
|
263
346
|
}),
|
|
347
|
+
"data-loading": isLoading ? "" : void 0,
|
|
264
348
|
disabled: disabled,
|
|
265
|
-
|
|
349
|
+
onClick: (event)=>{
|
|
350
|
+
if (isLoading) {
|
|
351
|
+
event.preventDefault();
|
|
352
|
+
event.stopPropagation();
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
onClick?.(event);
|
|
356
|
+
},
|
|
357
|
+
ref: buttonRef,
|
|
358
|
+
type: type,
|
|
266
359
|
children: isLoading ? /*#__PURE__*/ jsxs(Fragment, {
|
|
267
360
|
children: [
|
|
268
361
|
/*#__PURE__*/ jsx(Icon, {
|
|
269
|
-
className:
|
|
270
|
-
icon: "token-icon-button-spinner"
|
|
362
|
+
className: iconClassName,
|
|
363
|
+
icon: "token-icon-button-spinner",
|
|
364
|
+
size: "current"
|
|
271
365
|
}),
|
|
272
366
|
loadingText || children
|
|
273
367
|
]
|
|
274
368
|
}) : /*#__PURE__*/ jsxs(Fragment, {
|
|
275
369
|
children: [
|
|
276
370
|
icon && "left" === iconPosition && /*#__PURE__*/ jsx(Icon, {
|
|
371
|
+
className: iconSize ? void 0 : iconClassName,
|
|
277
372
|
icon: icon,
|
|
278
|
-
size: iconSize
|
|
373
|
+
size: iconSize ?? "current"
|
|
279
374
|
}),
|
|
280
375
|
children,
|
|
281
376
|
icon && "right" === iconPosition && /*#__PURE__*/ jsx(Icon, {
|
|
377
|
+
className: iconSize ? void 0 : iconClassName,
|
|
282
378
|
icon: icon,
|
|
283
|
-
size: iconSize
|
|
379
|
+
size: iconSize ?? "current"
|
|
284
380
|
})
|
|
285
381
|
]
|
|
286
382
|
})
|