@selectwin/kit 0.1.209 → 0.1.211
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/dist/SelectDetail.d.ts +8 -4
- package/dist/SelectDetail.js +22 -18
- package/dist/SelectField.d.ts +2 -0
- package/dist/SelectField.js +7 -6
- package/dist/SelectKpiBand.d.ts +4 -2
- package/dist/SelectKpiBand.js +20 -9
- package/dist/SelectKpiCard.js +35 -30
- package/dist/SelectPagination.d.ts +5 -0
- package/dist/SelectPagination.js +38 -34
- package/dist/SelectQuantityField.d.ts +39 -0
- package/dist/SelectQuantityField.js +145 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +142 -140
- package/dist/internal/kpiList.d.ts +2 -0
- package/dist/internal/kpiList.js +10 -0
- package/dist/internal/listChrome.d.ts +9 -1
- package/dist/internal/listChrome.js +17 -16
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/SelectDetail.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReactNode, ComponentPropsWithoutRef } from 'react';
|
|
2
|
-
|
|
1
|
+
import { ReactNode, HTMLAttributes, ComponentPropsWithoutRef } from 'react';
|
|
2
|
+
type SelectDetailListOwnProps = {
|
|
3
3
|
children: ReactNode;
|
|
4
4
|
stacked?: boolean;
|
|
5
5
|
/**
|
|
@@ -10,7 +10,11 @@ export declare function SelectDetailList({ children, stacked, compact, loading,
|
|
|
10
10
|
compact?: boolean;
|
|
11
11
|
/** Shimmer every row's value. The labels stay — only the values are unknown. */
|
|
12
12
|
loading?: boolean;
|
|
13
|
-
|
|
13
|
+
/** 0.1.210: `dl` desenha a lista de definição (`<dl>`, `<dt>`, `<dd>`). Padrão `div`, como antes. */
|
|
14
|
+
as?: 'div' | 'dl';
|
|
15
|
+
};
|
|
16
|
+
export type SelectDetailListProps = SelectDetailListOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectDetailListOwnProps>;
|
|
17
|
+
export declare function SelectDetailList({ children, stacked, compact, loading, as, className, ...rest }: SelectDetailListProps): import("react").JSX.Element;
|
|
14
18
|
type SelectDetailRowOwnProps = {
|
|
15
19
|
label: ReactNode;
|
|
16
20
|
children: ReactNode;
|
|
@@ -21,5 +25,5 @@ type SelectDetailRowOwnProps = {
|
|
|
21
25
|
loading?: boolean;
|
|
22
26
|
};
|
|
23
27
|
export type SelectDetailRowProps = SelectDetailRowOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectDetailRowOwnProps>;
|
|
24
|
-
export declare const SelectDetailRow: import('react').ForwardRefExoticComponent<SelectDetailRowOwnProps & Omit<Omit<import('react').DetailedHTMLProps<
|
|
28
|
+
export declare const SelectDetailRow: import('react').ForwardRefExoticComponent<SelectDetailRowOwnProps & Omit<Omit<import('react').DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectDetailRowOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
|
|
25
29
|
export {};
|
package/dist/SelectDetail.js
CHANGED
|
@@ -3,40 +3,44 @@ import { useSelectReveal as e } from "./internal/useSelectReveal.js";
|
|
|
3
3
|
import { createContext as t, forwardRef as n, useContext as r } from "react";
|
|
4
4
|
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
5
5
|
//#region src/SelectDetail.tsx
|
|
6
|
-
var o = t(!1);
|
|
7
|
-
function
|
|
8
|
-
let
|
|
6
|
+
var o = t(!1), s = t(!1);
|
|
7
|
+
function c({ children: t, stacked: n = !1, compact: r = !1, loading: a = !1, as: c = "div", className: l, ...u }) {
|
|
8
|
+
let d = e({
|
|
9
9
|
selector: ".select-detail",
|
|
10
10
|
y: 8,
|
|
11
11
|
duration: .45,
|
|
12
12
|
stagger: .05,
|
|
13
13
|
scroll: !0
|
|
14
|
-
})
|
|
14
|
+
}), f = `select-detaillist${n ? " select-detaillist--stacked" : ""}${r ? " select-detaillist--compact" : ""}${l ? " " + l : ""}`;
|
|
15
15
|
return /* @__PURE__ */ i(o.Provider, {
|
|
16
16
|
value: a,
|
|
17
|
-
children: /* @__PURE__ */ i(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
17
|
+
children: /* @__PURE__ */ i(s.Provider, {
|
|
18
|
+
value: c === "dl",
|
|
19
|
+
children: i(c === "dl" ? "dl" : "div", {
|
|
20
|
+
...u,
|
|
21
|
+
className: f,
|
|
22
|
+
ref: d,
|
|
23
|
+
children: t
|
|
24
|
+
})
|
|
21
25
|
})
|
|
22
26
|
});
|
|
23
27
|
}
|
|
24
|
-
var
|
|
25
|
-
let
|
|
28
|
+
var l = n(function({ label: e, children: t, action: n, align: c = "center", loading: l, className: u, ...d }, f) {
|
|
29
|
+
let p = r(o), m = l ?? p, h = r(s), g = h ? "dt" : "div", _ = h ? "dd" : "div";
|
|
26
30
|
return /* @__PURE__ */ a("div", {
|
|
27
|
-
ref:
|
|
28
|
-
...
|
|
29
|
-
className: `select-detail select-detail--${
|
|
31
|
+
ref: f,
|
|
32
|
+
...d,
|
|
33
|
+
className: `select-detail select-detail--${c}${u ? " " + u : ""}`,
|
|
30
34
|
children: [
|
|
31
|
-
/* @__PURE__ */ i(
|
|
35
|
+
/* @__PURE__ */ i(g, {
|
|
32
36
|
className: "select-detail__label",
|
|
33
37
|
children: e
|
|
34
38
|
}),
|
|
35
|
-
/* @__PURE__ */ i(
|
|
39
|
+
/* @__PURE__ */ i(_, {
|
|
36
40
|
className: "select-detail__value",
|
|
37
|
-
children:
|
|
41
|
+
children: m ? /* @__PURE__ */ i("span", { className: "select-skeleton select-detail__skel" }) : t
|
|
38
42
|
}),
|
|
39
|
-
n && /* @__PURE__ */ i(
|
|
43
|
+
n && /* @__PURE__ */ i(_, {
|
|
40
44
|
className: "select-detail__action",
|
|
41
45
|
children: n
|
|
42
46
|
})
|
|
@@ -44,6 +48,6 @@ var c = n(function({ label: e, children: t, action: n, align: s = "center", load
|
|
|
44
48
|
});
|
|
45
49
|
});
|
|
46
50
|
//#endregion
|
|
47
|
-
export {
|
|
51
|
+
export { c as SelectDetailList, l as SelectDetailRow };
|
|
48
52
|
|
|
49
53
|
//# sourceMappingURL=SelectDetail.js.map
|
package/dist/SelectField.d.ts
CHANGED
|
@@ -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>>;
|
package/dist/SelectField.js
CHANGED
|
@@ -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,
|
|
9
|
-
let
|
|
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:
|
|
12
|
-
...
|
|
13
|
-
className: `select-field__labelrow${
|
|
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: [" ",
|
|
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",
|
package/dist/SelectKpiBand.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { ComponentPropsWithoutRef, ReactNode } from 'react';
|
|
1
|
+
import { ComponentPropsWithoutRef, ReactNode, HTMLAttributes } from 'react';
|
|
2
2
|
type SelectKpiBandOwnProps = {
|
|
3
3
|
children: ReactNode;
|
|
4
|
+
/** 0.1.210: `dl` para a faixa de números só de leitura (os `SelectKpiCard` viram `<dt>` e `<dd>`). Padrão `div`. */
|
|
5
|
+
as?: 'div' | 'dl';
|
|
4
6
|
};
|
|
5
7
|
export type SelectKpiBandProps = SelectKpiBandOwnProps & Omit<ComponentPropsWithoutRef<'div'>, keyof SelectKpiBandOwnProps>;
|
|
6
|
-
export declare const SelectKpiBand: import('react').ForwardRefExoticComponent<SelectKpiBandOwnProps & Omit<Omit<import('react').DetailedHTMLProps<
|
|
8
|
+
export declare const SelectKpiBand: import('react').ForwardRefExoticComponent<SelectKpiBandOwnProps & Omit<Omit<import('react').DetailedHTMLProps<HTMLAttributes<HTMLDivElement>, HTMLDivElement>, "ref">, keyof SelectKpiBandOwnProps> & import('react').RefAttributes<HTMLDivElement>>;
|
|
7
9
|
export {};
|
package/dist/SelectKpiBand.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useInsideFrame as e } from "./internal/frame.js";
|
|
3
|
+
import { KpiListContext as t } from "./internal/kpiList.js";
|
|
4
|
+
import { forwardRef as n } from "react";
|
|
5
|
+
import { jsx as r } from "react/jsx-runtime";
|
|
4
6
|
//#region src/SelectKpiBand.tsx
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
var i = n(function({ children: n, as: i = "div", className: a, ...o }, s) {
|
|
8
|
+
let c = `select-kpiband${e() ? " select-kpiband--nested" : ""}${a ? " " + a : ""}`;
|
|
9
|
+
return i === "dl" ? /* @__PURE__ */ r(t.Provider, {
|
|
10
|
+
value: !0,
|
|
11
|
+
children: /* @__PURE__ */ r("dl", {
|
|
12
|
+
ref: s,
|
|
13
|
+
...o,
|
|
14
|
+
className: c,
|
|
15
|
+
children: n
|
|
16
|
+
})
|
|
17
|
+
}) : /* @__PURE__ */ r("div", {
|
|
18
|
+
ref: s,
|
|
8
19
|
role: "group",
|
|
9
|
-
...
|
|
10
|
-
className:
|
|
11
|
-
children:
|
|
20
|
+
...o,
|
|
21
|
+
className: c,
|
|
22
|
+
children: n
|
|
12
23
|
});
|
|
13
24
|
});
|
|
14
25
|
//#endregion
|
|
15
|
-
export {
|
|
26
|
+
export { i as SelectKpiBand };
|
|
16
27
|
|
|
17
28
|
//# sourceMappingURL=SelectKpiBand.js.map
|
package/dist/SelectKpiCard.js
CHANGED
|
@@ -1,54 +1,59 @@
|
|
|
1
1
|
import { SelectInfoTip as e } from "./SelectInfoTip.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { useKpiList as t } from "./internal/kpiList.js";
|
|
3
|
+
import { forwardRef as n } from "react";
|
|
4
|
+
import { Fragment as r, jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
4
5
|
//#region src/SelectKpiCard.tsx
|
|
5
|
-
var
|
|
6
|
-
let
|
|
6
|
+
var o = n(function({ label: n, value: o, caption: s, chart: c, help: l, tone: u, bare: d = !1, onClick: f, selected: p = !1, loading: m = !1, className: h, ...g }, _) {
|
|
7
|
+
let v = f != null, y = t(), b = y ? "dt" : "span", x = y ? "dd" : "span", S = y ? "dd" : "div", C = v ? {
|
|
7
8
|
role: "button",
|
|
8
9
|
tabIndex: 0,
|
|
9
|
-
"aria-pressed":
|
|
10
|
-
onClick:
|
|
10
|
+
"aria-pressed": p,
|
|
11
|
+
onClick: f,
|
|
11
12
|
onKeyDown: (e) => {
|
|
12
|
-
e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
13
|
+
e.target === e.currentTarget && (e.key === "Enter" || e.key === " ") && (e.preventDefault(), f());
|
|
13
14
|
}
|
|
14
|
-
} : {},
|
|
15
|
-
return /* @__PURE__ */
|
|
16
|
-
ref:
|
|
17
|
-
...
|
|
18
|
-
...
|
|
19
|
-
className:
|
|
20
|
-
children: [/* @__PURE__ */
|
|
21
|
-
className: `select-kpi__label${
|
|
22
|
-
children: [
|
|
15
|
+
} : {}, w = "select-kpi" + (d ? " select-kpi--bare" : "") + (v ? " select-kpi--interactive" : "") + (v && p ? " select-kpi--selected" : "") + (h ? " " + h : "");
|
|
16
|
+
return /* @__PURE__ */ a("div", {
|
|
17
|
+
ref: _,
|
|
18
|
+
...g,
|
|
19
|
+
...C,
|
|
20
|
+
className: w,
|
|
21
|
+
children: [/* @__PURE__ */ a(b, {
|
|
22
|
+
className: `select-kpi__label${l == null ? "" : " select-kpi__label--help"}`,
|
|
23
|
+
children: [l == null ? n : /* @__PURE__ */ i("span", {
|
|
23
24
|
className: "select-kpi__labeltext",
|
|
24
|
-
children:
|
|
25
|
-
}),
|
|
26
|
-
content:
|
|
25
|
+
children: n
|
|
26
|
+
}), l != null && /* @__PURE__ */ i(e, {
|
|
27
|
+
content: l,
|
|
27
28
|
placement: "top-end"
|
|
28
29
|
})]
|
|
29
|
-
}),
|
|
30
|
+
}), m ? y ? /* @__PURE__ */ a("dd", {
|
|
31
|
+
className: "select-kpi__loading",
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
children: [/* @__PURE__ */ i("span", { className: "select-skeleton select-kpi__skelvalue" }), /* @__PURE__ */ i("span", { className: "select-skeleton select-kpi__skelcaption" })]
|
|
34
|
+
}) : /* @__PURE__ */ a(r, { children: [/* @__PURE__ */ i("span", {
|
|
30
35
|
className: "select-skeleton select-kpi__skelvalue",
|
|
31
36
|
"aria-hidden": "true"
|
|
32
|
-
}), /* @__PURE__ */
|
|
37
|
+
}), /* @__PURE__ */ i("span", {
|
|
33
38
|
className: "select-skeleton select-kpi__skelcaption",
|
|
34
39
|
"aria-hidden": "true"
|
|
35
|
-
})] }) : /* @__PURE__ */
|
|
36
|
-
/* @__PURE__ */
|
|
37
|
-
className: `select-kpi__value${
|
|
38
|
-
children:
|
|
40
|
+
})] }) : /* @__PURE__ */ a(r, { children: [
|
|
41
|
+
/* @__PURE__ */ i(x, {
|
|
42
|
+
className: `select-kpi__value${u ? ` select-kpi__value--${u}` : ""}`,
|
|
43
|
+
children: o
|
|
39
44
|
}),
|
|
40
|
-
|
|
45
|
+
c != null && /* @__PURE__ */ i(S, {
|
|
41
46
|
className: "select-kpi__chart",
|
|
42
|
-
children:
|
|
47
|
+
children: c
|
|
43
48
|
}),
|
|
44
|
-
|
|
49
|
+
s != null && /* @__PURE__ */ i(x, {
|
|
45
50
|
className: "select-kpi__caption",
|
|
46
|
-
children:
|
|
51
|
+
children: s
|
|
47
52
|
})
|
|
48
53
|
] })]
|
|
49
54
|
});
|
|
50
55
|
});
|
|
51
56
|
//#endregion
|
|
52
|
-
export {
|
|
57
|
+
export { o as SelectKpiCard };
|
|
53
58
|
|
|
54
59
|
//# sourceMappingURL=SelectKpiCard.js.map
|
|
@@ -19,5 +19,10 @@ export interface SelectPaginationProps {
|
|
|
19
19
|
onPage?: (page: number) => void;
|
|
20
20
|
/** Noun for the count label, e.g. "produtos". Defaults to "resultados" ("results" in English, `SelectLocaleProvider`). */
|
|
21
21
|
noun?: string;
|
|
22
|
+
/**
|
|
23
|
+
* 0.1.210: a próxima página está chegando (a lista por cursor pede ao servidor). O "próxima" gira e fica
|
|
24
|
+
* `aria-busy`/`aria-disabled` sem perder o foco (o `disabled` o jogaria no `<body>`), e não aceita outro clique.
|
|
25
|
+
*/
|
|
26
|
+
loading?: boolean;
|
|
22
27
|
}
|
|
23
28
|
export declare const SelectPagination: import('react').ForwardRefExoticComponent<SelectPaginationProps & Omit<Omit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLElement>, HTMLElement>, "ref">, keyof SelectPaginationProps> & import('react').RefAttributes<HTMLElement>>;
|
package/dist/SelectPagination.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
/* empty css */
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { SelectSpinner as e } from "./SelectSpinner.js";
|
|
3
|
+
import { ChevronLeftIcon as t, ChevronRightIcon as n } from "./icons.js";
|
|
4
|
+
import { formatSelectNumber as r, useSelectLocale as i, useSelectMessages as a } from "./SelectLocale.js";
|
|
5
|
+
import { forwardRef as o } from "react";
|
|
6
|
+
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
6
7
|
//#region src/SelectPagination.tsx
|
|
7
|
-
function
|
|
8
|
+
function l(e, t) {
|
|
8
9
|
let n = [.../* @__PURE__ */ new Set([
|
|
9
10
|
1,
|
|
10
11
|
t,
|
|
@@ -15,7 +16,7 @@ function c(e, t) {
|
|
|
15
16
|
for (let e of n) e - i > 1 && r.push("gap"), r.push(e), i = e;
|
|
16
17
|
return r;
|
|
17
18
|
}
|
|
18
|
-
function
|
|
19
|
+
function u(e, t, n, r, i, a, o, s) {
|
|
19
20
|
let c = [];
|
|
20
21
|
if (e != null) {
|
|
21
22
|
if (e === 0) c.push(o.count(s(0), i));
|
|
@@ -26,50 +27,53 @@ function l(e, t, n, r, i, a, o, s) {
|
|
|
26
27
|
}
|
|
27
28
|
return a && r != null && r > 0 && c.push(o.pageOf(s(n), s(r))), c;
|
|
28
29
|
}
|
|
29
|
-
var
|
|
30
|
-
let
|
|
31
|
-
return /* @__PURE__ */
|
|
32
|
-
ref:
|
|
33
|
-
...
|
|
34
|
-
className: `select-pagination${
|
|
35
|
-
"aria-label":
|
|
36
|
-
children: [/* @__PURE__ */
|
|
30
|
+
var d = o(function({ page: o, pageCount: d, total: f, pageSize: p, hasPrevious: m, hasNext: h, onPrevious: g, onNext: _, onPage: v, noun: y, loading: b = !1, className: x, ...S }, C) {
|
|
31
|
+
let w = a().pagination, T = i(), E = (e) => r(e, T), D = y ?? w.noun, O = m ?? o > 1, k = h ?? (d == null || o < d), A = g ?? (v ? () => v(o - 1) : void 0), j = _ ?? (v ? () => v(o + 1) : void 0), M = d != null && d > 1 && v != null, N = M ? l(o, d) : [], P = u(f, p, o, d, D, M, w, E);
|
|
32
|
+
return /* @__PURE__ */ c("nav", {
|
|
33
|
+
ref: C,
|
|
34
|
+
...S,
|
|
35
|
+
className: `select-pagination${x ? " " + x : ""}`,
|
|
36
|
+
"aria-label": w.label,
|
|
37
|
+
children: [/* @__PURE__ */ c("div", {
|
|
37
38
|
className: "select-pagination__controls",
|
|
38
39
|
children: [
|
|
39
|
-
/* @__PURE__ */
|
|
40
|
+
/* @__PURE__ */ s("button", {
|
|
40
41
|
type: "button",
|
|
41
42
|
className: "select-pagination__nav",
|
|
42
|
-
onClick:
|
|
43
|
-
disabled: !
|
|
44
|
-
"aria-label":
|
|
45
|
-
children: /* @__PURE__ */
|
|
43
|
+
onClick: A,
|
|
44
|
+
disabled: !O || !A,
|
|
45
|
+
"aria-label": w.previous,
|
|
46
|
+
children: /* @__PURE__ */ s(t, {})
|
|
46
47
|
}),
|
|
47
|
-
|
|
48
|
+
M ? N.map((e, t) => e === "gap" ? /* @__PURE__ */ s("span", {
|
|
48
49
|
className: "select-pagination__gap",
|
|
49
50
|
"aria-hidden": "true",
|
|
50
51
|
children: "…"
|
|
51
|
-
}, `gap-${t}`) : /* @__PURE__ */
|
|
52
|
+
}, `gap-${t}`) : /* @__PURE__ */ s("button", {
|
|
52
53
|
type: "button",
|
|
53
|
-
className: `select-pagination__page${e ===
|
|
54
|
-
onClick: () =>
|
|
55
|
-
"aria-current": e ===
|
|
54
|
+
className: `select-pagination__page${e === o ? " is-active" : ""}`,
|
|
55
|
+
onClick: () => v == null ? void 0 : v(e),
|
|
56
|
+
"aria-current": e === o ? "page" : void 0,
|
|
56
57
|
children: e
|
|
57
|
-
}, e)) : /* @__PURE__ */
|
|
58
|
+
}, e)) : /* @__PURE__ */ s("span", {
|
|
58
59
|
className: "select-pagination__current",
|
|
59
|
-
|
|
60
|
+
"aria-live": "polite",
|
|
61
|
+
children: d == null ? w.page(E(o)) : `${E(o)} / ${E(d)}`
|
|
60
62
|
}),
|
|
61
|
-
/* @__PURE__ */
|
|
63
|
+
/* @__PURE__ */ s("button", {
|
|
62
64
|
type: "button",
|
|
63
65
|
className: "select-pagination__nav",
|
|
64
|
-
onClick:
|
|
65
|
-
disabled: !
|
|
66
|
-
"aria-
|
|
67
|
-
|
|
66
|
+
onClick: b ? void 0 : j,
|
|
67
|
+
disabled: !k || !j,
|
|
68
|
+
"aria-disabled": b || void 0,
|
|
69
|
+
"aria-busy": b || void 0,
|
|
70
|
+
"aria-label": w.next,
|
|
71
|
+
children: b ? /* @__PURE__ */ s(e, { size: "sm" }) : /* @__PURE__ */ s(n, {})
|
|
68
72
|
})
|
|
69
73
|
]
|
|
70
|
-
}),
|
|
74
|
+
}), P.length > 0 && /* @__PURE__ */ s("p", {
|
|
71
75
|
className: "select-pagination__count",
|
|
72
|
-
children:
|
|
76
|
+
children: P.map((e, t) => /* @__PURE__ */ s("span", {
|
|
73
77
|
className: "select-pagination__part",
|
|
74
78
|
children: t > 0 ? ` · ${e}` : e
|
|
75
79
|
}, t))
|
|
@@ -77,6 +81,6 @@ var u = a(function({ page: a, pageCount: u, total: d, pageSize: f, hasPrevious:
|
|
|
77
81
|
});
|
|
78
82
|
});
|
|
79
83
|
//#endregion
|
|
80
|
-
export {
|
|
84
|
+
export { d as SelectPagination };
|
|
81
85
|
|
|
82
86
|
//# sourceMappingURL=SelectPagination.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
|
package/dist/index.d.ts
CHANGED
|
@@ -240,6 +240,8 @@ export { SelectDateField } from './SelectDateField';
|
|
|
240
240
|
export type { SelectDateFieldProps } from './SelectDateField';
|
|
241
241
|
export { SelectRating } from './SelectRating';
|
|
242
242
|
export { SelectNumberField } from './SelectNumberField';
|
|
243
|
+
export { SelectQuantityField } from './SelectQuantityField';
|
|
244
|
+
export type { SelectQuantityFieldProps } from './SelectQuantityField';
|
|
243
245
|
export { SelectRepeatingFieldArray } from './SelectRepeatingFieldArray';
|
|
244
246
|
export { SelectBuilderLayout } from './SelectBuilderLayout';
|
|
245
247
|
export { SelectBuilderWorkspace } from './SelectBuilderWorkspace';
|
|
@@ -305,6 +307,7 @@ export type { SelectOfferPriceProps } from './SelectOfferPrice';
|
|
|
305
307
|
export type { SelectRatingQuoteProps } from './SelectRatingQuote';
|
|
306
308
|
export type { SelectMarkStackProps, SelectMark } from './SelectMarkStack';
|
|
307
309
|
export type { SelectListPagination } from './internal/listChrome';
|
|
310
|
+
export { SelectListFooter } from './internal/listChrome';
|
|
308
311
|
export type { SelectPaginationProps } from './SelectPagination';
|
|
309
312
|
export type { SelectFilterDef } from './SelectFilterBar';
|
|
310
313
|
export type { SelectTagOption } from './SelectTagSelect';
|