@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/dist/atoms/rating.js
CHANGED
|
@@ -1,130 +1,363 @@
|
|
|
1
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { connect, machine } from "@zag-js/rating-group";
|
|
2
4
|
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
3
|
-
import { useId } from "react";
|
|
5
|
+
import { useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
6
|
+
import { isSilentChoiceReset, runSilentChoiceReset, trackChoiceFormControl, useChoiceFocusRecovery } from "../internal/choice-control.js";
|
|
7
|
+
import { joinDescribedBy } from "../internal/described-by.js";
|
|
8
|
+
import { isEffectivelyDisabled, syncReactFormControl } from "../internal/form-control-lifecycle.js";
|
|
9
|
+
import { useEffectiveDisabled } from "../internal/use-effective-disabled.js";
|
|
4
10
|
import { tv } from "../utils.js";
|
|
5
11
|
import { Label } from "./label.js";
|
|
6
|
-
import
|
|
12
|
+
import { StatusText } from "./status-text.js";
|
|
13
|
+
function normalizeRating(value, count, allowHalf, readOnly) {
|
|
14
|
+
const bounded = Math.max(0, Math.min(count, Number.isFinite(value) ? value : 0));
|
|
15
|
+
if (readOnly) return bounded;
|
|
16
|
+
const step = allowHalf ? 2 : 1;
|
|
17
|
+
return Math.round(bounded * step) / step;
|
|
18
|
+
}
|
|
19
|
+
const ratingValueActions = machine.implementations?.actions ?? {};
|
|
20
|
+
const guardRatingAction = (action)=>(params)=>{
|
|
21
|
+
const root = params.scope.getById(params.scope.ids?.root ?? `rating:${params.scope.id}`);
|
|
22
|
+
if (params.prop("readOnly") || isEffectivelyDisabled(root, params.prop("disabled"))) return;
|
|
23
|
+
action?.(params);
|
|
24
|
+
};
|
|
25
|
+
const ratingResetValues = new WeakMap();
|
|
26
|
+
const ratingFocusRequests = new WeakMap();
|
|
27
|
+
const ratingChoiceMachine = {
|
|
28
|
+
...machine,
|
|
29
|
+
watch ({ track, action, prop, context, scope }) {
|
|
30
|
+
track([
|
|
31
|
+
()=>prop("count"),
|
|
32
|
+
()=>prop("allowHalf"),
|
|
33
|
+
()=>prop("readOnly")
|
|
34
|
+
], ()=>{
|
|
35
|
+
action([
|
|
36
|
+
"clearHoveredValue"
|
|
37
|
+
]);
|
|
38
|
+
if (void 0 !== prop("value")) return;
|
|
39
|
+
const value = normalizeRating(context.get("value"), prop("count"), !!prop("allowHalf"), !!prop("readOnly"));
|
|
40
|
+
if (value !== context.get("value")) context.set("value", value);
|
|
41
|
+
});
|
|
42
|
+
track([
|
|
43
|
+
()=>context.get("value")
|
|
44
|
+
], ()=>{
|
|
45
|
+
const resetValue = ratingResetValues.get(context);
|
|
46
|
+
ratingResetValues.delete(context);
|
|
47
|
+
if (resetValue === context.get("value")) {
|
|
48
|
+
const input = scope.getById(scope.ids?.hiddenInput ?? `rating:${scope.id}:input`);
|
|
49
|
+
if (input) syncReactFormControl(input, String(resetValue));
|
|
50
|
+
} else action([
|
|
51
|
+
"dispatchChangeEvent"
|
|
52
|
+
]);
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
implementations: {
|
|
56
|
+
...machine.implementations,
|
|
57
|
+
actions: {
|
|
58
|
+
...ratingValueActions,
|
|
59
|
+
setPrevValue: guardRatingAction(ratingValueActions.setPrevValue),
|
|
60
|
+
setNextValue: guardRatingAction(ratingValueActions.setNextValue),
|
|
61
|
+
setValueToMin: guardRatingAction(ratingValueActions.setValueToMin),
|
|
62
|
+
setValueToMax: guardRatingAction(ratingValueActions.setValueToMax),
|
|
63
|
+
setValue: guardRatingAction(ratingValueActions.setValue),
|
|
64
|
+
clearValue: guardRatingAction(ratingValueActions.clearValue),
|
|
65
|
+
setHoveredValue: guardRatingAction(ratingValueActions.setHoveredValue),
|
|
66
|
+
focusActiveRadio (params) {
|
|
67
|
+
if (void 0 !== params.prop("value")) return void ratingValueActions.focusActiveRadio?.(params);
|
|
68
|
+
ratingFocusRequests.get(params.context)?.();
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
effects: {
|
|
72
|
+
...machine.implementations?.effects,
|
|
73
|
+
trackFormControlState ({ scope, context, prop }) {
|
|
74
|
+
const root = scope.getById(scope.ids?.root ?? `rating:${scope.id}`);
|
|
75
|
+
return trackChoiceFormControl(root, ()=>{
|
|
76
|
+
if (void 0 === prop("value")) {
|
|
77
|
+
const restoredValue = normalizeRating(context.initial("value"), prop("count"), !!prop("allowHalf"), !!prop("readOnly"));
|
|
78
|
+
ratingResetValues.set(context, restoredValue);
|
|
79
|
+
runSilentChoiceReset(context, ()=>context.set("value", restoredValue));
|
|
80
|
+
} else {
|
|
81
|
+
const input = root?.querySelector("input");
|
|
82
|
+
if (input) input.value = String(context.get("value"));
|
|
83
|
+
}
|
|
84
|
+
}, (disabled)=>context.set("fieldsetDisabled", disabled));
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
7
89
|
const rating = tv({
|
|
8
90
|
slots: {
|
|
9
|
-
root:
|
|
10
|
-
|
|
91
|
+
root: "grid min-w-0 max-w-full items-center",
|
|
92
|
+
control: "rating-readonly form-control-readonly focus-visible:rating-focus-outline inline-flex w-fit max-w-full flex-wrap items-center",
|
|
93
|
+
item: [
|
|
94
|
+
"rating-item-fluid inline-grid min-h-rating-target place-items-center",
|
|
95
|
+
"cursor-pointer data-disabled:cursor-not-allowed",
|
|
96
|
+
"focus-visible:rating-focus-outline"
|
|
11
97
|
],
|
|
12
|
-
|
|
13
|
-
"
|
|
98
|
+
glyph: [
|
|
99
|
+
"token-icon-rating pointer-events-none col-start-1 row-start-1 text-rating-fg-empty",
|
|
100
|
+
"transition-colors duration-200 motion-reduce:transition-none",
|
|
101
|
+
"data-highlighted:not-data-half:token-icon-rating-selected data-highlighted:not-data-disabled:text-rating-fg-selected",
|
|
102
|
+
"data-half:token-icon-rating-half rtl:data-half:-scale-x-100",
|
|
103
|
+
"data-disabled:text-rating-fg-disabled"
|
|
14
104
|
],
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"has-focus-visible:outline-rating-ring",
|
|
19
|
-
"has-focus-visible:outline-offset-(length:--default-ring-offset)"
|
|
105
|
+
fractionalGlyph: [
|
|
106
|
+
"token-icon-rating-selected rating-fractional-fill pointer-events-none col-start-1 row-start-1 text-rating-fg-selected",
|
|
107
|
+
"data-disabled:text-rating-fg-disabled"
|
|
20
108
|
],
|
|
21
|
-
|
|
22
|
-
"cursor-pointer transition-colors duration-200",
|
|
23
|
-
"cursor-pointer transition-colors duration-200 motion-reduce:transition-none",
|
|
24
|
-
"text-rating-fg-base",
|
|
25
|
-
"data-highlighted:text-rating-fg-active",
|
|
26
|
-
"data-disabled:cursor-not-allowed",
|
|
27
|
-
"data-disabled:data-highlighted:text-rating-fg-disabled",
|
|
28
|
-
"token-icon-rating",
|
|
29
|
-
"data-half:token-icon-rating-half"
|
|
30
|
-
]
|
|
109
|
+
valueText: "text-rating-fg-selected text-rating-value tabular-nums data-disabled:text-rating-fg-disabled"
|
|
31
110
|
},
|
|
32
111
|
variants: {
|
|
33
112
|
size: {
|
|
34
113
|
sm: {
|
|
35
114
|
root: "gap-rating-sm",
|
|
36
|
-
control: "gap-rating-sm",
|
|
37
|
-
item: "text-rating-sm"
|
|
115
|
+
control: "gap-rating-control-sm",
|
|
116
|
+
item: "text-rating-sm",
|
|
117
|
+
glyph: "text-rating-sm",
|
|
118
|
+
fractionalGlyph: "text-rating-sm"
|
|
38
119
|
},
|
|
39
120
|
md: {
|
|
40
121
|
root: "gap-rating-md",
|
|
41
|
-
control: "gap-rating-md",
|
|
42
|
-
item: "text-rating-md"
|
|
122
|
+
control: "gap-rating-control-md",
|
|
123
|
+
item: "text-rating-md",
|
|
124
|
+
glyph: "text-rating-md",
|
|
125
|
+
fractionalGlyph: "text-rating-md"
|
|
43
126
|
},
|
|
44
127
|
lg: {
|
|
45
128
|
root: "gap-rating-lg",
|
|
46
|
-
control: "gap-rating-lg",
|
|
47
|
-
item: "text-rating-lg"
|
|
129
|
+
control: "gap-rating-control-lg",
|
|
130
|
+
item: "text-rating-lg",
|
|
131
|
+
glyph: "text-rating-lg",
|
|
132
|
+
fractionalGlyph: "text-rating-lg"
|
|
48
133
|
}
|
|
49
134
|
},
|
|
50
|
-
|
|
51
|
-
true: {
|
|
52
|
-
false: {
|
|
135
|
+
isDisplay: {
|
|
136
|
+
true: {
|
|
53
137
|
item: "cursor-default"
|
|
54
|
-
}
|
|
138
|
+
},
|
|
139
|
+
false: {}
|
|
55
140
|
}
|
|
56
141
|
},
|
|
57
142
|
defaultVariants: {
|
|
58
143
|
size: "md"
|
|
59
144
|
}
|
|
60
145
|
});
|
|
61
|
-
function Rating({ value, defaultValue, count = 5, labelText, readOnly = false, disabled = false, allowHalf = true, name, dir = "ltr", translations, onChange, onHoverChange, size = "md", className, ...props }) {
|
|
146
|
+
function Rating({ value, defaultValue = 0, count = 5, labelText, readOnly: readOnlyProp = false, displayOnly = false, disabled: disabledProp = false, allowHalf = true, name, dir = "ltr", translations, helpText, validateStatus = "default", onChange, onHoverChange, size = "md", className, "aria-describedby": ariaDescribedBy, "aria-label": ariaLabel, "aria-labelledby": ariaLabelledBy, ...props }) {
|
|
147
|
+
const readOnly = readOnlyProp || displayOnly;
|
|
148
|
+
const [controlElement, setControlElement] = useState(null);
|
|
149
|
+
const disabled = useEffectiveDisabled(controlElement, disabledProp);
|
|
62
150
|
const generatedId = useId();
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
151
|
+
const helpTextId = useId();
|
|
152
|
+
const scoreId = useId();
|
|
153
|
+
const id = props.id || generatedId;
|
|
154
|
+
const invalid = "error" === validateStatus;
|
|
155
|
+
const describedBy = joinDescribedBy(ariaDescribedBy, scoreId, helpText ? helpTextId : void 0);
|
|
156
|
+
const errorMessageId = invalid && helpText ? helpTextId : void 0;
|
|
157
|
+
const interactive = !(readOnly || disabled);
|
|
158
|
+
const normalizedCount = Number.isFinite(count) ? Math.max(1, Math.floor(count)) : 5;
|
|
159
|
+
const focusRef = useChoiceFocusRecovery('[role="radio"]');
|
|
160
|
+
const [focusRequest, setFocusRequest] = useState(0);
|
|
161
|
+
const controlRef = useMemo(()=>(node)=>{
|
|
162
|
+
focusRef.current = node;
|
|
163
|
+
setControlElement(node);
|
|
164
|
+
}, [
|
|
165
|
+
focusRef
|
|
166
|
+
]);
|
|
167
|
+
const service = useMachine(ratingChoiceMachine, {
|
|
168
|
+
id,
|
|
169
|
+
count: normalizedCount,
|
|
170
|
+
value: void 0 === value ? void 0 : normalizeRating(value, normalizedCount, allowHalf, readOnly),
|
|
171
|
+
defaultValue: normalizeRating(defaultValue, normalizedCount, allowHalf, readOnly),
|
|
69
172
|
disabled,
|
|
70
|
-
readOnly,
|
|
173
|
+
readOnly: readOnly && !disabled,
|
|
71
174
|
allowHalf,
|
|
72
175
|
name,
|
|
73
176
|
dir,
|
|
74
177
|
translations,
|
|
75
178
|
onValueChange: ({ value: newValue })=>{
|
|
76
|
-
onChange?.(newValue);
|
|
179
|
+
if (interactive && !isSilentChoiceReset(service.context)) onChange?.(newValue);
|
|
77
180
|
},
|
|
78
181
|
onHoverChange: ({ hoveredValue })=>{
|
|
79
|
-
onHoverChange?.(hoveredValue);
|
|
182
|
+
if (interactive) onHoverChange?.(hoveredValue);
|
|
80
183
|
}
|
|
81
184
|
});
|
|
82
|
-
const api =
|
|
83
|
-
|
|
185
|
+
const api = connect(service, normalizeProps);
|
|
186
|
+
useLayoutEffect(()=>{
|
|
187
|
+
const machineContext = service.context;
|
|
188
|
+
ratingFocusRequests.set(machineContext, ()=>{
|
|
189
|
+
setFocusRequest((request)=>request + 1);
|
|
190
|
+
});
|
|
191
|
+
return ()=>{
|
|
192
|
+
ratingFocusRequests.delete(machineContext);
|
|
193
|
+
};
|
|
194
|
+
}, [
|
|
195
|
+
service.context
|
|
196
|
+
]);
|
|
197
|
+
const handledFocusRequest = useRef(focusRequest);
|
|
198
|
+
useLayoutEffect(()=>{
|
|
199
|
+
if (focusRequest === handledFocusRequest.current) return;
|
|
200
|
+
handledFocusRequest.current = focusRequest;
|
|
201
|
+
if (void 0 !== value || !interactive) return;
|
|
202
|
+
const checked = controlElement?.querySelector('[role="radio"][aria-checked="true"]');
|
|
203
|
+
if (checked && checked !== checked.ownerDocument.activeElement) checked.focus();
|
|
204
|
+
}, [
|
|
205
|
+
controlElement,
|
|
206
|
+
focusRequest,
|
|
207
|
+
interactive,
|
|
208
|
+
value
|
|
209
|
+
]);
|
|
210
|
+
const isDisplay = displayOnly;
|
|
211
|
+
const styles = rating({
|
|
84
212
|
size,
|
|
85
|
-
|
|
213
|
+
isDisplay
|
|
86
214
|
});
|
|
87
|
-
const isDisplay = readOnly && !disabled;
|
|
88
|
-
const valueLabel = `${labelText ? `${labelText}: ` : ""}${api.value} out of ${count}`;
|
|
89
215
|
return /*#__PURE__*/ jsxs("div", {
|
|
90
|
-
className: root({
|
|
216
|
+
className: styles.root({
|
|
91
217
|
className
|
|
92
218
|
}),
|
|
93
219
|
...api.getRootProps(),
|
|
94
220
|
...props,
|
|
221
|
+
"aria-disabled": disabled || void 0,
|
|
95
222
|
children: [
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
})
|
|
103
|
-
/*#__PURE__*/ jsx("input", {
|
|
104
|
-
...api.getHiddenInputProps()
|
|
223
|
+
/*#__PURE__*/ jsx(RatingLabel, {
|
|
224
|
+
api: api,
|
|
225
|
+
disabled: disabled,
|
|
226
|
+
isDisplay: isDisplay,
|
|
227
|
+
labelText: labelText,
|
|
228
|
+
size: size
|
|
229
|
+
}),
|
|
230
|
+
!displayOnly && /*#__PURE__*/ jsx("input", {
|
|
231
|
+
...api.getHiddenInputProps(),
|
|
232
|
+
defaultValue: void 0,
|
|
233
|
+
value: api.value
|
|
105
234
|
}),
|
|
106
235
|
/*#__PURE__*/ jsx("div", {
|
|
107
|
-
className: control(),
|
|
108
|
-
...isDisplay
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
236
|
+
className: styles.control(),
|
|
237
|
+
...getRatingControlProps(api, isDisplay, labelText, ariaLabel, ariaLabelledBy),
|
|
238
|
+
"aria-describedby": describedBy,
|
|
239
|
+
"aria-errormessage": errorMessageId,
|
|
240
|
+
"aria-invalid": invalid || void 0,
|
|
241
|
+
"data-disabled": disabled ? "" : void 0,
|
|
242
|
+
"data-readonly": readOnly && !(disabled || isDisplay) ? "" : void 0,
|
|
243
|
+
ref: controlRef,
|
|
244
|
+
children: /*#__PURE__*/ jsx(RatingItems, {
|
|
245
|
+
api: api,
|
|
246
|
+
describedBy: describedBy,
|
|
247
|
+
dir: dir,
|
|
248
|
+
errorMessageId: errorMessageId,
|
|
249
|
+
invalid: invalid,
|
|
250
|
+
isDisplay: isDisplay,
|
|
251
|
+
showExactValue: readOnly,
|
|
252
|
+
styles: styles,
|
|
253
|
+
translations: translations
|
|
254
|
+
})
|
|
255
|
+
}),
|
|
256
|
+
/*#__PURE__*/ jsx("span", {
|
|
257
|
+
className: styles.valueText(),
|
|
258
|
+
"data-disabled": disabled ? "" : void 0,
|
|
259
|
+
id: scoreId,
|
|
260
|
+
children: /*#__PURE__*/ jsxs("bdi", {
|
|
261
|
+
dir: "ltr",
|
|
262
|
+
children: [
|
|
263
|
+
Math.max(0, api.value),
|
|
264
|
+
" / ",
|
|
265
|
+
normalizedCount
|
|
266
|
+
]
|
|
267
|
+
})
|
|
268
|
+
}),
|
|
269
|
+
helpText && /*#__PURE__*/ jsx(StatusText, {
|
|
270
|
+
id: helpTextId,
|
|
271
|
+
size: size,
|
|
272
|
+
status: validateStatus,
|
|
273
|
+
children: helpText
|
|
123
274
|
})
|
|
124
275
|
]
|
|
125
276
|
});
|
|
126
277
|
}
|
|
278
|
+
function RatingLabel({ api, labelText, size, isDisplay, disabled }) {
|
|
279
|
+
if (!labelText) return null;
|
|
280
|
+
return isDisplay ? /*#__PURE__*/ jsx(Label, {
|
|
281
|
+
"aria-hidden": true,
|
|
282
|
+
size: size,
|
|
283
|
+
children: labelText
|
|
284
|
+
}) : /*#__PURE__*/ jsx(Label, {
|
|
285
|
+
disabled: disabled,
|
|
286
|
+
size: size,
|
|
287
|
+
...api.getLabelProps(),
|
|
288
|
+
children: labelText
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
function getRatingControlProps(api, isDisplay, labelText, ariaLabel, ariaLabelledBy) {
|
|
292
|
+
if (isDisplay) {
|
|
293
|
+
const label = labelText ?? ariaLabel;
|
|
294
|
+
return {
|
|
295
|
+
role: "img",
|
|
296
|
+
"aria-labelledby": ariaLabelledBy,
|
|
297
|
+
"aria-label": `${label ? `${label}: ` : ""}${Math.max(0, api.value)} out of ${api.count}`,
|
|
298
|
+
"aria-description": "Average rating"
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
const visibleLabelId = labelText && !ariaLabel ? api.getLabelProps().id : void 0;
|
|
302
|
+
return {
|
|
303
|
+
...api.getControlProps(),
|
|
304
|
+
"aria-label": ariaLabel ?? (labelText || ariaLabelledBy ? void 0 : "Rating"),
|
|
305
|
+
"aria-labelledby": ariaLabelledBy ?? visibleLabelId
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function RatingItems({ api, dir, styles, isDisplay, showExactValue, describedBy, errorMessageId, invalid, translations }) {
|
|
309
|
+
return /*#__PURE__*/ jsx(Fragment, {
|
|
310
|
+
children: api.items.map((index)=>{
|
|
311
|
+
const itemProps = api.getItemProps({
|
|
312
|
+
index
|
|
313
|
+
});
|
|
314
|
+
const fill = Math.max(0, Math.min(1, api.value - index + 1));
|
|
315
|
+
const glyphProps = getRatingGlyphProps(itemProps, fill, showExactValue);
|
|
316
|
+
const checked = api.value > 0 && Math.ceil(api.value) === index;
|
|
317
|
+
const tabIndex = index === Math.max(1, Math.ceil(api.value)) ? 0 : -1;
|
|
318
|
+
const focusableProps = {
|
|
319
|
+
...itemProps,
|
|
320
|
+
"aria-checked": checked,
|
|
321
|
+
tabIndex: itemProps["aria-disabled"] ? void 0 : tabIndex,
|
|
322
|
+
"aria-label": checked ? translations?.ratingValueText?.(api.value) ?? `${api.value} stars` : itemProps["aria-label"]
|
|
323
|
+
};
|
|
324
|
+
return /*#__PURE__*/ jsxs("span", {
|
|
325
|
+
className: styles.item(),
|
|
326
|
+
...isDisplay ? pickDataAttributes(itemProps) : focusableProps,
|
|
327
|
+
"aria-describedby": isDisplay ? void 0 : describedBy,
|
|
328
|
+
"aria-errormessage": isDisplay ? void 0 : errorMessageId,
|
|
329
|
+
"aria-invalid": !isDisplay && invalid || void 0,
|
|
330
|
+
children: [
|
|
331
|
+
/*#__PURE__*/ jsx("span", {
|
|
332
|
+
"aria-hidden": "true",
|
|
333
|
+
className: styles.glyph(),
|
|
334
|
+
...glyphProps
|
|
335
|
+
}),
|
|
336
|
+
showExactValue && fill > 0 && fill < 1 && /*#__PURE__*/ jsx("span", {
|
|
337
|
+
"aria-hidden": "true",
|
|
338
|
+
className: styles.fractionalGlyph(),
|
|
339
|
+
"data-disabled": itemProps["data-disabled"],
|
|
340
|
+
"data-part": "fractional-glyph",
|
|
341
|
+
dir: dir,
|
|
342
|
+
style: {
|
|
343
|
+
"--rating-item-clip": `${Number(((1 - fill) * 100).toFixed(10))}%`
|
|
344
|
+
}
|
|
345
|
+
})
|
|
346
|
+
]
|
|
347
|
+
}, index);
|
|
348
|
+
})
|
|
349
|
+
});
|
|
350
|
+
}
|
|
127
351
|
function pickDataAttributes(props) {
|
|
128
352
|
return Object.fromEntries(Object.entries(props).filter(([key])=>key.startsWith("data-")));
|
|
129
353
|
}
|
|
354
|
+
function getRatingGlyphProps(itemProps, fill, showExactValue) {
|
|
355
|
+
return {
|
|
356
|
+
...pickDataAttributes(itemProps),
|
|
357
|
+
...showExactValue ? {
|
|
358
|
+
"data-highlighted": 1 === fill ? "" : void 0,
|
|
359
|
+
"data-half": void 0
|
|
360
|
+
} : {}
|
|
361
|
+
};
|
|
362
|
+
}
|
|
130
363
|
export { Rating };
|
package/dist/atoms/skeleton.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { Fragment, jsx } from "react/jsx-runtime";
|
|
2
3
|
import { createContext, useContext } from "react";
|
|
3
4
|
import { tv } from "../utils.js";
|
|
@@ -6,7 +7,8 @@ const skeletonVariants = tv({
|
|
|
6
7
|
root: [
|
|
7
8
|
"relative min-w-0 overflow-clip"
|
|
8
9
|
],
|
|
9
|
-
|
|
10
|
+
shape: "relative min-w-0 overflow-clip",
|
|
11
|
+
rectangle: "skeleton-rectangle w-full",
|
|
10
12
|
circle: [
|
|
11
13
|
"rounded-full",
|
|
12
14
|
"shrink-0"
|
|
@@ -56,13 +58,13 @@ const skeletonVariants = tv({
|
|
|
56
58
|
},
|
|
57
59
|
speed: {
|
|
58
60
|
slow: {
|
|
59
|
-
|
|
61
|
+
shape: "animate-skeleton-pulse-slow"
|
|
60
62
|
},
|
|
61
63
|
normal: {
|
|
62
|
-
|
|
64
|
+
shape: "animate-skeleton-pulse-normal"
|
|
63
65
|
},
|
|
64
66
|
fast: {
|
|
65
|
-
|
|
67
|
+
shape: "animate-skeleton-pulse-fast"
|
|
66
68
|
}
|
|
67
69
|
}
|
|
68
70
|
},
|
|
@@ -109,16 +111,19 @@ function Skeleton({ isLoaded = false, variant, children, speed, className, ref,
|
|
|
109
111
|
variant,
|
|
110
112
|
speed
|
|
111
113
|
},
|
|
112
|
-
children: isLoaded ? /*#__PURE__*/ jsx(
|
|
113
|
-
children: children
|
|
114
|
-
}) : /*#__PURE__*/ jsx("div", {
|
|
114
|
+
children: isLoaded ? children : /*#__PURE__*/ jsx("div", {
|
|
115
115
|
...LOADING_STATUS_PROPS,
|
|
116
116
|
className: styles.root({
|
|
117
117
|
className
|
|
118
118
|
}),
|
|
119
119
|
ref: ref,
|
|
120
120
|
...props,
|
|
121
|
-
children:
|
|
121
|
+
children: /*#__PURE__*/ jsx("div", {
|
|
122
|
+
"aria-hidden": "true",
|
|
123
|
+
className: "contents",
|
|
124
|
+
inert: true,
|
|
125
|
+
children: children
|
|
126
|
+
})
|
|
122
127
|
})
|
|
123
128
|
});
|
|
124
129
|
}
|
|
@@ -139,7 +144,7 @@ Skeleton.Circle = function({ size = "md", speed, isLoaded, variant, children, cl
|
|
|
139
144
|
});
|
|
140
145
|
return /*#__PURE__*/ jsx("div", {
|
|
141
146
|
...a11yProps,
|
|
142
|
-
className: styles.
|
|
147
|
+
className: styles.shape({
|
|
143
148
|
className: styles.circle({
|
|
144
149
|
className
|
|
145
150
|
})
|
|
@@ -163,7 +168,7 @@ Skeleton.Text = function({ noOfLines = 3, size = "md", speed, lastLineWidth = "8
|
|
|
163
168
|
if (resolved.isLoaded) return /*#__PURE__*/ jsx(Fragment, {
|
|
164
169
|
children: children
|
|
165
170
|
});
|
|
166
|
-
const lineCount = Number.isFinite(noOfLines) ? Math.max(1, noOfLines) : 1;
|
|
171
|
+
const lineCount = Number.isFinite(noOfLines) ? Math.max(1, Math.floor(noOfLines)) : 1;
|
|
167
172
|
return /*#__PURE__*/ jsx("div", {
|
|
168
173
|
...a11yProps,
|
|
169
174
|
className: styles.textContainer({
|
|
@@ -177,7 +182,7 @@ Skeleton.Text = function({ noOfLines = 3, size = "md", speed, lastLineWidth = "8
|
|
|
177
182
|
const isLastLine = index === lineCount - 1;
|
|
178
183
|
const width = isLastLine && lineCount > 1 ? lastLineWidth : "100%";
|
|
179
184
|
return /*#__PURE__*/ jsx("div", {
|
|
180
|
-
className: styles.
|
|
185
|
+
className: styles.shape({
|
|
181
186
|
className: styles.textLine({
|
|
182
187
|
className
|
|
183
188
|
})
|
|
@@ -205,14 +210,13 @@ Skeleton.Rectangle = function({ speed, isLoaded, variant, children, className, r
|
|
|
205
210
|
});
|
|
206
211
|
return /*#__PURE__*/ jsx("div", {
|
|
207
212
|
...a11yProps,
|
|
208
|
-
className: styles.
|
|
213
|
+
className: styles.shape({
|
|
209
214
|
className: styles.rectangle({
|
|
210
215
|
className
|
|
211
216
|
})
|
|
212
217
|
}),
|
|
213
218
|
ref: ref,
|
|
214
|
-
...props
|
|
215
|
-
children: children
|
|
219
|
+
...props
|
|
216
220
|
});
|
|
217
221
|
};
|
|
218
222
|
export { Skeleton };
|
|
@@ -3,39 +3,41 @@ import { tv } from "../utils.js";
|
|
|
3
3
|
import { Icon } from "./icon.js";
|
|
4
4
|
const statusTextVariants = tv({
|
|
5
5
|
slots: {
|
|
6
|
-
base: "flex
|
|
7
|
-
icon: ""
|
|
6
|
+
base: "flex",
|
|
7
|
+
icon: "inline-flex h-status-text-icon-line shrink-0 items-center",
|
|
8
|
+
message: "min-w-0 break-words"
|
|
8
9
|
},
|
|
9
10
|
variants: {
|
|
10
11
|
status: {
|
|
11
12
|
error: "text-status-text-fg-error",
|
|
12
13
|
success: "text-status-text-fg-success",
|
|
13
14
|
warning: "text-status-text-fg-warning",
|
|
14
|
-
default: "text-status-text-fg"
|
|
15
|
+
default: "status-text-neutral-prefix text-status-text-fg"
|
|
15
16
|
},
|
|
16
17
|
align: {
|
|
17
18
|
start: {
|
|
18
|
-
|
|
19
|
+
base: "items-start"
|
|
19
20
|
},
|
|
20
|
-
center: {
|
|
21
|
+
center: {
|
|
22
|
+
base: "items-center"
|
|
23
|
+
}
|
|
21
24
|
},
|
|
22
25
|
size: {
|
|
23
26
|
sm: {
|
|
24
|
-
base: "gap-status-text-sm text-status-text-sm"
|
|
27
|
+
base: "status-text-leading-sm gap-status-text-sm text-status-text-sm"
|
|
25
28
|
},
|
|
26
29
|
md: {
|
|
27
|
-
base: "gap-status-text-md text-status-text-md"
|
|
30
|
+
base: "status-text-leading-md gap-status-text-md text-status-text-md"
|
|
28
31
|
},
|
|
29
32
|
lg: {
|
|
30
|
-
base: "
|
|
31
|
-
icon: "mt-status-text-icon-offset"
|
|
33
|
+
base: "status-text-leading-lg gap-status-text-lg text-status-text-lg"
|
|
32
34
|
}
|
|
33
35
|
}
|
|
34
36
|
},
|
|
35
37
|
defaultVariants: {
|
|
36
38
|
status: "default",
|
|
37
39
|
size: "md",
|
|
38
|
-
align: "
|
|
40
|
+
align: "start"
|
|
39
41
|
}
|
|
40
42
|
});
|
|
41
43
|
const ICON_MAP = {
|
|
@@ -44,14 +46,19 @@ const ICON_MAP = {
|
|
|
44
46
|
warning: "token-icon-status-text-warning",
|
|
45
47
|
default: void 0
|
|
46
48
|
};
|
|
47
|
-
|
|
49
|
+
const LIVE_ROLE_MAP = {
|
|
50
|
+
error: "alert",
|
|
51
|
+
success: "status",
|
|
52
|
+
warning: "status",
|
|
53
|
+
default: void 0
|
|
54
|
+
};
|
|
55
|
+
function StatusText({ className, showIcon = true, status = "default", size = "md", align = "start", icon, children, ref, ...props }) {
|
|
48
56
|
const resolvedIcon = icon ?? ICON_MAP[status];
|
|
49
|
-
const liveRole =
|
|
50
|
-
const { base, icon: iconSlot } = statusTextVariants({
|
|
57
|
+
const liveRole = LIVE_ROLE_MAP[status];
|
|
58
|
+
const { base, icon: iconSlot, message } = statusTextVariants({
|
|
51
59
|
status,
|
|
52
60
|
size,
|
|
53
|
-
align
|
|
54
|
-
className
|
|
61
|
+
align
|
|
55
62
|
});
|
|
56
63
|
return /*#__PURE__*/ jsxs("div", {
|
|
57
64
|
className: base({
|
|
@@ -59,16 +66,22 @@ function StatusText({ className, showIcon = false, status = "default", size = "m
|
|
|
59
66
|
size,
|
|
60
67
|
className
|
|
61
68
|
}),
|
|
69
|
+
"data-status": status,
|
|
62
70
|
ref: ref,
|
|
63
71
|
role: liveRole,
|
|
64
72
|
...props,
|
|
65
73
|
children: [
|
|
66
|
-
showIcon && resolvedIcon && /*#__PURE__*/ jsx(
|
|
74
|
+
showIcon && resolvedIcon && /*#__PURE__*/ jsx("span", {
|
|
75
|
+
"aria-hidden": "true",
|
|
67
76
|
className: iconSlot(),
|
|
68
|
-
|
|
69
|
-
|
|
77
|
+
children: /*#__PURE__*/ jsx(Icon, {
|
|
78
|
+
"aria-hidden": "true",
|
|
79
|
+
icon: resolvedIcon,
|
|
80
|
+
size: "current"
|
|
81
|
+
})
|
|
70
82
|
}),
|
|
71
83
|
/*#__PURE__*/ jsx("span", {
|
|
84
|
+
className: message(),
|
|
72
85
|
children: children
|
|
73
86
|
})
|
|
74
87
|
]
|