@selectwin/kit 0.1.210 → 0.1.212

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.
@@ -10,6 +10,8 @@ type SelectLabelRowOwnProps = {
10
10
  action?: ReactNode;
11
11
  /** 0.1.198: o "(opcional)" depois do rótulo, dentro dele (o leitor de tela ouve "Nome (opcional)"). */
12
12
  optional?: boolean;
13
+ /** 0.1.211: o `id` do `<label>` — para outro controle do mesmo campo tomar o nome dele (`aria-labelledby`). */
14
+ labelId?: string;
13
15
  };
14
16
  export type SelectLabelRowProps = SelectLabelRowOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectLabelRowOwnProps>;
15
17
  export declare const SelectLabelRow: import('react').ForwardRefExoticComponent<SelectLabelRowOwnProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectLabelRowOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
@@ -5,20 +5,21 @@ import { SelectInfoTip as l } from "./SelectInfoTip.js";
5
5
  import { forwardRef as u, useId as d, useState as f } from "react";
6
6
  import { jsx as p, jsxs as m } from "react/jsx-runtime";
7
7
  //#region src/SelectField.tsx
8
- var h = u(function({ htmlFor: e, label: t, help: n, info: r, action: i, optional: o = !1, className: s, ...u }, d) {
9
- let f = c();
8
+ var h = u(function({ htmlFor: e, label: t, help: n, info: r, action: i, optional: o = !1, labelId: s, className: u, ...d }, f) {
9
+ let h = c();
10
10
  return /* @__PURE__ */ m("div", {
11
- ref: d,
12
- ...u,
13
- className: `select-field__labelrow${s ? " " + s : ""}`,
11
+ ref: f,
12
+ ...d,
13
+ className: `select-field__labelrow${u ? " " + u : ""}`,
14
14
  children: [/* @__PURE__ */ m("span", {
15
15
  className: "select-field__labelwrap",
16
16
  children: [/* @__PURE__ */ m("label", {
17
17
  className: "select-field__label",
18
18
  htmlFor: e,
19
+ id: s,
19
20
  children: [t, o && /* @__PURE__ */ m("span", {
20
21
  className: "select-field__optional",
21
- children: [" ", f.common.optional]
22
+ children: [" ", h.common.optional]
22
23
  })]
23
24
  }), n != null && n !== "" ? /* @__PURE__ */ p(l, { content: n }) : r && /* @__PURE__ */ p("span", {
24
25
  className: "select-field__info",
@@ -74,8 +74,16 @@ export interface SelectFlowNodeProps {
74
74
  invalid?: boolean;
75
75
  onClick?: () => void;
76
76
  ariaLabel?: string;
77
+ /**
78
+ * Remover o bloco: com ele, o nó ganha uma lixeira no canto de cima, à direita. Ela aparece com o mouse em cima, com
79
+ * o foco dentro (Tab do nó para ela) ou com o nó selecionado; no toque, só com o nó selecionado. Escondida, não
80
+ * recebe clique nem foco: um toque no canto do nó não apaga o que não se via. Confirmar ou desfazer é de quem chama.
81
+ */
82
+ onRemove?: () => void;
83
+ /** Nome acessível e dica da lixeira, com o que sai (ex.: "Remover o envio por SMS"). Padrão: "Remover". */
84
+ removeLabel?: string;
77
85
  }
78
- export declare function SelectFlowNode({ x, y, width, height, shape, tone, icon, order, eyebrow, title, subtitle, tags, titleTone, selected, active, muted, invalid, onClick, ariaLabel, }: SelectFlowNodeProps): import("react").JSX.Element;
86
+ export declare function SelectFlowNode({ x, y, width, height, shape, tone, icon, order, eyebrow, title, subtitle, tags, titleTone, selected, active, muted, invalid, onClick, ariaLabel, onRemove, removeLabel, }: SelectFlowNodeProps): import("react").JSX.Element;
79
87
  export interface SelectFlowLayoutProps {
80
88
  title: ReactNode;
81
89
  subtitle?: ReactNode;
@@ -1,34 +1,34 @@
1
1
  /* empty css */
2
- import { ArrowLeftIcon as e, CloseIcon as t, MinusCircleIcon as n, PlusIcon as r } from "./icons.js";
3
- import { SelectAlert as i } from "./SelectAlert.js";
4
- import { SelectIconButton as a } from "./SelectIconButton.js";
5
- import { useId as o, useState as s } from "react";
6
- import { jsx as c, jsxs as l } from "react/jsx-runtime";
2
+ import { ArrowLeftIcon as e, CloseIcon as t, MinusCircleIcon as n, PlusIcon as r, TrashIcon as i } from "./icons.js";
3
+ import { SelectAlert as a } from "./SelectAlert.js";
4
+ import { SelectIconButton as o } from "./SelectIconButton.js";
5
+ import { useId as s, useState as c } from "react";
6
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
7
7
  //#region src/SelectFlowCanvas.tsx
8
- var u = (e) => Math.round(e * 100) / 100;
9
- function d({ width: e, height: t, edges: i, labels: d = [], pluses: f = [], children: p, zoom: m, defaultZoom: h = 1, onZoomChange: g, minZoom: _ = .5, maxZoom: v = 1.3, onBackgroundClick: y, ariaLabel: b }) {
10
- let x = o().replace(/:/g, ""), [S, C] = s(h), w = m ?? S, T = (e) => {
11
- let t = u(Math.min(v, Math.max(_, e)));
8
+ var d = (e) => Math.round(e * 100) / 100;
9
+ function f({ width: e, height: t, edges: i, labels: a = [], pluses: f = [], children: p, zoom: m, defaultZoom: h = 1, onZoomChange: g, minZoom: _ = .5, maxZoom: v = 1.3, onBackgroundClick: y, ariaLabel: b }) {
10
+ let x = s().replace(/:/g, ""), [S, C] = c(h), w = m ?? S, T = (e) => {
11
+ let t = d(Math.min(v, Math.max(_, e)));
12
12
  m === void 0 && C(t), g == null || g(t);
13
13
  }, E = `select-flow-arrow-${x}`, D = `select-flow-arrow-on-${x}`;
14
- return /* @__PURE__ */ l("div", {
14
+ return /* @__PURE__ */ u("div", {
15
15
  className: "select-flow",
16
16
  role: "region",
17
17
  "aria-label": b,
18
- children: [/* @__PURE__ */ c("div", {
18
+ children: [/* @__PURE__ */ l("div", {
19
19
  className: "select-flow__scroll",
20
20
  onClick: (e) => {
21
21
  e.target.dataset.flowBackground === "true" && (y == null || y());
22
22
  },
23
23
  "data-flow-background": "true",
24
- children: /* @__PURE__ */ c("div", {
24
+ children: /* @__PURE__ */ l("div", {
25
25
  className: "select-flow__sizer",
26
26
  style: {
27
27
  width: e * w,
28
28
  height: t * w
29
29
  },
30
30
  "data-flow-background": "true",
31
- children: /* @__PURE__ */ l("div", {
31
+ children: /* @__PURE__ */ u("div", {
32
32
  className: "select-flow__stage",
33
33
  style: {
34
34
  width: e,
@@ -37,12 +37,12 @@ function d({ width: e, height: t, edges: i, labels: d = [], pluses: f = [], chil
37
37
  },
38
38
  "data-flow-background": "true",
39
39
  children: [
40
- /* @__PURE__ */ l("svg", {
40
+ /* @__PURE__ */ u("svg", {
41
41
  className: "select-flow__edges",
42
42
  width: e,
43
43
  height: t,
44
44
  "aria-hidden": "true",
45
- children: [/* @__PURE__ */ l("defs", { children: [/* @__PURE__ */ c("marker", {
45
+ children: [/* @__PURE__ */ u("defs", { children: [/* @__PURE__ */ l("marker", {
46
46
  id: E,
47
47
  viewBox: "0 0 10 10",
48
48
  refX: "8",
@@ -50,11 +50,11 @@ function d({ width: e, height: t, edges: i, labels: d = [], pluses: f = [], chil
50
50
  markerWidth: "7",
51
51
  markerHeight: "7",
52
52
  orient: "auto-start-reverse",
53
- children: /* @__PURE__ */ c("path", {
53
+ children: /* @__PURE__ */ l("path", {
54
54
  className: "select-flow__arrow",
55
55
  d: "M 0 0 L 10 5 L 0 10 z"
56
56
  })
57
- }), /* @__PURE__ */ c("marker", {
57
+ }), /* @__PURE__ */ l("marker", {
58
58
  id: D,
59
59
  viewBox: "0 0 10 10",
60
60
  refX: "8",
@@ -62,17 +62,17 @@ function d({ width: e, height: t, edges: i, labels: d = [], pluses: f = [], chil
62
62
  markerWidth: "7",
63
63
  markerHeight: "7",
64
64
  orient: "auto-start-reverse",
65
- children: /* @__PURE__ */ c("path", {
65
+ children: /* @__PURE__ */ l("path", {
66
66
  className: "select-flow__arrow select-flow__arrow--on",
67
67
  d: "M 0 0 L 10 5 L 0 10 z"
68
68
  })
69
- })] }), i.map((e) => /* @__PURE__ */ c("path", {
69
+ })] }), i.map((e) => /* @__PURE__ */ l("path", {
70
70
  d: e.d,
71
71
  className: `select-flow__edge${e.state === "on" ? " select-flow__edge--on" : e.state === "muted" ? " select-flow__edge--muted" : ""}`,
72
72
  markerEnd: `url(#${e.state === "on" ? D : E})`
73
73
  }, e.id))]
74
74
  }),
75
- d.map((e) => /* @__PURE__ */ c("span", {
75
+ a.map((e) => /* @__PURE__ */ l("span", {
76
76
  className: `select-flow__label${e.tone === "yes" ? " select-flow__label--yes" : ""}${e.active ? " select-flow__label--on" : ""}`,
77
77
  style: {
78
78
  left: e.x,
@@ -81,7 +81,7 @@ function d({ width: e, height: t, edges: i, labels: d = [], pluses: f = [], chil
81
81
  children: e.text
82
82
  }, e.id)),
83
83
  p,
84
- f.map((e) => /* @__PURE__ */ c("button", {
84
+ f.map((e) => /* @__PURE__ */ l("button", {
85
85
  type: "button",
86
86
  className: "select-flow__plus",
87
87
  style: {
@@ -91,30 +91,30 @@ function d({ width: e, height: t, edges: i, labels: d = [], pluses: f = [], chil
91
91
  title: e.label,
92
92
  "aria-label": e.label,
93
93
  onClick: e.onClick,
94
- children: /* @__PURE__ */ c(r, {})
94
+ children: /* @__PURE__ */ l(r, {})
95
95
  }, e.id))
96
96
  ]
97
97
  })
98
98
  })
99
- }), /* @__PURE__ */ l("div", {
99
+ }), /* @__PURE__ */ u("div", {
100
100
  className: "select-flow__zoom",
101
101
  children: [
102
- /* @__PURE__ */ c(a, {
103
- icon: /* @__PURE__ */ c(n, {}),
102
+ /* @__PURE__ */ l(o, {
103
+ icon: /* @__PURE__ */ l(n, {}),
104
104
  label: "Diminuir o zoom",
105
105
  size: "sm",
106
106
  disabled: w <= _,
107
107
  onClick: () => T(w - .1)
108
108
  }),
109
- /* @__PURE__ */ l("button", {
109
+ /* @__PURE__ */ u("button", {
110
110
  type: "button",
111
111
  className: "select-flow__zoomvalue",
112
112
  onClick: () => T(1),
113
113
  title: "Voltar a 100%",
114
114
  children: [Math.round(w * 100), "%"]
115
115
  }),
116
- /* @__PURE__ */ c(a, {
117
- icon: /* @__PURE__ */ c(r, {}),
116
+ /* @__PURE__ */ l(o, {
117
+ icon: /* @__PURE__ */ l(r, {}),
118
118
  label: "Aumentar o zoom",
119
119
  size: "sm",
120
120
  disabled: w >= v,
@@ -124,149 +124,192 @@ function d({ width: e, height: t, edges: i, labels: d = [], pluses: f = [], chil
124
124
  })]
125
125
  });
126
126
  }
127
- function f({ x: e, y: t, width: n, height: r, shape: i = "card", tone: a = "neutral", icon: o, order: s, eyebrow: u, title: d, subtitle: f, tags: p, titleTone: m = "default", selected: h = !1, active: g = !1, muted: _ = !1, invalid: v = !1, onClick: y, ariaLabel: b }) {
128
- let x = `${h ? " is-selected" : v ? " is-invalid" : g ? " is-on" : ""}${_ ? " is-muted" : ""}`, S = {
127
+ function p({ x: e, y: t, width: n, height: r, shape: a = "card", tone: o = "neutral", icon: s, order: c, eyebrow: d, title: f, subtitle: p, tags: h, titleTone: g = "default", selected: _ = !1, active: v = !1, muted: y = !1, invalid: b = !1, onClick: x, ariaLabel: S, onRemove: C, removeLabel: w = "Remover" }) {
128
+ let T = m({
129
+ shape: a,
130
+ tone: o,
131
+ icon: s,
132
+ order: c,
133
+ eyebrow: d,
134
+ title: f,
135
+ subtitle: p,
136
+ tags: h,
137
+ titleTone: g,
138
+ selected: _,
139
+ active: v,
140
+ muted: y,
141
+ invalid: b,
142
+ onClick: x,
143
+ ariaLabel: S
144
+ }, C ? {
145
+ left: 0,
146
+ top: 0,
147
+ width: n,
148
+ height: r
149
+ } : {
129
150
  left: e,
130
151
  top: t,
131
152
  width: n,
132
153
  height: r
133
- }, C = d != null && /* @__PURE__ */ c("span", {
134
- className: `select-flownode__title${m === "warning" ? " select-flownode__title--warning" : ""}`,
135
- children: d
136
154
  });
137
- return i === "decision" ? /* @__PURE__ */ c("button", {
155
+ return C ? /* @__PURE__ */ u("div", {
156
+ className: `select-flownode-slot select-flownode-slot--${a}${_ ? " is-selected" : ""}`,
157
+ style: {
158
+ left: e,
159
+ top: t,
160
+ width: n,
161
+ height: r
162
+ },
163
+ children: [T, /* @__PURE__ */ l("button", {
164
+ type: "button",
165
+ className: "select-flownode__remove",
166
+ "aria-label": w,
167
+ title: w,
168
+ onClick: (e) => {
169
+ e.stopPropagation(), C();
170
+ },
171
+ children: /* @__PURE__ */ l(i, {})
172
+ })]
173
+ }) : T;
174
+ }
175
+ function m({ shape: e = "card", tone: t = "neutral", icon: n, order: r, eyebrow: i, title: a, subtitle: o, tags: s, titleTone: c = "default", selected: d = !1, active: f = !1, muted: p = !1, invalid: m = !1, onClick: h, ariaLabel: g }, _) {
176
+ let v = `${d ? " is-selected" : m ? " is-invalid" : f ? " is-on" : ""}${p ? " is-muted" : ""}`, y = a != null && /* @__PURE__ */ l("span", {
177
+ className: `select-flownode__title${c === "warning" ? " select-flownode__title--warning" : ""}`,
178
+ children: a
179
+ });
180
+ return e === "decision" ? /* @__PURE__ */ l("button", {
138
181
  type: "button",
139
- className: `select-flownode select-flownode--decision${x}`,
140
- style: S,
141
- onClick: y,
142
- "aria-label": b,
143
- children: /* @__PURE__ */ l("span", {
182
+ className: `select-flownode select-flownode--decision${v}`,
183
+ style: _,
184
+ onClick: h,
185
+ "aria-label": g,
186
+ children: /* @__PURE__ */ u("span", {
144
187
  className: "select-flownode__inner",
145
- children: [s != null && /* @__PURE__ */ c("span", {
188
+ children: [r != null && /* @__PURE__ */ l("span", {
146
189
  className: "select-flownode__order",
147
- children: s
148
- }), /* @__PURE__ */ l("span", {
190
+ children: r
191
+ }), /* @__PURE__ */ u("span", {
149
192
  className: "select-flownode__text",
150
193
  children: [
151
- u != null && /* @__PURE__ */ c("span", {
194
+ i != null && /* @__PURE__ */ l("span", {
152
195
  className: "select-flownode__eyebrow",
153
- children: u
196
+ children: i
154
197
  }),
155
- C,
156
- f != null && /* @__PURE__ */ c("span", {
198
+ y,
199
+ o != null && /* @__PURE__ */ l("span", {
157
200
  className: "select-flownode__sub",
158
- children: f
201
+ children: o
159
202
  }),
160
- p != null && /* @__PURE__ */ c("span", {
203
+ s != null && /* @__PURE__ */ l("span", {
161
204
  className: "select-flownode__tags",
162
- children: p
205
+ children: s
163
206
  })
164
207
  ]
165
208
  })]
166
209
  })
167
- }) : i === "pill" ? /* @__PURE__ */ l("button", {
210
+ }) : e === "pill" ? /* @__PURE__ */ u("button", {
168
211
  type: "button",
169
- className: `select-flownode select-flownode--pill${x}`,
170
- style: S,
171
- onClick: y,
172
- "aria-label": b,
173
- children: [o, d]
174
- }) : /* @__PURE__ */ l("button", {
212
+ className: `select-flownode select-flownode--pill${v}`,
213
+ style: _,
214
+ onClick: h,
215
+ "aria-label": g,
216
+ children: [n, a]
217
+ }) : /* @__PURE__ */ u("button", {
175
218
  type: "button",
176
- className: `select-flownode select-flownode--${i === "terminal" ? "terminal" : "card"}${x}`,
177
- style: S,
178
- onClick: y,
179
- "aria-label": b,
180
- children: [i === "card" && o != null && /* @__PURE__ */ c("span", {
181
- className: `select-flownode__chip select-flownode__chip--${a}`,
182
- children: o
183
- }), /* @__PURE__ */ l("span", {
219
+ className: `select-flownode select-flownode--${e === "terminal" ? "terminal" : "card"}${v}`,
220
+ style: _,
221
+ onClick: h,
222
+ "aria-label": g,
223
+ children: [e === "card" && n != null && /* @__PURE__ */ l("span", {
224
+ className: `select-flownode__chip select-flownode__chip--${t}`,
225
+ children: n
226
+ }), /* @__PURE__ */ u("span", {
184
227
  className: "select-flownode__text",
185
228
  children: [
186
- u != null && /* @__PURE__ */ c("span", {
229
+ i != null && /* @__PURE__ */ l("span", {
187
230
  className: "select-flownode__eyebrow",
188
- children: u
231
+ children: i
189
232
  }),
190
- C,
191
- f != null && /* @__PURE__ */ c("span", {
233
+ y,
234
+ o != null && /* @__PURE__ */ l("span", {
192
235
  className: "select-flownode__sub",
193
- children: f
236
+ children: o
194
237
  }),
195
- p != null && /* @__PURE__ */ c("span", {
238
+ s != null && /* @__PURE__ */ l("span", {
196
239
  className: "select-flownode__tags",
197
- children: p
240
+ children: s
198
241
  })
199
242
  ]
200
243
  })]
201
244
  });
202
245
  }
203
- function p({ title: n, subtitle: r, onBack: o, backLabel: s = "Voltar", toolbar: u, actions: d, error: f, canvas: p, inspectorHead: m, inspector: h, inspectorLabel: g = "Painel", inspectorOpen: _, onInspectorClose: v }) {
246
+ function h({ title: n, subtitle: r, onBack: i, backLabel: s = "Voltar", toolbar: c, actions: d, error: f, canvas: p, inspectorHead: m, inspector: h, inspectorLabel: g = "Painel", inspectorOpen: _, onInspectorClose: v }) {
204
247
  let y = _ !== void 0;
205
- return /* @__PURE__ */ l("div", {
248
+ return /* @__PURE__ */ u("div", {
206
249
  className: `select-flowpage${y ? " select-flowpage--sheet" : ""}${y && _ ? " is-inspecting" : ""}`,
207
250
  children: [
208
- /* @__PURE__ */ l("header", {
251
+ /* @__PURE__ */ u("header", {
209
252
  className: "select-flowpage__bar",
210
253
  children: [
211
- o && /* @__PURE__ */ c(a, {
212
- icon: /* @__PURE__ */ c(e, {}),
254
+ i && /* @__PURE__ */ l(o, {
255
+ icon: /* @__PURE__ */ l(e, {}),
213
256
  label: s,
214
257
  variant: "outline",
215
- onClick: o
258
+ onClick: i
216
259
  }),
217
- /* @__PURE__ */ l("div", {
260
+ /* @__PURE__ */ u("div", {
218
261
  className: "select-flowpage__ident",
219
- children: [/* @__PURE__ */ c("span", {
262
+ children: [/* @__PURE__ */ l("span", {
220
263
  className: "select-flowpage__title",
221
264
  children: n
222
- }), r != null && /* @__PURE__ */ c("span", {
265
+ }), r != null && /* @__PURE__ */ l("span", {
223
266
  className: "select-flowpage__sub",
224
267
  children: r
225
268
  })]
226
269
  }),
227
- u != null && /* @__PURE__ */ c("div", {
270
+ c != null && /* @__PURE__ */ l("div", {
228
271
  className: "select-flowpage__tools",
229
- children: u
272
+ children: c
230
273
  }),
231
- d != null && /* @__PURE__ */ c("div", {
274
+ d != null && /* @__PURE__ */ l("div", {
232
275
  className: "select-flowpage__actions",
233
276
  children: d
234
277
  })
235
278
  ]
236
279
  }),
237
- f != null && f !== "" && /* @__PURE__ */ c("div", {
280
+ f != null && f !== "" && /* @__PURE__ */ l("div", {
238
281
  className: "select-flowpage__error",
239
- children: /* @__PURE__ */ c(i, {
282
+ children: /* @__PURE__ */ l(a, {
240
283
  tone: "critical",
241
284
  children: f
242
285
  })
243
286
  }),
244
- /* @__PURE__ */ l("div", {
287
+ /* @__PURE__ */ u("div", {
245
288
  className: "select-flowpage__body",
246
- children: [/* @__PURE__ */ c("div", {
289
+ children: [/* @__PURE__ */ l("div", {
247
290
  className: "select-flowpage__canvas",
248
291
  children: p
249
- }), /* @__PURE__ */ l("aside", {
292
+ }), /* @__PURE__ */ u("aside", {
250
293
  className: "select-flowpage__inspector",
251
294
  "aria-label": g,
252
295
  children: [
253
- y && v && /* @__PURE__ */ l("button", {
296
+ y && v && /* @__PURE__ */ u("button", {
254
297
  type: "button",
255
298
  className: "select-flowpage__sheetclose",
256
299
  onClick: v,
257
- children: [/* @__PURE__ */ c("span", {
300
+ children: [/* @__PURE__ */ l("span", {
258
301
  className: "select-flowpage__sheetgrip",
259
302
  "aria-hidden": "true"
260
- }), /* @__PURE__ */ l("span", {
303
+ }), /* @__PURE__ */ u("span", {
261
304
  className: "select-flowpage__sheetlabel",
262
- children: [/* @__PURE__ */ c(t, {}), "Fechar"]
305
+ children: [/* @__PURE__ */ l(t, {}), "Fechar"]
263
306
  })]
264
307
  }),
265
- m != null && /* @__PURE__ */ c("div", {
308
+ m != null && /* @__PURE__ */ l("div", {
266
309
  className: "select-flowpage__inspectorhead",
267
310
  children: m
268
311
  }),
269
- /* @__PURE__ */ c("div", {
312
+ /* @__PURE__ */ l("div", {
270
313
  className: "select-flowpage__inspectorbody",
271
314
  children: h
272
315
  })
@@ -277,6 +320,6 @@ function p({ title: n, subtitle: r, onBack: o, backLabel: s = "Voltar", toolbar:
277
320
  });
278
321
  }
279
322
  //#endregion
280
- export { d as SelectFlowCanvas, p as SelectFlowLayout, f as SelectFlowNode };
323
+ export { f as SelectFlowCanvas, h as SelectFlowLayout, p as SelectFlowNode };
281
324
 
282
325
  //# sourceMappingURL=SelectFlowCanvas.js.map
@@ -0,0 +1,39 @@
1
+ import { ComponentPropsWithoutRef, ReactNode } from 'react';
2
+ type SelectQuantityFieldOwnProps = {
3
+ label: ReactNode;
4
+ value: number | null;
5
+ /** O número digitado (sem prender a `min`/`max`) ou o da barra (na grade, entre `min` e `sliderMax`); vazio → `null`. */
6
+ onChange: (value: number | null) => void;
7
+ /** O menor número da barra (e o de partida da escala). Digitar menos não é bloqueado: diga o erro em `error`. */
8
+ min: number;
9
+ /** O maior número que se compra. Digitar mais não é bloqueado: diga o erro em `error`. */
10
+ max: number;
11
+ /** Onde a barra termina (padrão: `max`). Acima disso, só digitando. */
12
+ sliderMax?: number;
13
+ /** A escala da barra. `log` dá mais espaço aos números pequenos (de 1 mil a 200 mil). Padrão `linear`. */
14
+ scale?: 'linear' | 'log';
15
+ /** O passo da grade da barra e do teclado: um número, ou uma função do número (o passo muda com o tamanho). Padrão 1. */
16
+ step?: number | ((n: number) => number);
17
+ /** As marcas embaixo da barra (decorativas: o leitor de tela ouve o valor). A que encostaria na vizinha some. */
18
+ ticks?: number[];
19
+ /** O texto de cada marca. Padrão: o número compacto do idioma ("5 mil", "200 mil"; "5K" em inglês). */
20
+ formatTick?: (n: number) => string;
21
+ /** A unidade dentro da caixa, depois do número ("e-mails", "partes"). */
22
+ suffix?: ReactNode;
23
+ /** O valor por extenso para o leitor de tela. Padrão: o número formatado e a unidade, quando ela é texto. */
24
+ valueText?: (n: number) => string;
25
+ hint?: ReactNode;
26
+ /** O erro do número (fora dos limites, por exemplo). Pinta a caixa e toma o lugar do `hint`. */
27
+ error?: string;
28
+ disabled?: boolean;
29
+ /** O `id` da caixa (padrão: gerado). */
30
+ id?: string;
31
+ /** O `name` da caixa, para o formulário. */
32
+ name?: string;
33
+ onBlur?: () => void;
34
+ /** Ajuda contextual: o "!" ao lado do rótulo. */
35
+ help?: ReactNode;
36
+ };
37
+ export type SelectQuantityFieldProps = SelectQuantityFieldOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectQuantityFieldOwnProps>;
38
+ export declare const SelectQuantityField: import('react').ForwardRefExoticComponent<SelectQuantityFieldOwnProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectQuantityFieldOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
39
+ export {};
@@ -0,0 +1,145 @@
1
+ /* empty css */
2
+ import { formatSelectNumber as e, selectIntlLocale as t, useSelectLocale as n } from "./SelectLocale.js";
3
+ import { SelectLabelRow as r } from "./SelectField.js";
4
+ import { forwardRef as i, useId as a, useLayoutEffect as o, useRef as s, useState as c } from "react";
5
+ import { jsx as l, jsxs as u } from "react/jsx-runtime";
6
+ //#region src/SelectQuantityField.tsx
7
+ var d = 1e3, f = 8;
8
+ function p(e) {
9
+ let t = [...e.querySelectorAll(".select-qtyfield__tick")];
10
+ t.forEach((e) => e.removeAttribute("data-hidden"));
11
+ let n = t.map((e) => e.getBoundingClientRect());
12
+ if (t.length < 3 || n.every((e) => e.width === 0)) return;
13
+ let r = n[n.length - 1], i = n[0];
14
+ for (let e = 1; e < t.length - 1; e++) {
15
+ let a = n[e];
16
+ a.left >= i.right + f && a.right + f <= r.left ? i = a : t[e].setAttribute("data-hidden", "");
17
+ }
18
+ }
19
+ var m = i(function({ label: i, value: f, onChange: m, min: h, max: g, sliderMax: ee, scale: _ = "linear", step: v = 1, ticks: y, formatTick: b, suffix: x, valueText: S, hint: C, error: w, disabled: T = !1, id: E, name: te, onBlur: D, help: ne, className: O, ...k }, A) {
20
+ let j = n(), M = a(), N = E ?? M, P = `${N}-label`, F = w ? `${N}-err` : C ? `${N}-hint` : void 0, I = Math.max(h, ee ?? g), L = _ === "log" && h > 0, R = (e) => Math.max(1, typeof v == "function" ? v(e) : v), z = (e) => Math.min(I, Math.max(h, e)), B = (e) => {
21
+ let t = z(e);
22
+ if (I === h) return 0;
23
+ let n = L ? (Math.log(t) - Math.log(h)) / (Math.log(I) - Math.log(h)) : (t - h) / (I - h);
24
+ return Math.round(n * d);
25
+ }, V = (e) => {
26
+ let t = e / d, n = L ? Math.exp(Math.log(h) + t * (Math.log(I) - Math.log(h))) : h + t * (I - h), r = R(n);
27
+ return z(Math.round(n / r) * r);
28
+ }, H = (e) => {
29
+ let t = R(e);
30
+ return z((Math.floor(e / t) + 1) * t);
31
+ }, U = (e) => {
32
+ let t = R(e - 1);
33
+ return z((Math.ceil(e / t) - 1) * t);
34
+ }, [W, G] = c(!1), [K, q] = c(""), J = f == null ? "" : e(f, j), Y = W ? K : J, X = (e) => {
35
+ if (/[^\d.,\s  ]/.test(e)) return;
36
+ q(e);
37
+ let t = e.replace(/\D/g, "");
38
+ m(t === "" ? null : Number(t));
39
+ }, Z = f == null ? 0 : B(f), re = (t) => (S == null ? void 0 : S(t)) ?? `${e(t, j)}${typeof x == "string" ? ` ${x}` : ""}`, ie = (e) => {
40
+ let t = z(f ?? h), n = null;
41
+ if (e.key === "ArrowRight" || e.key === "ArrowUp") n = H(t);
42
+ else if (e.key === "ArrowLeft" || e.key === "ArrowDown") n = U(t);
43
+ else if (e.key === "PageUp" || e.key === "PageDown") {
44
+ n = t;
45
+ for (let t = 0; t < 10; t++) n = e.key === "PageUp" ? H(n) : U(n);
46
+ } else e.key === "Home" ? n = h : e.key === "End" && (n = I);
47
+ n != null && (e.preventDefault(), n !== f && m(n));
48
+ }, Q = (e) => (b == null ? void 0 : b(e)) ?? new Intl.NumberFormat(t(j), {
49
+ notation: "compact",
50
+ maximumFractionDigits: 1
51
+ }).format(e), $ = s(null), ae = (y == null ? void 0 : y.map((e) => `${e}:${Q(e)}`).join("|")) ?? "";
52
+ return o(() => {
53
+ let e = $.current;
54
+ if (!e || (p(e), typeof ResizeObserver > "u")) return;
55
+ let t = new ResizeObserver(() => p(e));
56
+ return t.observe(e), () => t.disconnect();
57
+ }, [
58
+ ae,
59
+ h,
60
+ I,
61
+ L
62
+ ]), /* @__PURE__ */ u("div", {
63
+ ref: A,
64
+ ...k,
65
+ className: `select-field select-qtyfield${w ? " is-error" : ""}${T ? " is-disabled" : ""}${O ? " " + O : ""}`,
66
+ children: [
67
+ /* @__PURE__ */ l(r, {
68
+ htmlFor: N,
69
+ labelId: P,
70
+ label: i,
71
+ help: ne
72
+ }),
73
+ /* @__PURE__ */ u("div", {
74
+ className: "select-qtyfield__box",
75
+ children: [/* @__PURE__ */ l("input", {
76
+ id: N,
77
+ name: te,
78
+ className: "select-qtyfield__input",
79
+ type: "text",
80
+ inputMode: "numeric",
81
+ autoComplete: "off",
82
+ disabled: T,
83
+ value: Y,
84
+ onChange: (e) => X(e.target.value),
85
+ onFocus: () => {
86
+ G(!0), q(J);
87
+ },
88
+ onBlur: () => {
89
+ G(!1), D == null || D();
90
+ },
91
+ "aria-invalid": w ? !0 : void 0,
92
+ "aria-describedby": F
93
+ }), x != null && /* @__PURE__ */ l("span", {
94
+ className: "select-qtyfield__suffix",
95
+ "aria-hidden": "true",
96
+ children: x
97
+ })]
98
+ }),
99
+ /* @__PURE__ */ l("div", {
100
+ className: "select-qtyfield__slider",
101
+ style: { "--select-qty-pct": `${Z / d * 100}%` },
102
+ children: /* @__PURE__ */ l("input", {
103
+ className: "select-qtyfield__range",
104
+ type: "range",
105
+ min: 0,
106
+ max: d,
107
+ step: 1,
108
+ value: Z,
109
+ disabled: T,
110
+ onChange: (e) => {
111
+ let t = V(Number(e.target.value));
112
+ t !== f && m(t);
113
+ },
114
+ onKeyDown: ie,
115
+ "aria-labelledby": P,
116
+ "aria-describedby": F,
117
+ "aria-valuetext": f == null ? void 0 : re(f)
118
+ })
119
+ }),
120
+ y && y.length > 0 && /* @__PURE__ */ l("div", {
121
+ ref: $,
122
+ className: "select-qtyfield__ticks",
123
+ "aria-hidden": "true",
124
+ children: y.map((e, t) => /* @__PURE__ */ l("span", {
125
+ className: `select-qtyfield__tick${t === 0 ? " is-first" : ""}${t === y.length - 1 ? " is-last" : ""}`,
126
+ style: { left: `calc(var(--select-qty-thumb) / 2 + (100% - var(--select-qty-thumb)) * ${B(e) / d})` },
127
+ children: Q(e)
128
+ }, e))
129
+ }),
130
+ w ? /* @__PURE__ */ l("p", {
131
+ id: `${N}-err`,
132
+ className: "select-field__error",
133
+ children: w
134
+ }) : C ? /* @__PURE__ */ l("p", {
135
+ id: `${N}-hint`,
136
+ className: "select-field__hint",
137
+ children: C
138
+ }) : null
139
+ ]
140
+ });
141
+ });
142
+ //#endregion
143
+ export { m as SelectQuantityField };
144
+
145
+ //# sourceMappingURL=SelectQuantityField.js.map