pentatrion-design 1.2.10 → 1.2.12

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 CHANGED
@@ -1,3 +1,16 @@
1
+ ## 1.2.12
2
+
3
+ ### Patch Changes
4
+
5
+ - 4cce0c9: update deps
6
+ - 4cce0c9: enhance Range AudioRange RangeField
7
+
8
+ ## 1.2.11
9
+
10
+ ### Patch Changes
11
+
12
+ - 53018ea: tabs added preload prop
13
+
1
14
  ## 1.2.10
2
15
 
3
16
  ### Patch Changes
@@ -1,11 +1,10 @@
1
1
  import { i as ThemeColor } from "../../../types-CbJroQxH.mjs";
2
2
  import { n as FieldProps } from "../../../Field-DhaPMGcl.mjs";
3
- import { ComponentPropsWithRef, RefObject } from "react";
3
+ import { ComponentProps } from "react";
4
4
  import { FieldName } from "@conform-to/react/future";
5
5
  //#region src/components/fields/range/Range.d.ts
6
- interface RangeProps$1 extends Omit<ComponentPropsWithRef<"input">, "value" | "defaultValue" | "min" | "max" | "step"> {
7
- defaultValue?: number | string;
8
- value?: number | string;
6
+ interface RangeProps$1 extends Omit<ComponentProps<"input">, "value" | "defaultValue" | "min" | "max" | "step" | "onPointerDown" | "onPointerUp" | "onTouchEnd" | "ref"> {
7
+ value: number;
9
8
  additionalBarValue?: number;
10
9
  min?: number;
11
10
  max?: number;
@@ -16,23 +15,22 @@ interface RangeProps$1 extends Omit<ComponentPropsWithRef<"input">, "value" | "d
16
15
  valuesByTick?: number;
17
16
  color?: ThemeColor;
18
17
  formatter?: (str: number) => string;
19
- ref?: RefObject<HTMLInputElement>;
18
+ onChangeCommitted?: (valueAsNumber: number) => void;
20
19
  }
21
- declare function Range({ className, defaultValue, additionalBarValue, value: controlledValue, min, max, color, showMinMax, step, valuesByTick, showValue, ticks, formatter, onChange, ref, ...rest }: RangeProps$1): import("react").JSX.Element;
20
+ declare function Range({ className, additionalBarValue, value: controlledValue, min, max, color, showMinMax, step, valuesByTick, showValue, ticks, formatter, onChange, onChangeCommitted, ...rest }: RangeProps$1): import("react").JSX.Element;
22
21
  //#endregion
23
22
  //#region src/components/fields/range/AudioRange.d.ts
24
- interface RangeProps extends Omit<ComponentPropsWithRef<"input">, "value" | "defaultValue" | "min" | "max" | "step"> {
25
- defaultValue?: number | string;
26
- value?: number | string;
23
+ interface RangeProps extends Omit<ComponentProps<"input">, "value" | "defaultValue" | "min" | "max" | "step" | "onPointerDown" | "onPointerUp" | "onTouchEnd" | "onKeyDown" | "ref"> {
24
+ value: number;
27
25
  min?: number;
28
26
  max?: number;
29
27
  step?: number;
30
28
  color?: ThemeColor;
31
29
  formatter?: (str: number) => string;
32
- ref?: RefObject<HTMLInputElement>;
33
30
  valueClassName?: string;
31
+ onChangeCommitted?: (valueAsNumber: number) => void;
34
32
  }
35
- declare function AudioRange({ className, valueClassName, defaultValue, value: controlledValue, min, max, color, step, formatter, onChange, ref, ...rest }: RangeProps): import("react").JSX.Element;
33
+ declare function AudioRange({ className, valueClassName, value: controlledValue, min, max, color, step, formatter, onChange, onChangeCommitted, ...rest }: RangeProps): import("react").JSX.Element;
36
34
  //#endregion
37
35
  //#region src/components/fields/range/RangeField.d.ts
38
36
  interface Props extends Omit<FieldProps, "errors" | "children" | "group"> {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/components/fields/range/Range.tsx","../../../../src/components/fields/range/AudioRange.tsx","../../../../src/components/fields/range/RangeField.tsx"],"mappings":";;;;;UAKiB,qBAAmB,KAClC;EAGA;EACA;EAEA;EAEA;EACA;EACA;EAEA;EAEA;EAEA;EAEA;EAEA,QAAQ;EAER,aAAa;EAEb,MAAM,UAAU;;iBAKF,QACd,WACA,cACA,oBACA,OAAO,iBACP,KACA,KACA,OACA,YACA,MACA,cACA,WACA,OACA,WACA,UACA,QACG,QACF,+BAAU,IAAA;;;UCnCI,mBAAmB,KAClC;EAGA;EACA;EAEA;EACA;EACA;EAEA,QAAQ;EAER,aAAa;EAEb,MAAM,UAAU;EAEhB;;iBAKc,aACd,WACA,gBACA,cACA,OAAO,iBACP,KACA,KACA,OACA,MACA,WACA,UACA,QACG,QACF,6BAAU,IAAA;;;UChDH,cAAc,KAAK;EAC3B,MAAM;EAEN;EACA;EACA;EACA;EACA;;iBAGc,aACd,MACA,KACA,KACA,MACA,YACA,WACA,IAAI,aACD,QACF,wBAAK,IAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/components/fields/range/Range.tsx","../../../../src/components/fields/range/AudioRange.tsx","../../../../src/components/fields/range/RangeField.tsx"],"mappings":";;;;;UAKiB,qBAAmB,KAClC;EAWA;EAEA;EAEA;EACA;EACA;EAEA;EAEA;EAEA;EAEA;EAEA,QAAQ;EAER,aAAa;EAEb,qBAAqB;;iBAKP,QACd,WACA,oBACA,OAAO,iBACP,KACA,KACA,OACA,YACA,MACA,cACA,WACA,OACA,WACA,UACA,sBACG,QACF,+BAAU,IAAA;;;UCzCI,mBAAmB,KAClC;EAYA;EAEA;EACA;EACA;EAEA,QAAQ;EAER,aAAa;EAEb;EAEA,qBAAqB;;iBAKP,aACd,WACA,gBACA,OAAO,iBACP,KACA,KACA,OACA,MACA,WACA,UACA,sBACG,QACF,6BAAU,IAAA;;;UCvDH,cAAc,KAAK;EAC3B,MAAM;EAEN;EACA;EACA;EACA;EACA;;iBAGc,aACd,MACA,KACA,KACA,MACA,YACA,WACA,IAAI,aACD,QACF,wBAAK,IAAA"}
@@ -1,31 +1,38 @@
1
1
  import { t as Field } from "../../../Field-DZmC5a1D.mjs";
2
2
  import { c } from "react/compiler-runtime";
3
- import { useMemo, useState } from "react";
3
+ import { useMemo, useRef, useState } from "react";
4
4
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
5
5
  import clsx from "clsx";
6
- import { useField } from "@conform-to/react/future";
6
+ import { useControl, useField } from "@conform-to/react/future";
7
7
  //#region src/components/fields/range/Range.tsx
8
8
  const trackBase$1 = "pointer-events-none absolute top-0 left-0 h-full";
9
- function Range({ className, defaultValue, additionalBarValue, value: controlledValue, min = 0, max = 100, color = "yellow", showMinMax = "onHover", step = 1, valuesByTick, showValue = true, ticks = false, formatter = (str) => str?.toString(), onChange, ref, ...rest }) {
10
- const isControlled = typeof controlledValue !== "undefined";
11
- const [unControlledValue, setUnControlledValue] = useState(defaultValue);
12
- const value = isControlled ? controlledValue : unControlledValue;
13
- const valueAsNumber = typeof value === "string" ? parseInt(value) : value;
9
+ function Range({ className, additionalBarValue, value: controlledValue, min = 0, max = 100, color = "yellow", showMinMax = "onHover", step = 1, valuesByTick, showValue = true, ticks = false, formatter = (str) => str?.toString(), onChange, onChangeCommitted, ...rest }) {
10
+ const rangeRef = useRef(null);
11
+ const [tempValue, setTempValue] = useState(void 0);
12
+ const isTemp = typeof tempValue !== "undefined";
13
+ const value = isTemp ? tempValue : controlledValue;
14
14
  const range = max - min;
15
- const percent = (valueAsNumber - min) / range;
15
+ const percent = (value - min) / range;
16
16
  const additionalPercent = additionalBarValue ? (additionalBarValue - min) / range : 0;
17
17
  const nbOfTicks = 1 + Math.floor(range / (valuesByTick ?? step ?? 5));
18
18
  const cssVars = useMemo(() => ({
19
- "--p8n-range-c-bg": `var(--color-custom-1)`,
20
- "--p8n-range-c-bg-2": `var(--color-custom-2)`,
21
- "--p8n-range-c-fg": `var(--color-custom-4)`,
22
19
  "--p8n-range-progress-percent": `${percent * 100}%`,
23
20
  "--p8n-range-additional-percent": `${additionalPercent * 100}%`
24
21
  }), [percent, additionalPercent]);
25
22
  const handleChange = (e) => {
26
- if (!isControlled) setUnControlledValue(e.target.valueAsNumber);
27
- if (onChange) onChange(e);
23
+ if (isTemp) setTempValue(e.target.valueAsNumber);
24
+ onChange?.(e);
28
25
  };
26
+ function handleSeekStart() {
27
+ setTempValue(rangeRef.current.valueAsNumber);
28
+ }
29
+ function handleSeekEnd() {
30
+ setTempValue(void 0);
31
+ onChangeCommitted?.(rangeRef.current.valueAsNumber);
32
+ }
33
+ function handleKeyUp() {
34
+ onChangeCommitted?.(rangeRef.current.valueAsNumber);
35
+ }
29
36
  return /* @__PURE__ */ jsxs("div", {
30
37
  className: clsx("group relative flex", className),
31
38
  style: cssVars,
@@ -43,13 +50,13 @@ function Range({ className, defaultValue, additionalBarValue, value: controlledV
43
50
  children: /* @__PURE__ */ jsxs("div", {
44
51
  className: "relative h-2 w-[calc(100%-2rem)]",
45
52
  children: [
46
- /* @__PURE__ */ jsx("div", { className: clsx(trackBase$1, "track w-full bg-(--p8n-range-c-bg) after:absolute after:left-[calc(100%-.25rem)] after:h-2 after:w-2 after:rounded-full after:bg-(--p8n-range-c-bg)") }),
47
- typeof additionalBarValue !== "undefined" && /* @__PURE__ */ jsx("div", { className: clsx(trackBase$1, "w-(--p8n-range-additional-percent) rounded-[3px] bg-(--p8n-range-c-bg-2) before:absolute before:-left-1 before:h-2 before:w-2 before:rounded-full before:bg-(--p8n-range-c-bg-2)") }),
53
+ /* @__PURE__ */ jsx("div", { className: clsx(trackBase$1, "track w-full bg-custom-1 after:absolute after:left-[calc(100%-.25rem)] after:h-2 after:w-2 after:rounded-full after:bg-custom-1") }),
54
+ typeof additionalBarValue !== "undefined" && /* @__PURE__ */ jsx("div", { className: clsx(trackBase$1, "w-(--p8n-range-additional-percent) rounded-[3px] bg-custom-2 before:absolute before:-left-1 before:h-2 before:w-2 before:rounded-full before:bg-custom-2") }),
48
55
  showValue && /* @__PURE__ */ jsx("div", {
49
56
  className: "text-body-sm pointer-events-none absolute bottom-4 left-(--p8n-range-progress-percent) -translate-x-2/4",
50
- children: formatter(valueAsNumber)
57
+ children: formatter(value)
51
58
  }),
52
- /* @__PURE__ */ jsx("div", { className: clsx(trackBase$1, "w-(--p8n-range-progress-percent) rounded-[3px] bg-(--p8n-range-c-fg) before:absolute before:-left-1 before:h-2 before:w-2 before:rounded-full before:bg-(--p8n-range-c-fg)") }),
59
+ /* @__PURE__ */ jsx("div", { className: clsx(trackBase$1, "w-(--p8n-range-progress-percent) rounded-[3px] bg-custom-4 before:absolute before:-left-1 before:h-2 before:w-2 before:rounded-full before:bg-custom-4") }),
53
60
  ticks && /* @__PURE__ */ jsx("div", {
54
61
  className: clsx(trackBase$1, "-mx-0.5 flex w-[calc(100%+0.25rem)] items-center justify-between"),
55
62
  children: Array.from({ length: nbOfTicks }).map((_, i) => /* @__PURE__ */ jsx("span", { className: "bg-gray-0 h-1 w-1 rounded-full" }, i))
@@ -60,13 +67,16 @@ function Range({ className, defaultValue, additionalBarValue, value: controlledV
60
67
  /* @__PURE__ */ jsx("input", {
61
68
  type: "range",
62
69
  className: clsx("p8n-input-range h-8 w-full min-w-0 bg-transparent outline-offset-[0.75rem]"),
63
- ref,
70
+ ref: rangeRef,
64
71
  min,
65
72
  max,
66
73
  step,
67
- defaultValue,
68
- value: controlledValue,
74
+ value,
69
75
  onChange: handleChange,
76
+ onPointerDown: handleSeekStart,
77
+ onPointerUp: handleSeekEnd,
78
+ onTouchEnd: handleSeekEnd,
79
+ onKeyUp: handleKeyUp,
70
80
  ...rest
71
81
  })
72
82
  ]
@@ -83,12 +93,11 @@ const formatTime = (time) => {
83
93
  };
84
94
  const trackBase = "pointer-events-none absolute top-0 left-0 h-full";
85
95
  function AudioRange(t0) {
86
- const $ = c(57);
96
+ const $ = c(63);
87
97
  let className;
88
98
  let controlledValue;
89
- let defaultValue;
90
99
  let onChange;
91
- let ref;
100
+ let onChangeCommitted;
92
101
  let rest;
93
102
  let t1;
94
103
  let t2;
@@ -97,269 +106,269 @@ function AudioRange(t0) {
97
106
  let t5;
98
107
  let valueClassName;
99
108
  if ($[0] !== t0) {
100
- ({className, valueClassName, defaultValue, value: controlledValue, min: t1, max: t2, color: t3, step: t4, formatter: t5, onChange, ref, ...rest} = t0);
109
+ ({className, valueClassName, value: controlledValue, min: t1, max: t2, color: t3, step: t4, formatter: t5, onChange, onChangeCommitted, ...rest} = t0);
101
110
  $[0] = t0;
102
111
  $[1] = className;
103
112
  $[2] = controlledValue;
104
- $[3] = defaultValue;
105
- $[4] = onChange;
106
- $[5] = ref;
107
- $[6] = rest;
108
- $[7] = t1;
109
- $[8] = t2;
110
- $[9] = t3;
111
- $[10] = t4;
112
- $[11] = t5;
113
- $[12] = valueClassName;
113
+ $[3] = onChange;
114
+ $[4] = onChangeCommitted;
115
+ $[5] = rest;
116
+ $[6] = t1;
117
+ $[7] = t2;
118
+ $[8] = t3;
119
+ $[9] = t4;
120
+ $[10] = t5;
121
+ $[11] = valueClassName;
114
122
  } else {
115
123
  className = $[1];
116
124
  controlledValue = $[2];
117
- defaultValue = $[3];
118
- onChange = $[4];
119
- ref = $[5];
120
- rest = $[6];
121
- t1 = $[7];
122
- t2 = $[8];
123
- t3 = $[9];
124
- t4 = $[10];
125
- t5 = $[11];
126
- valueClassName = $[12];
125
+ onChange = $[3];
126
+ onChangeCommitted = $[4];
127
+ rest = $[5];
128
+ t1 = $[6];
129
+ t2 = $[7];
130
+ t3 = $[8];
131
+ t4 = $[9];
132
+ t5 = $[10];
133
+ valueClassName = $[11];
127
134
  }
128
135
  const min = t1 === void 0 ? 0 : t1;
129
136
  const max = t2 === void 0 ? 100 : t2;
130
137
  const color = t3 === void 0 ? "yellow" : t3;
131
138
  const step = t4 === void 0 ? 1 : t4;
132
139
  const formatter = t5 === void 0 ? formatTime : t5;
133
- const isControlled = typeof controlledValue !== "undefined";
134
- const [unControlledValue, setUnControlledValue] = useState(defaultValue);
135
- const value = isControlled ? controlledValue : unControlledValue;
136
- const valueAsNumber = typeof value === "string" ? parseInt(value) : value;
140
+ const rangeRef = useRef(null);
141
+ const [tempValue, setTempValue] = useState(void 0);
142
+ const isTemp = typeof tempValue !== "undefined";
143
+ const value = isTemp ? tempValue : controlledValue;
137
144
  const range = max - min;
138
- const t6 = `${(valueAsNumber - min) / range * 100}%`;
145
+ const t6 = `${(value - min) / range * 100}%`;
139
146
  let t7;
140
- if ($[13] !== t6) {
141
- t7 = {
142
- "--p8n-range-c-bg": "var(--color-custom-1)",
143
- "--p8n-range-c-fg": "var(--color-custom-4)",
144
- "--p8n-range-progress-percent": t6
145
- };
146
- $[13] = t6;
147
- $[14] = t7;
148
- } else t7 = $[14];
147
+ if ($[12] !== t6) {
148
+ t7 = { "--p8n-range-progress-percent": t6 };
149
+ $[12] = t6;
150
+ $[13] = t7;
151
+ } else t7 = $[13];
149
152
  const cssVars = t7;
150
153
  let t8;
151
- if ($[15] !== isControlled || $[16] !== onChange) {
154
+ if ($[14] !== isTemp || $[15] !== onChange) {
152
155
  t8 = (e) => {
153
- if (!isControlled) setUnControlledValue(e.target.valueAsNumber);
154
- if (onChange) onChange(e);
156
+ if (isTemp) setTempValue(e.target.valueAsNumber);
157
+ onChange?.(e);
155
158
  };
156
- $[15] = isControlled;
157
- $[16] = onChange;
158
- $[17] = t8;
159
- } else t8 = $[17];
159
+ $[14] = isTemp;
160
+ $[15] = onChange;
161
+ $[16] = t8;
162
+ } else t8 = $[16];
160
163
  const handleChange = t8;
161
164
  let t9;
162
- if ($[18] !== valueClassName) {
163
- t9 = clsx("text-right", valueClassName);
164
- $[18] = valueClassName;
165
- $[19] = t9;
166
- } else t9 = $[19];
165
+ if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
166
+ t9 = function handleSeekStart() {
167
+ setTempValue(rangeRef.current.valueAsNumber);
168
+ };
169
+ $[17] = t9;
170
+ } else t9 = $[17];
171
+ const handleSeekStart = t9;
167
172
  let t10;
168
- if ($[20] !== formatter || $[21] !== valueAsNumber) {
169
- t10 = formatter(valueAsNumber);
170
- $[20] = formatter;
171
- $[21] = valueAsNumber;
172
- $[22] = t10;
173
- } else t10 = $[22];
173
+ if ($[18] !== onChangeCommitted) {
174
+ t10 = function handleSeekEnd() {
175
+ setTempValue(void 0);
176
+ onChangeCommitted?.(rangeRef.current.valueAsNumber);
177
+ };
178
+ $[18] = onChangeCommitted;
179
+ $[19] = t10;
180
+ } else t10 = $[19];
181
+ const handleSeekEnd = t10;
174
182
  let t11;
175
- if ($[23] !== t10 || $[24] !== t9) {
176
- t11 = /* @__PURE__ */ jsx("div", {
177
- className: t9,
178
- children: t10
179
- });
180
- $[23] = t10;
181
- $[24] = t9;
182
- $[25] = t11;
183
- } else t11 = $[25];
183
+ if ($[20] !== max || $[21] !== min || $[22] !== onChangeCommitted) {
184
+ t11 = function handleKeyDown(e_0) {
185
+ const currentVal = rangeRef.current.valueAsNumber;
186
+ bb41: switch (e_0.code) {
187
+ case "ArrowLeft":
188
+ e_0.preventDefault();
189
+ onChangeCommitted?.(Math.max(min, currentVal - 5));
190
+ break bb41;
191
+ case "ArrowRight":
192
+ e_0.preventDefault();
193
+ onChangeCommitted?.(Math.min(max, currentVal + 5));
194
+ }
195
+ };
196
+ $[20] = max;
197
+ $[21] = min;
198
+ $[22] = onChangeCommitted;
199
+ $[23] = t11;
200
+ } else t11 = $[23];
201
+ const handleKeyDown = t11;
184
202
  let t12;
185
- if ($[26] !== className) {
186
- t12 = clsx("group relative flex flex-1", className);
187
- $[26] = className;
188
- $[27] = t12;
189
- } else t12 = $[27];
203
+ if ($[24] !== valueClassName) {
204
+ t12 = clsx("text-right", valueClassName);
205
+ $[24] = valueClassName;
206
+ $[25] = t12;
207
+ } else t12 = $[25];
190
208
  let t13;
191
- if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
192
- t13 = clsx(trackBase, "right-0 bottom-0 flex items-center justify-center");
209
+ if ($[26] !== formatter || $[27] !== value) {
210
+ t13 = formatter(value);
211
+ $[26] = formatter;
212
+ $[27] = value;
193
213
  $[28] = t13;
194
214
  } else t13 = $[28];
195
215
  let t14;
196
- if ($[29] === Symbol.for("react.memo_cache_sentinel")) {
216
+ if ($[29] !== t12 || $[30] !== t13) {
197
217
  t14 = /* @__PURE__ */ jsx("div", {
198
- className: t13,
218
+ className: t12,
219
+ children: t13
220
+ });
221
+ $[29] = t12;
222
+ $[30] = t13;
223
+ $[31] = t14;
224
+ } else t14 = $[31];
225
+ let t15;
226
+ if ($[32] !== className) {
227
+ t15 = clsx("group relative flex flex-1", className);
228
+ $[32] = className;
229
+ $[33] = t15;
230
+ } else t15 = $[33];
231
+ let t16;
232
+ if ($[34] === Symbol.for("react.memo_cache_sentinel")) {
233
+ t16 = clsx(trackBase, "right-0 bottom-0 flex items-center justify-center");
234
+ $[34] = t16;
235
+ } else t16 = $[34];
236
+ let t17;
237
+ if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
238
+ t17 = /* @__PURE__ */ jsx("div", {
239
+ className: t16,
199
240
  children: /* @__PURE__ */ jsxs("div", {
200
241
  className: "relative h-2 w-[calc(100%-2rem)]",
201
- children: [/* @__PURE__ */ jsx("div", { className: clsx(trackBase, "track bg-custom-2/50 after:bg-custom-2/50 w-full after:absolute after:left-[calc(100%-.25rem)] after:h-2 after:w-2 after:rounded-full after:mask-l-from-50% after:mask-l-to-transparent after:mask-l-to-50%") }), /* @__PURE__ */ jsx("div", { className: clsx(trackBase, "from-gray-8/70 to-gray-8/50 before:bg-gray-8/70 bg-linear-to-r from-5%", "group-hover:from-custom-4 group-hover:to-custom-3 group-hover:before:bg-custom-4 group-hover:bg-linear-to-r", "w-(--p8n-range-progress-percent) rounded-r-[4px]", "before:absolute before:-left-1 before:h-2 before:w-2 before:rounded-full before:mask-r-from-50% before:mask-r-to-transparent before:mask-r-to-50%") })]
242
+ children: [/* @__PURE__ */ jsx("div", { className: clsx(trackBase, "track bg-custom-2/50 after:bg-custom-2/50 w-full after:absolute after:left-[calc(100%-.25rem)] after:h-2 after:w-2 after:rounded-full after:mask-l-from-50% after:mask-l-to-transparent after:mask-l-to-50%") }), /* @__PURE__ */ jsx("div", { className: clsx(trackBase, "from-gray-8/70 to-gray-8/50 before:bg-gray-8/70 bg-linear-to-r from-5%", "group-hover:from-custom-4 group-hover:to-custom-3 group-hover:before:bg-custom-4 group-hover:bg-linear-to-r", "w-(--p8n-range-progress-percent) rounded-r-sm", "before:absolute before:-left-1 before:h-2 before:w-2 before:rounded-full before:mask-r-from-50% before:mask-r-to-transparent before:mask-r-to-50%") })]
202
243
  })
203
244
  });
204
- $[29] = t14;
205
- } else t14 = $[29];
206
- let t15;
207
- if ($[30] === Symbol.for("react.memo_cache_sentinel")) {
208
- t15 = clsx("p8n-input-audio-range h-8 w-full min-w-0 cursor-pointer bg-transparent outline-offset-[0.75rem]");
209
- $[30] = t15;
210
- } else t15 = $[30];
211
- let t16;
212
- if ($[31] !== controlledValue || $[32] !== defaultValue || $[33] !== handleChange || $[34] !== max || $[35] !== min || $[36] !== ref || $[37] !== rest || $[38] !== step) {
213
- t16 = /* @__PURE__ */ jsx("input", {
245
+ $[35] = t17;
246
+ } else t17 = $[35];
247
+ let t18;
248
+ if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
249
+ t18 = clsx("p8n-input-audio-range h-8 w-full min-w-0 cursor-pointer bg-transparent outline-offset-[0.75rem]");
250
+ $[36] = t18;
251
+ } else t18 = $[36];
252
+ let t19;
253
+ if ($[37] !== handleChange || $[38] !== handleKeyDown || $[39] !== handleSeekEnd || $[40] !== max || $[41] !== min || $[42] !== rest || $[43] !== step || $[44] !== value) {
254
+ t19 = /* @__PURE__ */ jsx("input", {
214
255
  autoComplete: "off",
215
256
  type: "range",
216
- className: t15,
217
- ref,
257
+ className: t18,
258
+ ref: rangeRef,
218
259
  min,
219
260
  max,
220
261
  step,
221
- defaultValue,
222
- value: controlledValue,
262
+ value,
223
263
  onChange: handleChange,
264
+ onPointerDown: handleSeekStart,
265
+ onPointerUp: handleSeekEnd,
266
+ onTouchEnd: handleSeekEnd,
267
+ onKeyDown: handleKeyDown,
224
268
  ...rest
225
269
  });
226
- $[31] = controlledValue;
227
- $[32] = defaultValue;
228
- $[33] = handleChange;
229
- $[34] = max;
230
- $[35] = min;
231
- $[36] = ref;
232
- $[37] = rest;
233
- $[38] = step;
234
- $[39] = t16;
235
- } else t16 = $[39];
236
- let t17;
237
- if ($[40] !== color || $[41] !== cssVars || $[42] !== t12 || $[43] !== t16) {
238
- t17 = /* @__PURE__ */ jsxs("div", {
239
- className: t12,
270
+ $[37] = handleChange;
271
+ $[38] = handleKeyDown;
272
+ $[39] = handleSeekEnd;
273
+ $[40] = max;
274
+ $[41] = min;
275
+ $[42] = rest;
276
+ $[43] = step;
277
+ $[44] = value;
278
+ $[45] = t19;
279
+ } else t19 = $[45];
280
+ let t20;
281
+ if ($[46] !== color || $[47] !== cssVars || $[48] !== t15 || $[49] !== t19) {
282
+ t20 = /* @__PURE__ */ jsxs("div", {
283
+ className: t15,
240
284
  style: cssVars,
241
285
  "data-color": color,
242
- children: [t14, t16]
286
+ children: [t17, t19]
243
287
  });
244
- $[40] = color;
245
- $[41] = cssVars;
246
- $[42] = t12;
247
- $[43] = t16;
248
- $[44] = t17;
249
- } else t17 = $[44];
250
- let t18;
251
- if ($[45] !== valueClassName) {
252
- t18 = clsx(valueClassName);
253
- $[45] = valueClassName;
254
- $[46] = t18;
255
- } else t18 = $[46];
256
- let t19;
257
- if ($[47] !== formatter || $[48] !== max) {
258
- t19 = formatter(max);
259
- $[47] = formatter;
260
- $[48] = max;
288
+ $[46] = color;
289
+ $[47] = cssVars;
290
+ $[48] = t15;
261
291
  $[49] = t19;
262
- } else t19 = $[49];
263
- let t20;
264
- if ($[50] !== t18 || $[51] !== t19) {
265
- t20 = /* @__PURE__ */ jsx("div", {
266
- className: t18,
267
- children: t19
268
- });
269
- $[50] = t18;
270
- $[51] = t19;
271
- $[52] = t20;
272
- } else t20 = $[52];
292
+ $[50] = t20;
293
+ } else t20 = $[50];
273
294
  let t21;
274
- if ($[53] !== t11 || $[54] !== t17 || $[55] !== t20) {
275
- t21 = /* @__PURE__ */ jsxs("div", {
295
+ if ($[51] !== valueClassName) {
296
+ t21 = clsx(valueClassName);
297
+ $[51] = valueClassName;
298
+ $[52] = t21;
299
+ } else t21 = $[52];
300
+ let t22;
301
+ if ($[53] !== formatter || $[54] !== max) {
302
+ t22 = formatter(max);
303
+ $[53] = formatter;
304
+ $[54] = max;
305
+ $[55] = t22;
306
+ } else t22 = $[55];
307
+ let t23;
308
+ if ($[56] !== t21 || $[57] !== t22) {
309
+ t23 = /* @__PURE__ */ jsx("div", {
310
+ className: t21,
311
+ children: t22
312
+ });
313
+ $[56] = t21;
314
+ $[57] = t22;
315
+ $[58] = t23;
316
+ } else t23 = $[58];
317
+ let t24;
318
+ if ($[59] !== t14 || $[60] !== t20 || $[61] !== t23) {
319
+ t24 = /* @__PURE__ */ jsxs("div", {
276
320
  className: "flex items-center",
277
321
  children: [
278
- t11,
279
- t17,
280
- t20
322
+ t14,
323
+ t20,
324
+ t23
281
325
  ]
282
326
  });
283
- $[53] = t11;
284
- $[54] = t17;
285
- $[55] = t20;
286
- $[56] = t21;
287
- } else t21 = $[56];
288
- return t21;
327
+ $[59] = t14;
328
+ $[60] = t20;
329
+ $[61] = t23;
330
+ $[62] = t24;
331
+ } else t24 = $[62];
332
+ return t24;
289
333
  }
290
334
  //#endregion
291
335
  //#region src/components/fields/range/RangeField.tsx
292
- function RangeField(t0) {
293
- const $ = c(23);
294
- let forcedId;
295
- let max;
296
- let min;
297
- let name;
298
- let rest;
299
- let showMinMax;
300
- let showValue;
301
- let step;
302
- if ($[0] !== t0) {
303
- ({name, min, max, step, showMinMax, showValue, id: forcedId, ...rest} = t0);
304
- $[0] = t0;
305
- $[1] = forcedId;
306
- $[2] = max;
307
- $[3] = min;
308
- $[4] = name;
309
- $[5] = rest;
310
- $[6] = showMinMax;
311
- $[7] = showValue;
312
- $[8] = step;
313
- } else {
314
- forcedId = $[1];
315
- max = $[2];
316
- min = $[3];
317
- name = $[4];
318
- rest = $[5];
319
- showMinMax = $[6];
320
- showValue = $[7];
321
- step = $[8];
322
- }
336
+ function RangeField({ name, min, max, step, showMinMax, showValue, id: forcedId, ...rest }) {
323
337
  const field = useField(name);
324
338
  const id = forcedId ?? field.id;
325
- const numberValue = field.defaultValue ? parseInt(field.defaultValue) : void 0;
326
- let t1;
327
- if ($[9] !== field.name || $[10] !== max || $[11] !== min || $[12] !== numberValue || $[13] !== showMinMax || $[14] !== showValue || $[15] !== step) {
328
- t1 = /* @__PURE__ */ jsx(Range, {
329
- name: field.name,
330
- defaultValue: numberValue,
339
+ const control = useControl({
340
+ defaultValue: field.defaultValue,
341
+ parse(payload) {
342
+ if (typeof payload !== "string") throw new Error("range input must return string");
343
+ return parseInt(payload);
344
+ },
345
+ serialize(value) {
346
+ return value.toString();
347
+ }
348
+ });
349
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("input", {
350
+ type: "text",
351
+ name: field.name,
352
+ ref: control.register,
353
+ hidden: true
354
+ }), /* @__PURE__ */ jsx(Field, {
355
+ id,
356
+ errors: field.errors,
357
+ "data-testid": field.name,
358
+ ...rest,
359
+ children: /* @__PURE__ */ jsx(Range, {
360
+ value: control.payload ?? 0,
331
361
  min,
332
362
  max,
333
363
  step,
334
364
  showMinMax,
335
- showValue
336
- });
337
- $[9] = field.name;
338
- $[10] = max;
339
- $[11] = min;
340
- $[12] = numberValue;
341
- $[13] = showMinMax;
342
- $[14] = showValue;
343
- $[15] = step;
344
- $[16] = t1;
345
- } else t1 = $[16];
346
- let t2;
347
- if ($[17] !== field.errors || $[18] !== field.name || $[19] !== id || $[20] !== rest || $[21] !== t1) {
348
- t2 = /* @__PURE__ */ jsx(Field, {
349
- id,
350
- errors: field.errors,
351
- "data-testid": field.name,
352
- ...rest,
353
- children: t1
354
- });
355
- $[17] = field.errors;
356
- $[18] = field.name;
357
- $[19] = id;
358
- $[20] = rest;
359
- $[21] = t1;
360
- $[22] = t2;
361
- } else t2 = $[22];
362
- return t2;
365
+ showValue,
366
+ onChangeCommitted: (value_0) => {
367
+ control.change(value_0);
368
+ },
369
+ onBlur: () => control.blur()
370
+ })
371
+ })] });
363
372
  }
364
373
  //#endregion
365
374
  export { AudioRange, Range, RangeField };