@techsio/ui-kit 0.56.1 → 0.58.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 +78 -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 +107 -2
- package/dist/atoms/input.js +57 -9
- package/dist/atoms/label.js +13 -4
- package/dist/atoms/link-button.js +14 -12
- package/dist/atoms/link.js +18 -4
- package/dist/atoms/numeric-input.js +293 -76
- 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 +276 -38
- package/dist/molecules/color-select.js +181 -62
- package/dist/molecules/combobox.js +535 -182
- package/dist/molecules/command.js +2 -1
- package/dist/molecules/date-picker.js +571 -119
- package/dist/molecules/dialog.js +81 -47
- package/dist/molecules/drawer.js +54 -5
- 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 +23 -18
- 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 +85 -20
- package/dist/molecules/tabs.js +227 -31
- package/dist/molecules/toast.js +146 -51
- 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 +25 -5
- package/dist/organisms/data-table.helpers.js +6 -2
- package/dist/organisms/data-table.js +580 -151
- 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 +35 -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 +14 -6
- 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 +54 -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 +23 -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 +7 -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 +23 -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 +7 -3
- package/dist/src/molecules/date-picker.d.ts.map +1 -1
- package/dist/src/molecules/dialog.d.ts +7 -3
- 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 +20 -25
- 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 +25 -13
- 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 +24 -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 +103 -0
- package/src/tokens/_foundation-overrides.css +251 -0
- package/src/tokens/_reset.css +10 -10
- package/src/tokens/_scheme-scopes.css +4144 -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 +67 -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 +111 -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 +12 -14
- 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 +49 -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 +6 -6
- package/src/tokens/figma/brand-overrides.css +162 -57
- package/src/tokens/figma/business/variables.css +6 -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 +4 -4
- package/src/tokens/figma/light/variables.css +43 -40
- package/src/tokens/figma/{neo → n1}/variables.css +114 -114
- package/src/tokens/figma/variables.css +639 -240
- package/src/tokens/theme.css +24 -4
- package/src/tokens/_colors.css +0 -5
- package/src/tokens/figma/neo-dark/variables.css +0 -457
|
@@ -1,17 +1,70 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx } from "react/jsx-runtime";
|
|
2
3
|
import { normalizeProps, useMachine } from "@zag-js/react";
|
|
3
|
-
import { createContext, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef } from "react";
|
|
4
|
+
import { createContext, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState } from "react";
|
|
5
|
+
import { flushSync } from "react-dom";
|
|
6
|
+
import { isSilentChoiceReset, mergeChoiceInputProps, runSilentChoiceReset, trackChoiceFormControl } from "../internal/choice-control.js";
|
|
7
|
+
import { joinDescribedBy, useDescribedBy, useRegisterDescription } from "../internal/described-by.js";
|
|
8
|
+
import { createNumericInputEditing, syncNumericInputValue } from "../internal/numeric-input-editing.js";
|
|
4
9
|
import { tv } from "../utils.js";
|
|
5
10
|
import { Button } from "./button.js";
|
|
6
11
|
import { Input } from "./input.js";
|
|
12
|
+
import { StatusText } from "./status-text.js";
|
|
7
13
|
import * as __rspack_external__zag_js_number_input_f1a1f439 from "@zag-js/number-input";
|
|
14
|
+
const valueActions = __rspack_external__zag_js_number_input_f1a1f439.machine.implementations?.actions ?? {};
|
|
15
|
+
const guardValueAction = (action)=>(params)=>{
|
|
16
|
+
if (params.prop("readOnly") || params.computed("isDisabled")) return;
|
|
17
|
+
action?.(params);
|
|
18
|
+
};
|
|
19
|
+
const defaultComputed = __rspack_external__zag_js_number_input_f1a1f439.machine.computed;
|
|
20
|
+
const readOnlySafeMachine = {
|
|
21
|
+
...__rspack_external__zag_js_number_input_f1a1f439.machine,
|
|
22
|
+
computed: defaultComputed && {
|
|
23
|
+
...defaultComputed,
|
|
24
|
+
formattedValue (params) {
|
|
25
|
+
const value = params.computed("valueAsNumber");
|
|
26
|
+
if (Number.isFinite(value) && !Number.isInteger(value) && params.prop("formatOptions")?.maximumFractionDigits === 0) return params.context.get("value");
|
|
27
|
+
return defaultComputed.formattedValue(params);
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
implementations: {
|
|
31
|
+
...__rspack_external__zag_js_number_input_f1a1f439.machine.implementations,
|
|
32
|
+
actions: {
|
|
33
|
+
...valueActions,
|
|
34
|
+
increment: guardValueAction(valueActions.increment),
|
|
35
|
+
decrement: guardValueAction(valueActions.decrement),
|
|
36
|
+
incrementToMax: guardValueAction(valueActions.incrementToMax),
|
|
37
|
+
decrementToMin: guardValueAction(valueActions.decrementToMin),
|
|
38
|
+
setValue () {},
|
|
39
|
+
setRawValue: guardValueAction(valueActions.setRawValue),
|
|
40
|
+
clearValue: guardValueAction(valueActions.clearValue),
|
|
41
|
+
setClampedValue: guardValueAction(valueActions.setClampedValue),
|
|
42
|
+
setFormattedValue: guardValueAction(valueActions.setFormattedValue),
|
|
43
|
+
invokeOnValueCommit ({ computed, prop, event }) {
|
|
44
|
+
let valueAsNumber = computed("valueAsNumber");
|
|
45
|
+
let value = computed("formattedValue");
|
|
46
|
+
if ("INPUT.BLUR" === event.type && prop("clampValueOnBlur") && !prop("readOnly") && !computed("isDisabled") && Number.isFinite(valueAsNumber)) {
|
|
47
|
+
const clamped = Math.min(prop("max"), Math.max(prop("min"), valueAsNumber));
|
|
48
|
+
if (clamped !== valueAsNumber) {
|
|
49
|
+
valueAsNumber = clamped;
|
|
50
|
+
value = prop("formatOptions") ? computed("formatter").format(clamped) : String(clamped);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
prop("onValueCommit")?.({
|
|
54
|
+
value,
|
|
55
|
+
valueAsNumber
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
};
|
|
8
61
|
const numericInputVariants = tv({
|
|
9
62
|
slots: {
|
|
10
63
|
root: [
|
|
11
|
-
"relative flex"
|
|
64
|
+
"relative flex min-w-0 flex-col"
|
|
12
65
|
],
|
|
13
66
|
container: [
|
|
14
|
-
"group form-control-base relative flex",
|
|
67
|
+
"group numeric-input-focus-owner form-control-base numeric-input-validation numeric-input-readonly relative flex",
|
|
15
68
|
"border-numeric-input-border",
|
|
16
69
|
"min-w-0 items-center overflow-clip",
|
|
17
70
|
"hover:border-numeric-input-border-hover",
|
|
@@ -19,9 +72,6 @@ const numericInputVariants = tv({
|
|
|
19
72
|
"data-disabled:bg-numeric-input-bg-disabled",
|
|
20
73
|
"data-disabled:border-numeric-input-border-disabled",
|
|
21
74
|
"data-disabled:text-numeric-input-fg-disabled",
|
|
22
|
-
"data-invalid:bg-numeric-input-bg-invalid",
|
|
23
|
-
"data-invalid:border-(length:--border-width-validation)",
|
|
24
|
-
"data-invalid:border-numeric-input-border-invalid",
|
|
25
75
|
"text-numeric-input-fg",
|
|
26
76
|
"has-[input:not(:disabled):hover]:bg-numeric-input-input-bg-hover",
|
|
27
77
|
"has-[input:focus]:bg-numeric-input-input-bg-focus",
|
|
@@ -31,28 +81,30 @@ const numericInputVariants = tv({
|
|
|
31
81
|
"transition-colors duration-200 motion-reduce:transition-none"
|
|
32
82
|
],
|
|
33
83
|
input: [
|
|
34
|
-
"h-full rounded-none border-none",
|
|
84
|
+
"h-full min-w-0 flex-1 rounded-none border-none",
|
|
35
85
|
"bg-numeric-input-input-bg",
|
|
36
|
-
"focus:bg-numeric-input-input-bg
|
|
37
|
-
"hover:bg-numeric-input-input-bg
|
|
86
|
+
"focus:bg-numeric-input-input-bg",
|
|
87
|
+
"hover:bg-numeric-input-input-bg",
|
|
38
88
|
"disabled:hover:bg-numeric-input-input-bg",
|
|
39
89
|
"disabled:cursor-not-allowed",
|
|
40
90
|
"focus-visible:outline-hidden",
|
|
41
91
|
"duration-0 data-invalid:focus:border-input-border-danger-focus"
|
|
42
92
|
],
|
|
43
93
|
triggerContainer: [
|
|
44
|
-
"flex
|
|
45
|
-
"border-numeric-input-border border-s"
|
|
94
|
+
"flex shrink-0 flex-row self-stretch",
|
|
95
|
+
"border-numeric-input-border border-s group-data-disabled:border-numeric-input-border-disabled"
|
|
46
96
|
],
|
|
47
97
|
trigger: [
|
|
48
|
-
"flex flex-1 place-items-center",
|
|
98
|
+
"flex min-h-numeric-input-trigger-min min-w-numeric-input-trigger-min flex-1 place-items-center",
|
|
99
|
+
"pointer-coarse:min-w-numeric-input-trigger-touch-min",
|
|
49
100
|
"px-numeric-input-trigger-x py-numeric-input-trigger-y",
|
|
50
|
-
"bg-transparent hover:bg-
|
|
51
|
-
"text-
|
|
101
|
+
"bg-transparent hover:bg-numeric-input-trigger-bg-hover active:bg-numeric-input-trigger-bg-active",
|
|
102
|
+
"text-numeric-input-trigger-fg",
|
|
52
103
|
"cursor-pointer",
|
|
53
104
|
"transition-colors duration-200 motion-reduce:transition-none",
|
|
54
|
-
"disabled:cursor-not-allowed disabled:text-
|
|
105
|
+
"disabled:cursor-not-allowed disabled:text-numeric-input-trigger-fg-disabled"
|
|
55
106
|
],
|
|
107
|
+
triggerIcon: "",
|
|
56
108
|
scrubber: "absolute inset-0 cursor-ew-resize"
|
|
57
109
|
},
|
|
58
110
|
variants: {
|
|
@@ -61,18 +113,21 @@ const numericInputVariants = tv({
|
|
|
61
113
|
root: "gap-numeric-input-sm text-numeric-input-sm",
|
|
62
114
|
container: "h-form-control-sm rounded-numeric-input-sm",
|
|
63
115
|
trigger: "text-numeric-input-sm",
|
|
116
|
+
triggerIcon: "numeric-input-trigger-icon-sm",
|
|
64
117
|
input: "ps-numeric-input-input-sm text-numeric-input-sm"
|
|
65
118
|
},
|
|
66
119
|
md: {
|
|
67
120
|
root: "gap-numeric-input-md text-numeric-input-md",
|
|
68
121
|
container: "h-form-control-md rounded-numeric-input-md",
|
|
69
122
|
trigger: "text-numeric-input-md",
|
|
123
|
+
triggerIcon: "numeric-input-trigger-icon-md",
|
|
70
124
|
input: "ps-numeric-input-input-md text-numeric-input-md"
|
|
71
125
|
},
|
|
72
126
|
lg: {
|
|
73
127
|
root: "gap-numeric-input-lg text-numeric-input-lg",
|
|
74
128
|
container: "h-form-control-lg rounded-numeric-input-lg",
|
|
75
129
|
trigger: "text-numeric-input-lg",
|
|
130
|
+
triggerIcon: "numeric-input-trigger-icon-lg",
|
|
76
131
|
input: "ps-numeric-input-input-lg text-numeric-input-lg"
|
|
77
132
|
}
|
|
78
133
|
}
|
|
@@ -81,31 +136,83 @@ const numericInputVariants = tv({
|
|
|
81
136
|
size: "md"
|
|
82
137
|
}
|
|
83
138
|
});
|
|
84
|
-
const
|
|
85
|
-
sm: "xs",
|
|
86
|
-
md: "sm",
|
|
87
|
-
lg: "md"
|
|
88
|
-
};
|
|
139
|
+
const numericDraftPattern = /^[+-]?\d*(?:\.\d*)?$/;
|
|
89
140
|
const NumericInputContext = /*#__PURE__*/ createContext(null);
|
|
90
141
|
function useNumericInputContext() {
|
|
91
142
|
const context = useContext(NumericInputContext);
|
|
92
143
|
if (!context) throw new Error("NumericInput components must be used within NumericInput.Root");
|
|
93
144
|
return context;
|
|
94
145
|
}
|
|
95
|
-
function NumericInput({ id, size, value, defaultValue, onChange, dir = "ltr", describedBy, precision, children, ref, className, locale = "cs-CZ", ...props }) {
|
|
146
|
+
function NumericInput({ id, size, value, defaultValue, onChange, validateStatus = "default", dir = "ltr", describedBy, "aria-describedby": ariaDescribedBy, "aria-errormessage": ariaErrorMessage, "aria-invalid": ariaInvalid, precision, children, ref, className, locale = "cs-CZ", ...props }) {
|
|
96
147
|
const generatedId = useId();
|
|
148
|
+
const [inputId, setInputId] = useState();
|
|
149
|
+
const description = useDescribedBy();
|
|
150
|
+
const errors = useDescribedBy();
|
|
97
151
|
const [machineProps, elementProps] = __rspack_external__zag_js_number_input_f1a1f439.splitProps(props);
|
|
98
|
-
const { formatOptions, invalid, disabled = false, required = false, step = 1, allowMouseWheel = true, clampValueOnBlur = true, spinOnPress = true, focusInputOnChange = true } = machineProps;
|
|
99
|
-
const
|
|
152
|
+
const { formatOptions, invalid: machineInvalid, disabled = false, required = false, step = 1, allowMouseWheel = true, clampValueOnBlur = true, spinOnPress = true, focusInputOnChange = true } = machineProps;
|
|
153
|
+
const invalid = "error" === validateStatus || machineInvalid || void 0 !== ariaInvalid && false !== ariaInvalid && "false" !== ariaInvalid;
|
|
154
|
+
const resolvedFormatOptions = void 0 === precision ? formatOptions : {
|
|
100
155
|
...formatOptions ?? {},
|
|
156
|
+
minimumFractionDigits: Math.min(formatOptions?.minimumFractionDigits ?? 0, precision),
|
|
101
157
|
maximumFractionDigits: precision
|
|
102
|
-
}
|
|
158
|
+
};
|
|
103
159
|
const formatValue = (inputValue)=>{
|
|
160
|
+
if ("number" == typeof inputValue && !Number.isFinite(inputValue)) return "";
|
|
104
161
|
if ("string" == typeof inputValue || !resolvedFormatOptions) return String(inputValue);
|
|
105
162
|
return new Intl.NumberFormat(locale, resolvedFormatOptions).format(inputValue);
|
|
106
163
|
};
|
|
107
|
-
const
|
|
164
|
+
const parseDraft = useRef(Number.parseFloat);
|
|
165
|
+
const [editing] = useState(()=>createNumericInputEditing((draft)=>parseDraft.current(draft)));
|
|
166
|
+
const [, refreshNativeValue] = useState(0);
|
|
167
|
+
const controlledValue = void 0 === value ? void 0 : formatValue(value);
|
|
168
|
+
const resolvedValue = editing.resolve(controlledValue, value);
|
|
169
|
+
const coordinatedMachine = useMemo(()=>{
|
|
170
|
+
const actions = readOnlySafeMachine.implementations?.actions ?? {};
|
|
171
|
+
const authoritativeAction = (action)=>(params)=>{
|
|
172
|
+
if (!(params.prop("readOnly") || params.computed("isDisabled"))) editing.reset();
|
|
173
|
+
action?.(params);
|
|
174
|
+
};
|
|
175
|
+
return {
|
|
176
|
+
...readOnlySafeMachine,
|
|
177
|
+
implementations: {
|
|
178
|
+
...readOnlySafeMachine.implementations,
|
|
179
|
+
effects: {
|
|
180
|
+
...readOnlySafeMachine.implementations?.effects,
|
|
181
|
+
trackFormControl ({ scope, context, prop, action }) {
|
|
182
|
+
const root = scope.getById(scope.ids?.root ?? `number-input:${scope.id}`);
|
|
183
|
+
return trackChoiceFormControl(root, ()=>{
|
|
184
|
+
editing.reset();
|
|
185
|
+
flushSync(()=>refreshNativeValue((current)=>current + 1));
|
|
186
|
+
if (void 0 === prop("value")) runSilentChoiceReset(context, ()=>context.set("value", context.initial("value")));
|
|
187
|
+
action([
|
|
188
|
+
"syncInputElement"
|
|
189
|
+
]);
|
|
190
|
+
}, (fieldsetDisabled)=>context.set("fieldsetDisabled", fieldsetDisabled));
|
|
191
|
+
}
|
|
192
|
+
},
|
|
193
|
+
actions: {
|
|
194
|
+
...actions,
|
|
195
|
+
syncInputElement ({ scope, context, computed, event }) {
|
|
196
|
+
if (editing.nativeOwnsValue) return;
|
|
197
|
+
const input = scope.getById(scope.ids?.input ?? `number-input:${scope.id}:input`);
|
|
198
|
+
const nextValue = event.type.endsWith("CHANGE") ? context.get("value") : computed("formattedValue");
|
|
199
|
+
if (input) editing.schedule(input, ()=>syncNumericInputValue(input, nextValue));
|
|
200
|
+
},
|
|
201
|
+
increment: authoritativeAction(actions.increment),
|
|
202
|
+
decrement: authoritativeAction(actions.decrement),
|
|
203
|
+
incrementToMax: authoritativeAction(actions.incrementToMax),
|
|
204
|
+
decrementToMin: authoritativeAction(actions.decrementToMin),
|
|
205
|
+
setRawValue: authoritativeAction(actions.setRawValue),
|
|
206
|
+
clearValue: authoritativeAction(actions.clearValue)
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
}, [
|
|
211
|
+
editing
|
|
212
|
+
]);
|
|
213
|
+
const service = useMachine(coordinatedMachine, {
|
|
108
214
|
...machineProps,
|
|
215
|
+
invalid,
|
|
109
216
|
disabled,
|
|
110
217
|
required,
|
|
111
218
|
step,
|
|
@@ -114,24 +221,74 @@ function NumericInput({ id, size, value, defaultValue, onChange, dir = "ltr", de
|
|
|
114
221
|
spinOnPress,
|
|
115
222
|
focusInputOnChange,
|
|
116
223
|
id: id || generatedId,
|
|
117
|
-
ids: id ? {
|
|
224
|
+
ids: inputId || id ? {
|
|
118
225
|
...machineProps.ids,
|
|
119
|
-
input: machineProps.ids?.input ?? id
|
|
226
|
+
input: inputId ?? machineProps.ids?.input ?? id
|
|
120
227
|
} : machineProps.ids,
|
|
121
228
|
dir,
|
|
122
229
|
locale,
|
|
123
|
-
value:
|
|
124
|
-
defaultValue: void 0
|
|
230
|
+
value: resolvedValue,
|
|
231
|
+
defaultValue: void 0 === defaultValue ? void 0 : formatValue(defaultValue),
|
|
125
232
|
formatOptions: resolvedFormatOptions,
|
|
126
233
|
onValueChange: (details)=>{
|
|
234
|
+
if (isSilentChoiceReset(service.context)) return;
|
|
235
|
+
editing.propose(details.value);
|
|
127
236
|
onChange?.(details.valueAsNumber);
|
|
128
237
|
machineProps.onValueChange?.(details);
|
|
129
238
|
}
|
|
130
239
|
});
|
|
240
|
+
parseDraft.current = (draft)=>resolvedFormatOptions ? service.computed("parser").parse(draft) : Number.parseFloat(draft);
|
|
241
|
+
useLayoutEffect(()=>{
|
|
242
|
+
if (!editing.reconcile(controlledValue, value)) return;
|
|
243
|
+
const input = service.scope.getById(service.scope.ids?.input ?? `number-input:${service.scope.id}:input`);
|
|
244
|
+
if (input && void 0 !== controlledValue) syncNumericInputValue(input, controlledValue);
|
|
245
|
+
});
|
|
246
|
+
const onNativeCommit = ()=>{
|
|
247
|
+
editing.commit();
|
|
248
|
+
flushSync(()=>refreshNativeValue((current)=>current + 1));
|
|
249
|
+
};
|
|
250
|
+
const onNativeInput = (input)=>{
|
|
251
|
+
if (machineProps.readOnly || service.computed("isDisabled")) return;
|
|
252
|
+
const draft = input.value;
|
|
253
|
+
editing.edit(draft);
|
|
254
|
+
service.send({
|
|
255
|
+
type: "INPUT.CHANGE",
|
|
256
|
+
value: draft,
|
|
257
|
+
hint: "set"
|
|
258
|
+
});
|
|
259
|
+
flushSync(()=>{
|
|
260
|
+
service.context.set("value", draft);
|
|
261
|
+
refreshNativeValue((current)=>current + 1);
|
|
262
|
+
});
|
|
263
|
+
};
|
|
264
|
+
let isValidInputDraft;
|
|
265
|
+
if (resolvedFormatOptions) {
|
|
266
|
+
if (0 === resolvedFormatOptions.maximumFractionDigits && (!resolvedFormatOptions.style || "decimal" === resolvedFormatOptions.style)) {
|
|
267
|
+
const separator = new Intl.NumberFormat(locale).formatToParts(1.1).find((part)=>"decimal" === part.type)?.value;
|
|
268
|
+
if (separator) isValidInputDraft = (draft)=>{
|
|
269
|
+
const integerDraft = draft.replace(separator, "");
|
|
270
|
+
return !integerDraft.includes(separator) && service.computed("parser").isValidPartialNumber(integerDraft);
|
|
271
|
+
};
|
|
272
|
+
}
|
|
273
|
+
} else isValidInputDraft = (draft)=>numericDraftPattern.test(draft);
|
|
131
274
|
const api = __rspack_external__zag_js_number_input_f1a1f439.connect(service, normalizeProps);
|
|
132
275
|
useEffect(()=>{
|
|
133
|
-
|
|
134
|
-
|
|
276
|
+
if (machineProps.readOnly || disabled) {
|
|
277
|
+
service.send({
|
|
278
|
+
type: "TRIGGER.PRESS_UP"
|
|
279
|
+
});
|
|
280
|
+
service.send({
|
|
281
|
+
type: "SCRUBBER.POINTER_UP"
|
|
282
|
+
});
|
|
283
|
+
}
|
|
284
|
+
}, [
|
|
285
|
+
machineProps.readOnly,
|
|
286
|
+
disabled,
|
|
287
|
+
service
|
|
288
|
+
]);
|
|
289
|
+
useEffect(()=>{
|
|
290
|
+
const machineInputId = api.getInputProps().id;
|
|
291
|
+
const input = machineInputId ? service.scope.getById(machineInputId) : null;
|
|
135
292
|
if (input && input === service.scope.getActiveElement() && !api.focused) service.send({
|
|
136
293
|
type: "INPUT.FOCUS"
|
|
137
294
|
});
|
|
@@ -148,9 +305,20 @@ function NumericInput({ id, size, value, defaultValue, onChange, dir = "ltr", de
|
|
|
148
305
|
api,
|
|
149
306
|
size,
|
|
150
307
|
styles,
|
|
151
|
-
invalid,
|
|
152
|
-
|
|
153
|
-
|
|
308
|
+
invalid: invalid || Boolean(errors.describedById),
|
|
309
|
+
validateStatus: invalid || errors.describedById ? "error" : validateStatus,
|
|
310
|
+
describedBy: joinDescribedBy(describedBy, ariaDescribedBy),
|
|
311
|
+
description,
|
|
312
|
+
errors,
|
|
313
|
+
errorMessageId: ariaErrorMessage,
|
|
314
|
+
readOnly: machineProps.readOnly,
|
|
315
|
+
disabled: inputDisabled,
|
|
316
|
+
controlledValue: resolvedValue,
|
|
317
|
+
editing,
|
|
318
|
+
onNativeInput,
|
|
319
|
+
onNativeCommit,
|
|
320
|
+
setInputId,
|
|
321
|
+
isValidInputDraft
|
|
154
322
|
},
|
|
155
323
|
children: /*#__PURE__*/ jsx("div", {
|
|
156
324
|
className: styles.root({
|
|
@@ -168,7 +336,7 @@ function NumericInput({ id, size, value, defaultValue, onChange, dir = "ltr", de
|
|
|
168
336
|
});
|
|
169
337
|
}
|
|
170
338
|
NumericInput.Control = function({ children, ref, className, ...props }) {
|
|
171
|
-
const { api, styles, invalid } = useNumericInputContext();
|
|
339
|
+
const { api, styles, invalid, readOnly, disabled, validateStatus } = useNumericInputContext();
|
|
172
340
|
return /*#__PURE__*/ jsx("div", {
|
|
173
341
|
className: styles.container({
|
|
174
342
|
className
|
|
@@ -176,12 +344,22 @@ NumericInput.Control = function({ children, ref, className, ...props }) {
|
|
|
176
344
|
ref: ref,
|
|
177
345
|
...api.getControlProps(),
|
|
178
346
|
...props,
|
|
347
|
+
"data-disabled": disabled ? "" : void 0,
|
|
179
348
|
"data-invalid": invalid || void 0,
|
|
349
|
+
"data-readonly": readOnly ? "" : void 0,
|
|
350
|
+
"data-validation": "default" === validateStatus ? void 0 : validateStatus,
|
|
180
351
|
children: children
|
|
181
352
|
});
|
|
182
353
|
};
|
|
183
|
-
NumericInput.Input = function({ ref, className, ...props }) {
|
|
184
|
-
const { api, styles, describedBy, controlledValue } = useNumericInputContext();
|
|
354
|
+
NumericInput.Input = function({ ref, id, className, ...props }) {
|
|
355
|
+
const { api, styles, size, describedBy, controlledValue, editing, onNativeInput, onNativeCommit, setInputId, isValidInputDraft, description, errors, errorMessageId, invalid, readOnly, disabled } = useNumericInputContext();
|
|
356
|
+
useLayoutEffect(()=>{
|
|
357
|
+
setInputId(id);
|
|
358
|
+
return ()=>setInputId(void 0);
|
|
359
|
+
}, [
|
|
360
|
+
id,
|
|
361
|
+
setInputId
|
|
362
|
+
]);
|
|
185
363
|
const inputRef = useRef(null);
|
|
186
364
|
const mergedRef = useMemo(()=>(node)=>{
|
|
187
365
|
inputRef.current = node;
|
|
@@ -197,56 +375,71 @@ NumericInput.Input = function({ ref, className, ...props }) {
|
|
|
197
375
|
ref
|
|
198
376
|
]);
|
|
199
377
|
useLayoutEffect(()=>{
|
|
200
|
-
|
|
201
|
-
const
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
queueMicrotask(()=>{
|
|
206
|
-
if (cancelled) return;
|
|
207
|
-
frame = view.requestAnimationFrame(()=>{
|
|
208
|
-
const input = inputRef.current;
|
|
209
|
-
if (!input || input.value === controlledValue) return;
|
|
210
|
-
const start = input.selectionStart;
|
|
211
|
-
const end = input.selectionEnd;
|
|
212
|
-
const direction = input.selectionDirection;
|
|
213
|
-
input.value = controlledValue;
|
|
214
|
-
if (input.ownerDocument.activeElement === input && null !== start && null !== end) input.setSelectionRange(Math.min(start, controlledValue.length), Math.min(end, controlledValue.length), direction ?? void 0);
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
return ()=>{
|
|
218
|
-
cancelled = true;
|
|
219
|
-
if (void 0 !== frame) view.cancelAnimationFrame(frame);
|
|
220
|
-
};
|
|
378
|
+
const input = inputRef.current;
|
|
379
|
+
const cancel = input && void 0 !== controlledValue ? editing.schedule(input, ()=>{
|
|
380
|
+
if (input.value !== controlledValue) syncNumericInputValue(input, controlledValue);
|
|
381
|
+
}) : void 0;
|
|
382
|
+
return ()=>cancel?.();
|
|
221
383
|
}, [
|
|
222
384
|
api,
|
|
223
|
-
controlledValue
|
|
385
|
+
controlledValue,
|
|
386
|
+
editing
|
|
224
387
|
]);
|
|
225
|
-
const ariaDescribedBy = [
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
388
|
+
const ariaDescribedBy = joinDescribedBy(props["aria-describedby"], describedBy, description.describedById);
|
|
389
|
+
const errorId = joinDescribedBy(props["aria-errormessage"], errorMessageId, errors.describedById);
|
|
390
|
+
const isInvalid = invalid || Boolean(errors.describedById) || props["aria-invalid"];
|
|
391
|
+
const machineInputProps = api.getInputProps();
|
|
392
|
+
const inputProps = mergeChoiceInputProps(props, {
|
|
393
|
+
...machineInputProps,
|
|
394
|
+
onChange (event) {
|
|
395
|
+
onNativeInput(event.currentTarget);
|
|
396
|
+
},
|
|
397
|
+
onBlur (event) {
|
|
398
|
+
onNativeCommit();
|
|
399
|
+
machineInputProps.onBlur?.(event);
|
|
400
|
+
},
|
|
401
|
+
onKeyDown (event) {
|
|
402
|
+
if ("Enter" === event.key) onNativeCommit();
|
|
403
|
+
machineInputProps.onKeyDown?.(event);
|
|
404
|
+
},
|
|
405
|
+
onBeforeInput (event) {
|
|
406
|
+
if (!isValidInputDraft) return void machineInputProps.onBeforeInput?.(event);
|
|
407
|
+
const nativeEvent = event.nativeEvent;
|
|
408
|
+
if (nativeEvent.isComposing || nativeEvent.inputType?.startsWith("delete")) return;
|
|
409
|
+
const input = event.currentTarget;
|
|
410
|
+
const nextValue = input.value.slice(0, input.selectionStart ?? 0) + (nativeEvent.data ?? event.data ?? "") + input.value.slice(input.selectionEnd ?? 0);
|
|
411
|
+
if (!isValidInputDraft(nextValue)) event.preventDefault();
|
|
412
|
+
}
|
|
413
|
+
});
|
|
229
414
|
return /*#__PURE__*/ jsx(Input, {
|
|
230
415
|
ref: void 0 === controlledValue ? ref : mergedRef,
|
|
231
|
-
...
|
|
232
|
-
...props,
|
|
416
|
+
...inputProps,
|
|
233
417
|
"aria-describedby": ariaDescribedBy,
|
|
418
|
+
"aria-errormessage": errorId,
|
|
419
|
+
"aria-invalid": isInvalid || void 0,
|
|
234
420
|
className: styles.input({
|
|
235
421
|
className
|
|
236
|
-
})
|
|
422
|
+
}),
|
|
423
|
+
disabled: disabled || props.disabled,
|
|
424
|
+
id: id ?? machineInputProps.id,
|
|
425
|
+
readOnly: readOnly || props.readOnly,
|
|
426
|
+
size: size
|
|
237
427
|
});
|
|
238
428
|
};
|
|
239
429
|
NumericInput.IncrementTrigger = function({ variant = "primary", theme = "borderless", icon = "token-icon-numeric-input-increment", iconPosition = "left", iconSize, uppercase, block, isLoading, loadingText, ref, className, children, ...props }) {
|
|
240
|
-
const { api, styles,
|
|
241
|
-
|
|
430
|
+
const { api, styles, readOnly, disabled } = useNumericInputContext();
|
|
431
|
+
if (readOnly) return null;
|
|
242
432
|
return /*#__PURE__*/ jsx(Button, {
|
|
243
433
|
block: block,
|
|
244
434
|
className: styles.trigger({
|
|
245
|
-
className
|
|
435
|
+
className: [
|
|
436
|
+
void 0 === iconSize && styles.triggerIcon(),
|
|
437
|
+
className
|
|
438
|
+
]
|
|
246
439
|
}),
|
|
247
440
|
icon: icon,
|
|
248
441
|
iconPosition: iconPosition,
|
|
249
|
-
iconSize:
|
|
442
|
+
iconSize: iconSize ?? "current",
|
|
250
443
|
isLoading: isLoading,
|
|
251
444
|
loadingText: loadingText,
|
|
252
445
|
ref: ref,
|
|
@@ -256,20 +449,25 @@ NumericInput.IncrementTrigger = function({ variant = "primary", theme = "borderl
|
|
|
256
449
|
variant: variant,
|
|
257
450
|
...api.getIncrementTriggerProps(),
|
|
258
451
|
...props,
|
|
452
|
+
"data-readonly-affordance": "",
|
|
453
|
+
disabled: api.getIncrementTriggerProps().disabled || disabled || props.disabled,
|
|
259
454
|
children: children
|
|
260
455
|
});
|
|
261
456
|
};
|
|
262
457
|
NumericInput.DecrementTrigger = function({ variant = "primary", theme = "borderless", icon = "token-icon-numeric-input-decrement", iconPosition = "left", iconSize, uppercase, block, isLoading, loadingText, ref, className, children, ...props }) {
|
|
263
|
-
const { api, styles,
|
|
264
|
-
|
|
458
|
+
const { api, styles, readOnly, disabled } = useNumericInputContext();
|
|
459
|
+
if (readOnly) return null;
|
|
265
460
|
return /*#__PURE__*/ jsx(Button, {
|
|
266
461
|
block: block,
|
|
267
462
|
className: styles.trigger({
|
|
268
|
-
className
|
|
463
|
+
className: [
|
|
464
|
+
void 0 === iconSize && styles.triggerIcon(),
|
|
465
|
+
className
|
|
466
|
+
]
|
|
269
467
|
}),
|
|
270
468
|
icon: icon,
|
|
271
469
|
iconPosition: iconPosition,
|
|
272
|
-
iconSize:
|
|
470
|
+
iconSize: iconSize ?? "current",
|
|
273
471
|
isLoading: isLoading,
|
|
274
472
|
loadingText: loadingText,
|
|
275
473
|
ref: ref,
|
|
@@ -279,11 +477,14 @@ NumericInput.DecrementTrigger = function({ variant = "primary", theme = "borderl
|
|
|
279
477
|
variant: variant,
|
|
280
478
|
...api.getDecrementTriggerProps(),
|
|
281
479
|
...props,
|
|
480
|
+
"data-readonly-affordance": "",
|
|
481
|
+
disabled: api.getDecrementTriggerProps().disabled || disabled || props.disabled,
|
|
282
482
|
children: children
|
|
283
483
|
});
|
|
284
484
|
};
|
|
285
485
|
NumericInput.Scrubber = function({ ref, className, ...props }) {
|
|
286
|
-
const { api, styles } = useNumericInputContext();
|
|
486
|
+
const { api, styles, readOnly, disabled } = useNumericInputContext();
|
|
487
|
+
if (readOnly || disabled) return null;
|
|
287
488
|
return /*#__PURE__*/ jsx("div", {
|
|
288
489
|
className: styles.scrubber({
|
|
289
490
|
className
|
|
@@ -294,7 +495,8 @@ NumericInput.Scrubber = function({ ref, className, ...props }) {
|
|
|
294
495
|
});
|
|
295
496
|
};
|
|
296
497
|
NumericInput.TriggerContainer = function({ children, ref, className, ...props }) {
|
|
297
|
-
const { styles } = useNumericInputContext();
|
|
498
|
+
const { styles, readOnly } = useNumericInputContext();
|
|
499
|
+
if (readOnly) return null;
|
|
298
500
|
return /*#__PURE__*/ jsx("div", {
|
|
299
501
|
className: styles.triggerContainer({
|
|
300
502
|
className
|
|
@@ -304,5 +506,20 @@ NumericInput.TriggerContainer = function({ children, ref, className, ...props })
|
|
|
304
506
|
children: children
|
|
305
507
|
});
|
|
306
508
|
};
|
|
509
|
+
const ignoreDescription = ()=>()=>{};
|
|
510
|
+
NumericInput.StatusText = function({ id, status = "default", size, showIcon, ...props }) {
|
|
511
|
+
const generatedId = useId();
|
|
512
|
+
const messageId = id || generatedId;
|
|
513
|
+
const { size: fieldSize, description, errors } = useNumericInputContext();
|
|
514
|
+
useRegisterDescription(messageId, description.registerDescription);
|
|
515
|
+
useRegisterDescription(messageId, "error" === status ? errors.registerDescription : ignoreDescription);
|
|
516
|
+
return /*#__PURE__*/ jsx(StatusText, {
|
|
517
|
+
...props,
|
|
518
|
+
id: messageId,
|
|
519
|
+
showIcon: "default" !== status || showIcon,
|
|
520
|
+
size: size ?? fieldSize,
|
|
521
|
+
status: status
|
|
522
|
+
});
|
|
523
|
+
};
|
|
307
524
|
NumericInput.displayName = "NumericInput";
|
|
308
525
|
export { NumericInput };
|