@optimum-intelligence/opti-ui 0.7.5 → 0.8.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/CHANGELOG.md +77 -0
- package/README.md +24 -11
- package/dist/components/alert/Alert.d.ts +5 -2
- package/dist/components/alert/Alert.js +67 -65
- package/dist/components/alert/Alert.js.map +1 -1
- package/dist/components/app-shell/AppShell.d.ts +19 -7
- package/dist/components/app-shell/AppShell.js +329 -303
- package/dist/components/app-shell/AppShell.js.map +1 -1
- package/dist/components/calendar/Calendar.js +140 -136
- package/dist/components/calendar/Calendar.js.map +1 -1
- package/dist/components/combobox/Combobox.d.ts +8 -2
- package/dist/components/combobox/Combobox.js +182 -202
- package/dist/components/combobox/Combobox.js.map +1 -1
- package/dist/components/data-table/DataTable.d.ts +23 -11
- package/dist/components/data-table/DataTable.js +148 -88
- package/dist/components/data-table/DataTable.js.map +1 -1
- package/dist/components/data-table/DataTableContent.js +1 -1
- package/dist/components/data-table/DataTableFilters.d.ts +56 -4
- package/dist/components/data-table/DataTableFilters.js +492 -77
- package/dist/components/data-table/DataTableFilters.js.map +1 -1
- package/dist/components/data-table/types.d.ts +13 -2
- package/dist/components/data-table/useDataTable.d.ts +1 -1
- package/dist/components/data-table/useDataTable.js +251 -229
- package/dist/components/data-table/useDataTable.js.map +1 -1
- package/dist/components/date-picker/DatePicker.d.ts +5 -0
- package/dist/components/date-picker/DatePicker.js +148 -140
- package/dist/components/date-picker/DatePicker.js.map +1 -1
- package/dist/components/date-picker/DateRangePicker.d.ts +2 -0
- package/dist/components/date-picker/DateRangePicker.js +171 -164
- package/dist/components/date-picker/DateRangePicker.js.map +1 -1
- package/dist/components/date-picker/PickerField.d.ts +6 -3
- package/dist/components/date-picker/PickerField.js +166 -159
- package/dist/components/date-picker/PickerField.js.map +1 -1
- package/dist/components/dialog/ConfirmDialog.d.ts +5 -2
- package/dist/components/dialog/ConfirmDialog.js +79 -77
- package/dist/components/dialog/ConfirmDialog.js.map +1 -1
- package/dist/components/dialog/Dialog.d.ts +5 -2
- package/dist/components/dialog/Dialog.js +65 -63
- package/dist/components/dialog/Dialog.js.map +1 -1
- package/dist/components/drawer/Drawer.d.ts +13 -4
- package/dist/components/drawer/Drawer.js +122 -164
- package/dist/components/drawer/Drawer.js.map +1 -1
- package/dist/components/field/Field.d.ts +38 -9
- package/dist/components/field/Field.js +66 -1
- package/dist/components/field/Field.js.map +1 -1
- package/dist/components/file-upload/FileUpload.js +2 -0
- package/dist/components/file-upload/FileUpload.js.map +1 -1
- package/dist/components/input/Input.d.ts +9 -16
- package/dist/components/input/Input.js +124 -206
- package/dist/components/input/Input.js.map +1 -1
- package/dist/components/map/Map.d.ts +29 -3
- package/dist/components/map/Map.js +332 -160
- package/dist/components/map/Map.js.map +1 -1
- package/dist/components/map/colors.d.ts +2 -2
- package/dist/components/map/colors.js +12 -3
- package/dist/components/map/colors.js.map +1 -1
- package/dist/components/number-field/NumberField.d.ts +12 -3
- package/dist/components/number-field/NumberField.js +109 -130
- package/dist/components/number-field/NumberField.js.map +1 -1
- package/dist/components/pagination/Pagination.js +135 -186
- package/dist/components/pagination/Pagination.js.map +1 -1
- package/dist/components/search-input/SearchInput.d.ts +5 -2
- package/dist/components/search-input/SearchInput.js +47 -45
- package/dist/components/search-input/SearchInput.js.map +1 -1
- package/dist/components/select/Select.d.ts +13 -3
- package/dist/components/select/Select.js +144 -139
- package/dist/components/select/Select.js.map +1 -1
- package/dist/components/spinner/Spinner.d.ts +6 -2
- package/dist/components/spinner/Spinner.js +42 -40
- package/dist/components/spinner/Spinner.js.map +1 -1
- package/dist/components/stepper/Stepper.js +44 -40
- package/dist/components/stepper/Stepper.js.map +1 -1
- package/dist/components/toast/Toast.d.ts +17 -1
- package/dist/components/toast/Toast.js +65 -33
- package/dist/components/toast/Toast.js.map +1 -1
- package/dist/components.json +393 -59
- package/dist/index.d.ts +2 -0
- package/dist/index.js +5 -3
- package/dist/labels/Labels.d.ts +85 -0
- package/dist/labels/Labels.js +92 -0
- package/dist/labels/Labels.js.map +1 -0
- package/dist/llms-full.txt +231 -45
- package/dist/llms.txt +10 -4
- package/dist/opti-ui.css +212 -18
- package/dist/theme/ThemeProvider.d.ts +8 -4
- package/dist/theme/ThemeProvider.js.map +1 -1
- package/dist/utils/media.d.ts +9 -2
- package/dist/utils/media.js +10 -3
- package/dist/utils/media.js.map +1 -1
- package/package.json +5 -2
|
@@ -26,7 +26,7 @@ function createResolver(element, _version) {
|
|
|
26
26
|
const cache = {};
|
|
27
27
|
let ctx;
|
|
28
28
|
return {
|
|
29
|
-
dark: element
|
|
29
|
+
dark: !!element && getComputedStyle(element).colorScheme === "dark",
|
|
30
30
|
color(css) {
|
|
31
31
|
if (!element) return "rgba(0, 0, 0, 0)";
|
|
32
32
|
if (!(css in cache)) {
|
|
@@ -50,7 +50,7 @@ function createResolver(element, _version) {
|
|
|
50
50
|
/**
|
|
51
51
|
* Resolves `--oui-*` colour tokens to `rgba()` strings inside `element`, for MapLibre paint properties,
|
|
52
52
|
* which accept no `var()` or `color-mix()`. It re-reads them when `data-oui-theme`, `class` or `style`
|
|
53
|
-
* changes on the element or an ancestor (theme switches, `ThemeProvider`).
|
|
53
|
+
* changes on the element or an ancestor (theme switches, `ThemeProvider`), and when the OS colour scheme changes.
|
|
54
54
|
* `Map.Root` calls it for you; use it for your own `Source`/`Layer` children.
|
|
55
55
|
*/
|
|
56
56
|
function useResolvedColors(element) {
|
|
@@ -70,7 +70,13 @@ function useResolvedColors(element) {
|
|
|
70
70
|
"style"
|
|
71
71
|
]
|
|
72
72
|
});
|
|
73
|
-
|
|
73
|
+
const scheme = window.matchMedia("(prefers-color-scheme: dark)");
|
|
74
|
+
const onScheme = () => setVersion(_temp2);
|
|
75
|
+
scheme.addEventListener("change", onScheme);
|
|
76
|
+
return () => {
|
|
77
|
+
observer.disconnect();
|
|
78
|
+
scheme.removeEventListener("change", onScheme);
|
|
79
|
+
};
|
|
74
80
|
};
|
|
75
81
|
t1 = [element];
|
|
76
82
|
$[0] = element;
|
|
@@ -90,6 +96,9 @@ function useResolvedColors(element) {
|
|
|
90
96
|
} else t2 = $[5];
|
|
91
97
|
return t2;
|
|
92
98
|
}
|
|
99
|
+
function _temp2(v_0) {
|
|
100
|
+
return v_0 + 1;
|
|
101
|
+
}
|
|
93
102
|
function _temp(v) {
|
|
94
103
|
return v + 1;
|
|
95
104
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colors.js","names":["React","ResolvedColors","dark","color","css","number","name","fallback","round","n","Math","toRgba","computed","ctx","CanvasRenderingContext2D","test","srgb","match","r","g","b","slice","map","v","min","max","Number","clearRect","fillStyle","fillRect","a","getImageData","data","createResolver","element","HTMLElement","_version","cache","Record","
|
|
1
|
+
{"version":3,"file":"colors.js","names":["React","ResolvedColors","dark","color","css","number","name","fallback","round","n","Math","toRgba","computed","ctx","CanvasRenderingContext2D","test","srgb","match","r","g","b","slice","map","v","min","max","Number","clearRect","fillStyle","fillRect","a","getImageData","data","createResolver","element","HTMLElement","_version","cache","Record","getComputedStyle","colorScheme","probe","document","createElement","hidden","style","appendChild","remove","getContext","willReadFrequently","value","parseFloat","getPropertyValue","NaN","isFinite","useResolvedColors","$","_c","version","setVersion","useState","t0","t1","observer","MutationObserver","_temp","node","parentElement","observe","attributes","attributeFilter","scheme","window","matchMedia","onScheme","_temp2","addEventListener","disconnect","removeEventListener","useEffect","t2","v_0","_c"],"sources":["../../../src/components/map/colors.ts"],"sourcesContent":["import * as React from 'react';\n\n/** Theme values read from the map container, in forms MapLibre accepts. */\nexport interface ResolvedColors {\n /** True when the element is in dark mode: `data-oui-theme=\"dark\"`, or `\"system\"` on a dark OS. */\n dark: boolean;\n /** Any CSS colour (`var(--oui-…)`, `color-mix()`, `oklch()`, hex) as an `rgba()` string. */\n color: (css: string) => string;\n /** A numeric custom property, e.g. `--oui-map-dim-opacity`, or `fallback` when it is unset. */\n number: (name: string, fallback: number) => number;\n}\n\nconst round = (n: number) => Math.round(n * 1000) / 1000;\n\n/**\n * Turns a computed colour into `rgba()`. Browsers serialise `color-mix()` results as\n * `color(srgb r g b / a)` or `oklab(…)`, which MapLibre rejects. sRGB forms are parsed directly (exact\n * alpha); anything else is drawn as one pixel on a canvas and read back.\n */\nfunction toRgba(computed: string, ctx: CanvasRenderingContext2D | null): string {\n if (/^rgba?\\(/.test(computed)) return computed;\n const srgb = computed.match(/^color\\(srgb\\s+([\\d.e-]+)\\s+([\\d.e-]+)\\s+([\\d.e-]+)(?:\\s*\\/\\s*([\\d.e-]+))?\\)$/);\n if (srgb) {\n const [r, g, b] = srgb.slice(1, 4).map((v) => Math.round(Math.min(1, Math.max(0, Number(v))) * 255));\n return `rgba(${r}, ${g}, ${b}, ${round(Number(srgb[4] ?? 1))})`;\n }\n if (!ctx) return 'rgba(0, 0, 0, 0)';\n ctx.clearRect(0, 0, 1, 1);\n ctx.fillStyle = computed;\n ctx.fillRect(0, 0, 1, 1);\n const [r, g, b, a] = ctx.getImageData(0, 0, 1, 1).data;\n return `rgba(${r}, ${g}, ${b}, ${round(a / 255)})`;\n}\n\nfunction createResolver(element: HTMLElement | null, _version: number): ResolvedColors {\n const cache: Record<string, string> = {};\n let ctx: CanvasRenderingContext2D | null | undefined;\n return {\n // The theme tokens set `color-scheme`, which also covers \"system\" mode.\n dark: !!element && getComputedStyle(element).colorScheme === 'dark',\n color(css) {\n if (!element) return 'rgba(0, 0, 0, 0)';\n if (!(css in cache)) {\n const probe = document.createElement('span');\n probe.hidden = true;\n probe.style.color = css;\n element.appendChild(probe);\n const computed = getComputedStyle(probe).color;\n probe.remove();\n ctx ??= document.createElement('canvas').getContext('2d', { willReadFrequently: true });\n cache[css] = toRgba(computed, ctx);\n }\n return cache[css];\n },\n number(name, fallback) {\n const value = element ? parseFloat(getComputedStyle(element).getPropertyValue(name)) : NaN;\n return Number.isFinite(value) ? value : fallback;\n },\n };\n}\n\n/**\n * Resolves `--oui-*` colour tokens to `rgba()` strings inside `element`, for MapLibre paint properties,\n * which accept no `var()` or `color-mix()`. It re-reads them when `data-oui-theme`, `class` or `style`\n * changes on the element or an ancestor (theme switches, `ThemeProvider`), and when the OS colour scheme changes.\n * `Map.Root` calls it for you; use it for your own `Source`/`Layer` children.\n */\nexport function useResolvedColors(element: HTMLElement | null): ResolvedColors {\n const [version, setVersion] = React.useState(0);\n React.useEffect(() => {\n if (!element) return;\n // Watches the element and its ancestors only, not their subtrees: MapLibre rewrites marker styles on\n // every frame while panning.\n const observer = new MutationObserver(() => setVersion((v) => v + 1));\n for (let node: Element | null = element; node; node = node.parentElement) {\n observer.observe(node, { attributes: true, attributeFilter: ['data-oui-theme', 'class', 'style'] });\n }\n const scheme = window.matchMedia('(prefers-color-scheme: dark)');\n const onScheme = () => setVersion((v) => v + 1);\n scheme.addEventListener('change', onScheme);\n return () => {\n observer.disconnect();\n scheme.removeEventListener('change', onScheme);\n };\n }, [element]);\n return createResolver(element, version);\n}\n"],"mappings":";;;;AAYA,IAAMQ,SAASC,MAAcC,KAAKF,MAAMC,IAAI,GAAI,IAAI;;;;;;AAOpD,SAASE,OAAOC,UAAkBC,KAA8C;CAC9E,IAAI,WAAWE,KAAKH,QAAQ,GAAG,OAAOA;CACtC,MAAMI,OAAOJ,SAASK,MAAM,+EAA+E;CAC3G,IAAID,MAAM;EACR,MAAM,CAACE,GAAGC,GAAGC,KAAKJ,KAAKK,MAAM,GAAG,CAAC,CAAC,CAACC,KAAKC,MAAMb,KAAKF,MAAME,KAAKc,IAAI,GAAGd,KAAKe,IAAI,GAAGC,OAAOH,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC;EACnG,OAAO,QAAQL,EAAC,IAAKC,EAAC,IAAKC,EAAC,IAAKZ,MAAMkB,OAAOV,KAAK,MAAM,CAAC,CAAC,EAAC;CAC9D;CACA,IAAI,CAACH,KAAK,OAAO;CACjBA,IAAIc,UAAU,GAAG,GAAG,GAAG,CAAC;CACxBd,IAAIe,YAAYhB;CAChBC,IAAIgB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AAC3B,SAAO;GAGZ,MAAA6B,WAAiB,IAAIC,uBAAuBL,WAAWM,KAAY,CAAC;GACpE,KAAA,IAAAC,OAAgChC,SAASgC,MAAzCA,OAAsDA,KAAIC,eACxDJ,SAAQK,QAASF,MAAM;IAAAG,YAAc;IAAIC,iBAAmB;KAAC;KAAkB;KAAS;IAAO;GAAE,CAAC;GAEpG,MAAAC,SAAeC,OAAMC,WAAY,8BAA8B;GAC/D,MAAAC,iBAAuBf,WAAWgB,MAAY;GAC9CJ,OAAMK,iBAAkB,UAAUF,QAAQ;GAAC,aACpC;IACLX,SAAQc,WAAY;IACpBN,OAAMO,oBAAqB,UAAUJ,QAAQ;GAAC;EAC/C;EACAZ,KAAA,CAAC5B,OAAO;EAACsB,EAAA,KAAAtB;EAAAsB,EAAA,KAAAK;EAAAL,EAAA,KAAAM;CAAA,OAAA;EAAAD,KAAAL,EAAA;EAAAM,KAAAN,EAAA;CAAA;CAfZxD,MAAK+E,UAAWlB,IAebC,EAAS;CAAC,IAAAkB;CAAA,IAAAxB,EAAA,OAAAtB,WAAAsB,EAAA,OAAAE,SAAA;EACNsB,KAAA/C,eAAeC,SAASwB,OAAO;EAACF,EAAA,KAAAtB;EAAAsB,EAAA,KAAAE;EAAAF,EAAA,KAAAwB;CAAA,OAAAA,KAAAxB,EAAA;CAAA,OAAhCwB;AAAgC;AAlBlC,SAAAL,OAAAM,KAAA;CAAA,OAWsC1D,MAAI;AAAC;AAX3C,SAAA0C,MAAA1C,GAAA;CAAA,OAM2DA,IAAI;AAAC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { NumberField as BaseNumberField } from '@base-ui/react/number-field';
|
|
3
|
+
import { type FormFieldProps } from '../field/Field';
|
|
3
4
|
import type { ControlSize } from '../input/Input';
|
|
4
5
|
export interface NumberFieldProps extends BaseNumberField.Root.Props {
|
|
5
6
|
/** Visible field label. */
|
|
@@ -8,16 +9,24 @@ export interface NumberFieldProps extends BaseNumberField.Root.Props {
|
|
|
8
9
|
description?: React.ReactNode;
|
|
9
10
|
/** Error message. When set, the field is marked invalid. */
|
|
10
11
|
error?: React.ReactNode;
|
|
12
|
+
/** Props for the wrapping `Field.Root` (className, validate, validationMode…). */
|
|
13
|
+
fieldProps?: FormFieldProps['fieldProps'];
|
|
11
14
|
/** Control height. */
|
|
12
15
|
size?: ControlSize;
|
|
13
16
|
/** Placeholder shown while empty. */
|
|
14
17
|
placeholder?: string;
|
|
15
18
|
/** Hide the − / + stepper buttons. */
|
|
16
19
|
hideStepper?: boolean;
|
|
17
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* Accessible name of the − button. Set app-wide with `LabelsProvider` (`decrease`).
|
|
22
|
+
* @default 'Decrease'
|
|
23
|
+
*/
|
|
18
24
|
decrementLabel?: string;
|
|
19
|
-
/**
|
|
25
|
+
/**
|
|
26
|
+
* Accessible name of the + button. Set app-wide with `LabelsProvider` (`increase`).
|
|
27
|
+
* @default 'Increase'
|
|
28
|
+
*/
|
|
20
29
|
incrementLabel?: string;
|
|
21
30
|
}
|
|
22
31
|
/** Numeric input with stepper buttons, locale formatting and keyboard stepping. */
|
|
23
|
-
export declare function NumberField({ label, description, error, size, placeholder, hideStepper, decrementLabel, incrementLabel, className, name, disabled, required, ref, ...props }: NumberFieldProps): React.JSX.Element;
|
|
32
|
+
export declare function NumberField({ label, description, error, fieldProps, size, placeholder, hideStepper, decrementLabel: decrementLabelProp, incrementLabel: incrementLabelProp, className, name, disabled, required, ref, ...props }: NumberFieldProps): React.JSX.Element;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { withClass } from "../../utils/cx.js";
|
|
3
|
+
import { useLabels } from "../../labels/Labels.js";
|
|
3
4
|
import { MinusIcon, PlusIcon } from "../../icons/index.js";
|
|
4
|
-
import {
|
|
5
|
+
import { FormField } from "../field/Field.js";
|
|
5
6
|
import { c } from "react/compiler-runtime";
|
|
6
7
|
import "react";
|
|
7
8
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -9,12 +10,15 @@ import { NumberField } from "@base-ui/react/number-field";
|
|
|
9
10
|
//#region src/components/number-field/NumberField.tsx
|
|
10
11
|
/** Numeric input with stepper buttons, locale formatting and keyboard stepping. */
|
|
11
12
|
function NumberField$1(t0) {
|
|
12
|
-
const $ = c(
|
|
13
|
+
const $ = c(47);
|
|
13
14
|
let className;
|
|
15
|
+
let decrementLabelProp;
|
|
14
16
|
let description;
|
|
15
17
|
let disabled;
|
|
16
18
|
let error;
|
|
19
|
+
let fieldProps;
|
|
17
20
|
let hideStepper;
|
|
21
|
+
let incrementLabelProp;
|
|
18
22
|
let label;
|
|
19
23
|
let name;
|
|
20
24
|
let placeholder;
|
|
@@ -22,165 +26,140 @@ function NumberField$1(t0) {
|
|
|
22
26
|
let ref;
|
|
23
27
|
let required;
|
|
24
28
|
let t1;
|
|
25
|
-
let t2;
|
|
26
|
-
let t3;
|
|
27
29
|
if ($[0] !== t0) {
|
|
28
|
-
({label, description, error, size: t1, placeholder, hideStepper, decrementLabel:
|
|
30
|
+
({label, description, error, fieldProps, size: t1, placeholder, hideStepper, decrementLabel: decrementLabelProp, incrementLabel: incrementLabelProp, className, name, disabled, required, ref, ...props} = t0);
|
|
29
31
|
$[0] = t0;
|
|
30
32
|
$[1] = className;
|
|
31
|
-
$[2] =
|
|
32
|
-
$[3] =
|
|
33
|
-
$[4] =
|
|
34
|
-
$[5] =
|
|
35
|
-
$[6] =
|
|
36
|
-
$[7] =
|
|
37
|
-
$[8] =
|
|
38
|
-
$[9] =
|
|
39
|
-
$[10] =
|
|
40
|
-
$[11] =
|
|
41
|
-
$[12] =
|
|
42
|
-
$[13] =
|
|
43
|
-
$[14] =
|
|
33
|
+
$[2] = decrementLabelProp;
|
|
34
|
+
$[3] = description;
|
|
35
|
+
$[4] = disabled;
|
|
36
|
+
$[5] = error;
|
|
37
|
+
$[6] = fieldProps;
|
|
38
|
+
$[7] = hideStepper;
|
|
39
|
+
$[8] = incrementLabelProp;
|
|
40
|
+
$[9] = label;
|
|
41
|
+
$[10] = name;
|
|
42
|
+
$[11] = placeholder;
|
|
43
|
+
$[12] = props;
|
|
44
|
+
$[13] = ref;
|
|
45
|
+
$[14] = required;
|
|
46
|
+
$[15] = t1;
|
|
44
47
|
} else {
|
|
45
48
|
className = $[1];
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
decrementLabelProp = $[2];
|
|
50
|
+
description = $[3];
|
|
51
|
+
disabled = $[4];
|
|
52
|
+
error = $[5];
|
|
53
|
+
fieldProps = $[6];
|
|
54
|
+
hideStepper = $[7];
|
|
55
|
+
incrementLabelProp = $[8];
|
|
56
|
+
label = $[9];
|
|
57
|
+
name = $[10];
|
|
58
|
+
placeholder = $[11];
|
|
59
|
+
props = $[12];
|
|
60
|
+
ref = $[13];
|
|
61
|
+
required = $[14];
|
|
62
|
+
t1 = $[15];
|
|
59
63
|
}
|
|
60
64
|
const size = t1 === void 0 ? "md" : t1;
|
|
61
|
-
const
|
|
62
|
-
const incrementLabel =
|
|
63
|
-
const
|
|
64
|
-
let
|
|
65
|
-
if ($[
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
} else t5 = $[17];
|
|
74
|
-
let t6;
|
|
75
|
-
if ($[18] !== className) {
|
|
76
|
-
t6 = withClass("oui-number-field", className);
|
|
77
|
-
$[18] = className;
|
|
78
|
-
$[19] = t6;
|
|
79
|
-
} else t6 = $[19];
|
|
80
|
-
let t7;
|
|
81
|
-
if ($[20] !== decrementLabel || $[21] !== hideStepper) {
|
|
82
|
-
t7 = !hideStepper && /* @__PURE__ */ jsx(NumberField.Decrement, {
|
|
65
|
+
const text = useLabels();
|
|
66
|
+
const incrementLabel = incrementLabelProp ?? text.increase;
|
|
67
|
+
const decrementLabel = decrementLabelProp ?? text.decrease;
|
|
68
|
+
let t2;
|
|
69
|
+
if ($[16] !== className) {
|
|
70
|
+
t2 = withClass("oui-number-field", className);
|
|
71
|
+
$[16] = className;
|
|
72
|
+
$[17] = t2;
|
|
73
|
+
} else t2 = $[17];
|
|
74
|
+
let t3;
|
|
75
|
+
if ($[18] !== decrementLabel || $[19] !== hideStepper) {
|
|
76
|
+
t3 = !hideStepper && /* @__PURE__ */ jsx(NumberField.Decrement, {
|
|
83
77
|
className: "oui-number-field__step",
|
|
84
78
|
"aria-label": decrementLabel,
|
|
85
79
|
children: /* @__PURE__ */ jsx(MinusIcon, {})
|
|
86
80
|
});
|
|
87
|
-
$[
|
|
88
|
-
$[
|
|
89
|
-
$[
|
|
90
|
-
} else
|
|
91
|
-
let
|
|
92
|
-
if ($[
|
|
93
|
-
|
|
81
|
+
$[18] = decrementLabel;
|
|
82
|
+
$[19] = hideStepper;
|
|
83
|
+
$[20] = t3;
|
|
84
|
+
} else t3 = $[20];
|
|
85
|
+
let t4;
|
|
86
|
+
if ($[21] !== placeholder) {
|
|
87
|
+
t4 = /* @__PURE__ */ jsx(NumberField.Input, {
|
|
94
88
|
className: "oui-number-field__input",
|
|
95
89
|
placeholder
|
|
96
90
|
});
|
|
97
|
-
$[
|
|
98
|
-
$[
|
|
99
|
-
} else
|
|
100
|
-
let
|
|
101
|
-
if ($[
|
|
102
|
-
|
|
91
|
+
$[21] = placeholder;
|
|
92
|
+
$[22] = t4;
|
|
93
|
+
} else t4 = $[22];
|
|
94
|
+
let t5;
|
|
95
|
+
if ($[23] !== hideStepper || $[24] !== incrementLabel) {
|
|
96
|
+
t5 = !hideStepper && /* @__PURE__ */ jsx(NumberField.Increment, {
|
|
103
97
|
className: "oui-number-field__step",
|
|
104
98
|
"aria-label": incrementLabel,
|
|
105
99
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
106
100
|
});
|
|
107
|
-
$[
|
|
108
|
-
$[
|
|
109
|
-
$[
|
|
110
|
-
} else
|
|
111
|
-
let
|
|
112
|
-
if ($[
|
|
113
|
-
|
|
101
|
+
$[23] = hideStepper;
|
|
102
|
+
$[24] = incrementLabel;
|
|
103
|
+
$[25] = t5;
|
|
104
|
+
} else t5 = $[25];
|
|
105
|
+
let t6;
|
|
106
|
+
if ($[26] !== size || $[27] !== t3 || $[28] !== t4 || $[29] !== t5) {
|
|
107
|
+
t6 = /* @__PURE__ */ jsxs(NumberField.Group, {
|
|
114
108
|
className: "oui-number-field__group",
|
|
115
109
|
"data-size": size,
|
|
116
110
|
children: [
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
t3,
|
|
112
|
+
t4,
|
|
113
|
+
t5
|
|
120
114
|
]
|
|
121
115
|
});
|
|
122
|
-
$[
|
|
123
|
-
$[
|
|
124
|
-
$[
|
|
125
|
-
$[
|
|
126
|
-
$[
|
|
127
|
-
} else
|
|
128
|
-
let
|
|
129
|
-
if ($[
|
|
130
|
-
|
|
116
|
+
$[26] = size;
|
|
117
|
+
$[27] = t3;
|
|
118
|
+
$[28] = t4;
|
|
119
|
+
$[29] = t5;
|
|
120
|
+
$[30] = t6;
|
|
121
|
+
} else t6 = $[30];
|
|
122
|
+
let t7;
|
|
123
|
+
if ($[31] !== disabled || $[32] !== props || $[33] !== ref || $[34] !== required || $[35] !== t2 || $[36] !== t6) {
|
|
124
|
+
t7 = /* @__PURE__ */ jsx(NumberField.Root, {
|
|
131
125
|
ref,
|
|
132
|
-
className:
|
|
126
|
+
className: t2,
|
|
133
127
|
disabled,
|
|
134
128
|
required,
|
|
135
129
|
...props,
|
|
136
|
-
children:
|
|
130
|
+
children: t6
|
|
137
131
|
});
|
|
138
|
-
$[
|
|
139
|
-
$[
|
|
140
|
-
$[
|
|
141
|
-
$[
|
|
142
|
-
$[
|
|
143
|
-
$[
|
|
144
|
-
$[
|
|
145
|
-
} else
|
|
146
|
-
let
|
|
147
|
-
if ($[40] !==
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
if ($[42] !== error) {
|
|
154
|
-
t13 = error ? /* @__PURE__ */ jsx(Field.Error, {
|
|
155
|
-
match: true,
|
|
156
|
-
children: error
|
|
157
|
-
}) : /* @__PURE__ */ jsx(Field.Error, {});
|
|
158
|
-
$[42] = error;
|
|
159
|
-
$[43] = t13;
|
|
160
|
-
} else t13 = $[43];
|
|
161
|
-
let t14;
|
|
162
|
-
if ($[44] !== disabled || $[45] !== name || $[46] !== t11 || $[47] !== t12 || $[48] !== t13 || $[49] !== t4 || $[50] !== t5) {
|
|
163
|
-
t14 = /* @__PURE__ */ jsxs(Field.Root, {
|
|
132
|
+
$[31] = disabled;
|
|
133
|
+
$[32] = props;
|
|
134
|
+
$[33] = ref;
|
|
135
|
+
$[34] = required;
|
|
136
|
+
$[35] = t2;
|
|
137
|
+
$[36] = t6;
|
|
138
|
+
$[37] = t7;
|
|
139
|
+
} else t7 = $[37];
|
|
140
|
+
let t8;
|
|
141
|
+
if ($[38] !== description || $[39] !== disabled || $[40] !== error || $[41] !== fieldProps || $[42] !== label || $[43] !== name || $[44] !== required || $[45] !== t7) {
|
|
142
|
+
t8 = /* @__PURE__ */ jsx(FormField, {
|
|
143
|
+
label,
|
|
144
|
+
description,
|
|
145
|
+
error,
|
|
146
|
+
required,
|
|
164
147
|
name,
|
|
165
148
|
disabled,
|
|
166
|
-
|
|
167
|
-
children:
|
|
168
|
-
t5,
|
|
169
|
-
t11,
|
|
170
|
-
t12,
|
|
171
|
-
t13
|
|
172
|
-
]
|
|
149
|
+
fieldProps,
|
|
150
|
+
children: t7
|
|
173
151
|
});
|
|
174
|
-
$[
|
|
175
|
-
$[
|
|
176
|
-
$[
|
|
177
|
-
$[
|
|
178
|
-
$[
|
|
179
|
-
$[
|
|
180
|
-
$[
|
|
181
|
-
$[
|
|
182
|
-
|
|
183
|
-
|
|
152
|
+
$[38] = description;
|
|
153
|
+
$[39] = disabled;
|
|
154
|
+
$[40] = error;
|
|
155
|
+
$[41] = fieldProps;
|
|
156
|
+
$[42] = label;
|
|
157
|
+
$[43] = name;
|
|
158
|
+
$[44] = required;
|
|
159
|
+
$[45] = t7;
|
|
160
|
+
$[46] = t8;
|
|
161
|
+
} else t8 = $[46];
|
|
162
|
+
return t8;
|
|
184
163
|
}
|
|
185
164
|
//#endregion
|
|
186
165
|
export { NumberField$1 as NumberField };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NumberField.js","names":["React","NumberField","BaseNumberField","withClass","MinusIcon","PlusIcon","
|
|
1
|
+
{"version":3,"file":"NumberField.js","names":["React","NumberField","BaseNumberField","withClass","MinusIcon","PlusIcon","FormField","FormFieldProps","ControlSize","useLabels","NumberFieldProps","Root","Props","label","ReactNode","description","error","fieldProps","size","placeholder","hideStepper","decrementLabel","incrementLabel","t0","$","_c","className","decrementLabelProp","disabled","incrementLabelProp","name","props","ref","required","t1","undefined","text","increase","decrease","t2","t3","t4","t5","t6","t7","t8","NumberField","_c","BaseNumberField"],"sources":["../../../src/components/number-field/NumberField.tsx"],"sourcesContent":["import * as React from 'react';\nimport { NumberField as BaseNumberField } from '@base-ui/react/number-field';\nimport { withClass } from '../../utils/cx';\nimport { MinusIcon, PlusIcon } from '../../icons';\nimport { FormField, type FormFieldProps } from '../field/Field';\nimport type { ControlSize } from '../input/Input';\nimport { useLabels } from '../../labels/Labels';\n\nexport interface NumberFieldProps extends BaseNumberField.Root.Props {\n /** Visible field label. */\n label?: React.ReactNode;\n /** Help text under the input. */\n description?: React.ReactNode;\n /** Error message. When set, the field is marked invalid. */\n error?: React.ReactNode;\n /** Props for the wrapping `Field.Root` (className, validate, validationMode…). */\n fieldProps?: FormFieldProps['fieldProps'];\n /** Control height. */\n size?: ControlSize;\n /** Placeholder shown while empty. */\n placeholder?: string;\n /** Hide the − / + stepper buttons. */\n hideStepper?: boolean;\n /**\n * Accessible name of the − button. Set app-wide with `LabelsProvider` (`decrease`).\n * @default 'Decrease'\n */\n decrementLabel?: string;\n /**\n * Accessible name of the + button. Set app-wide with `LabelsProvider` (`increase`).\n * @default 'Increase'\n */\n incrementLabel?: string;\n}\n\n/** Numeric input with stepper buttons, locale formatting and keyboard stepping. */\nexport function NumberField({\n label,\n description,\n error,\n fieldProps,\n size = 'md',\n placeholder,\n hideStepper,\n decrementLabel: decrementLabelProp,\n incrementLabel: incrementLabelProp,\n className,\n name,\n disabled,\n required,\n ref,\n ...props\n}: NumberFieldProps) {\n const text = useLabels();\n const incrementLabel = incrementLabelProp ?? text.increase;\n const decrementLabel = decrementLabelProp ?? text.decrease;\n return (\n <FormField\n label={label}\n description={description}\n error={error}\n required={required}\n name={name}\n disabled={disabled}\n fieldProps={fieldProps}\n >\n <BaseNumberField.Root\n ref={ref}\n className={withClass('oui-number-field', className)}\n disabled={disabled}\n required={required}\n {...props}\n >\n <BaseNumberField.Group className=\"oui-number-field__group\" data-size={size}>\n {!hideStepper && (\n <BaseNumberField.Decrement className=\"oui-number-field__step\" aria-label={decrementLabel}>\n <MinusIcon />\n </BaseNumberField.Decrement>\n )}\n <BaseNumberField.Input className=\"oui-number-field__input\" placeholder={placeholder} />\n {!hideStepper && (\n <BaseNumberField.Increment className=\"oui-number-field__step\" aria-label={incrementLabel}>\n <PlusIcon />\n </BaseNumberField.Increment>\n )}\n </BaseNumberField.Group>\n </BaseNumberField.Root>\n </FormField>\n );\n}\n"],"mappings":";;;;;;;;;;;AAoCA,SAAOC,cAAAsB,IAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAZ;CAAA,IAAAa;CAAA,IAAAZ;CAAA,IAAAC;CAAA,IAAAG;CAAA,IAAAS;CAAA,IAAAhB;CAAA,IAAAiB;CAAA,IAAAX;CAAA,IAAAY;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAC;CAAA,IAAAV,EAAA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