bj-web-components 0.2.28 → 0.2.30

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.
Files changed (90) hide show
  1. package/dist/index.js +1 -51
  2. package/dist/index.mjs +49 -49
  3. package/dist/style.css +1 -3744
  4. package/dist/web/BasicInput/BInput.js +1 -208
  5. package/dist/web/BasicInput/BInput.mjs +132 -164
  6. package/dist/web/BasicInput/utils.js +1 -47
  7. package/dist/web/BasicInput/utils.mjs +28 -38
  8. package/dist/web/CategoryDropdown/CategoryDropdown.js +1 -307
  9. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +170 -218
  10. package/dist/web/CheckBox/BCheckBox.js +1 -116
  11. package/dist/web/CheckBox/BCheckBox.mjs +70 -86
  12. package/dist/web/CheckBox/Group.js +1 -73
  13. package/dist/web/CheckBox/Group.mjs +56 -63
  14. package/dist/web/CheckBox/context.js +1 -5
  15. package/dist/web/CheckBox/context.mjs +3 -3
  16. package/dist/web/CheckBox/index.js +1 -8
  17. package/dist/web/CheckBox/index.mjs +6 -6
  18. package/dist/web/Dropdown/BDropdown.js +1 -186
  19. package/dist/web/Dropdown/BDropdown.mjs +106 -132
  20. package/dist/web/EmptyInputBox/EmptyInputBox.js +1 -77
  21. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +48 -52
  22. package/dist/web/FileCard/FileCard.js +1 -157
  23. package/dist/web/FileCard/FileCard.mjs +82 -112
  24. package/dist/web/Icon/Icon.js +1 -9
  25. package/dist/web/Icon/Icon.mjs +6 -6
  26. package/dist/web/Input/Input.js +1 -181
  27. package/dist/web/Input/Input.mjs +113 -122
  28. package/dist/web/InputNumber/BInputNumber.js +1 -311
  29. package/dist/web/InputNumber/BInputNumber.mjs +167 -275
  30. package/dist/web/InputNumber/StepHandler.js +1 -69
  31. package/dist/web/InputNumber/StepHandler.mjs +32 -38
  32. package/dist/web/InputNumber/hooks/useCursor.js +1 -40
  33. package/dist/web/InputNumber/hooks/useCursor.mjs +33 -35
  34. package/dist/web/InputNumber/hooks/useFrame.js +1 -12
  35. package/dist/web/InputNumber/hooks/useFrame.mjs +6 -9
  36. package/dist/web/InputNumber/utils/decimal.js +1 -147
  37. package/dist/web/InputNumber/utils/decimal.mjs +81 -109
  38. package/dist/web/Modal/Modal.js +1 -84
  39. package/dist/web/Modal/Modal.mjs +49 -52
  40. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +1 -232
  41. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +125 -206
  42. package/dist/web/Pagination/Pagination.js +1 -328
  43. package/dist/web/Pagination/Pagination.mjs +178 -254
  44. package/dist/web/ProductField/ProductField.js +1 -272
  45. package/dist/web/ProductField/ProductField.mjs +143 -190
  46. package/dist/web/ProductField/arrow-up.svg.js +1 -3
  47. package/dist/web/ProductField/arrow-up.svg.mjs +2 -2
  48. package/dist/web/ProductField/checkbox-no.svg.js +1 -3
  49. package/dist/web/ProductField/checkbox-no.svg.mjs +2 -2
  50. package/dist/web/ProductField/checkbox-ok.svg.js +1 -3
  51. package/dist/web/ProductField/checkbox-ok.svg.mjs +2 -2
  52. package/dist/web/ProductField/no_data_light.svg.js +1 -3
  53. package/dist/web/ProductField/no_data_light.svg.mjs +2 -2
  54. package/dist/web/ProductField/search.svg.js +1 -3
  55. package/dist/web/ProductField/search.svg.mjs +2 -2
  56. package/dist/web/ProductField/sort.svg.js +1 -3
  57. package/dist/web/ProductField/sort.svg.mjs +2 -2
  58. package/dist/web/SkuInputCard/SkuInputCard.js +1 -276
  59. package/dist/web/SkuInputCard/SkuInputCard.mjs +149 -188
  60. package/dist/web/SkuInputCard/spin_loading_red.gif.js +1 -3
  61. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +2 -2
  62. package/dist/web/Switch/Switch.js +1 -70
  63. package/dist/web/Switch/Switch.mjs +37 -47
  64. package/dist/web/Table/BTable.js +1 -950
  65. package/dist/web/Table/BTable.mjs +521 -767
  66. package/dist/web/Table/Column.js +1 -5
  67. package/dist/web/Table/Column.mjs +2 -2
  68. package/dist/web/Table/ColumnGroup.js +1 -5
  69. package/dist/web/Table/ColumnGroup.mjs +2 -2
  70. package/dist/web/Table/utils/columns.js +1 -48
  71. package/dist/web/Table/utils/columns.mjs +30 -35
  72. package/dist/web/Table/utils/sortFilter.js +1 -84
  73. package/dist/web/Table/utils/sortFilter.mjs +52 -73
  74. package/dist/web/Tabs/BTabs.js +1 -150
  75. package/dist/web/Tabs/BTabs.mjs +98 -118
  76. package/dist/web/Tabs/TabPane.js +1 -8
  77. package/dist/web/Tabs/TabPane.mjs +4 -4
  78. package/dist/web/Tooltip/ConfirmTooltip.js +1 -26
  79. package/dist/web/Tooltip/ConfirmTooltip.mjs +19 -20
  80. package/dist/web/Tooltip/ContentTooltip.js +1 -94
  81. package/dist/web/Tooltip/ContentTooltip.mjs +62 -72
  82. package/dist/web/Tooltip/ProgressTooltip.js +1 -36
  83. package/dist/web/Tooltip/ProgressTooltip.mjs +20 -22
  84. package/dist/web/Tooltip/TooltipWrapper.js +1 -12
  85. package/dist/web/Tooltip/TooltipWrapper.mjs +8 -8
  86. package/dist/web/Tooltip/useAutoPlacement.js +1 -41
  87. package/dist/web/Tooltip/useAutoPlacement.mjs +25 -34
  88. package/dist/web.js +1 -51
  89. package/dist/web.mjs +49 -49
  90. package/package.json +1 -1
@@ -1,117 +1,101 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
2
- import { forwardRef, useContext, useState, useRef, useEffect } from "react";
3
- import BuIcon from "../Icon/Icon.mjs";
4
- import { CheckBoxGroupContext } from "./context.mjs";
1
+ import { jsxs as h, jsx as d } from "react/jsx-runtime";
2
+ import { forwardRef as S, useContext as g, useState as L, useRef as O, useEffect as x } from "react";
3
+ import $ from "../Icon/Icon.mjs";
4
+ import { CheckBoxGroupContext as q } from "./context.mjs";
5
5
  /* empty css */
6
- function classNames(...values) {
7
- return values.filter(Boolean).join(" ");
6
+ function u(...r) {
7
+ return r.filter(Boolean).join(" ");
8
8
  }
9
- const BCheckBox = forwardRef((props, forwardedRef) => {
9
+ const z = S((r, p) => {
10
10
  const {
11
- checked: controlledChecked,
12
- defaultChecked = false,
13
- disabled,
14
- indeterminate = false,
15
- children,
16
- className,
17
- style,
18
- onChange,
19
- onMouseEnter,
20
- onMouseLeave,
21
- value,
22
- skipGroup = false,
23
- direction = "ltr",
24
- name,
25
- variant = "dark",
26
- ...inputProps
27
- } = props;
28
- const group = useContext(CheckBoxGroupContext);
29
- const [internalChecked, setInternalChecked] = useState(defaultChecked);
30
- const previousValue = useRef(value);
31
- const inGroup = Boolean(group && !skipGroup);
32
- const mergedChecked = inGroup ? group.value.includes(value) : controlledChecked ?? internalChecked;
33
- const mergedDisabled = (group == null ? void 0 : group.disabled) || disabled;
34
- const mergedName = inGroup ? group == null ? void 0 : group.name : name;
35
- const mergedVariant = inGroup ? (group == null ? void 0 : group.variant) ?? variant : variant;
36
- useEffect(() => {
37
- if (!inGroup || value === void 0) return;
38
- group == null ? void 0 : group.registerValue(value);
39
- return () => group == null ? void 0 : group.cancelValue(value);
40
- }, [group, inGroup, value]);
41
- useEffect(() => {
42
- if (!inGroup || previousValue.current === value) return;
43
- if (previousValue.current !== void 0) group == null ? void 0 : group.cancelValue(previousValue.current);
44
- if (value !== void 0) group == null ? void 0 : group.registerValue(value);
45
- previousValue.current = value;
46
- }, [group, inGroup, value]);
47
- const handleChange = (event) => {
48
- if (mergedDisabled) return;
49
- const nextChecked = event.target.checked;
50
- if (!inGroup && controlledChecked === void 0) setInternalChecked(nextChecked);
51
- const changeEvent = {
52
- target: { ...props, checked: nextChecked },
53
- stopPropagation: () => event.stopPropagation(),
54
- preventDefault: () => event.preventDefault(),
55
- nativeEvent: event.nativeEvent
11
+ checked: k,
12
+ defaultChecked: j = !1,
13
+ disabled: v,
14
+ indeterminate: o = !1,
15
+ children: b,
16
+ className: C,
17
+ style: N,
18
+ onChange: i,
19
+ onMouseEnter: _,
20
+ onMouseLeave: B,
21
+ value: c,
22
+ skipGroup: V = !1,
23
+ direction: w = "ltr",
24
+ name: y,
25
+ variant: m = "dark",
26
+ ...E
27
+ } = r, e = g(q), [D, G] = L(j), s = O(c), a = !!(e && !V), t = a ? e.value.includes(c) : k ?? D, n = (e == null ? void 0 : e.disabled) || v, P = a ? e == null ? void 0 : e.name : y, I = a ? (e == null ? void 0 : e.variant) ?? m : m;
28
+ x(() => {
29
+ if (!(!a || c === void 0))
30
+ return e == null || e.registerValue(c), () => e == null ? void 0 : e.cancelValue(c);
31
+ }, [e, a, c]), x(() => {
32
+ !a || s.current === c || (s.current !== void 0 && (e == null || e.cancelValue(s.current)), c !== void 0 && (e == null || e.registerValue(c)), s.current = c);
33
+ }, [e, a, c]);
34
+ const M = (l) => {
35
+ if (n) return;
36
+ const f = l.target.checked;
37
+ !a && k === void 0 && G(f);
38
+ const R = {
39
+ target: { ...r, checked: f },
40
+ stopPropagation: () => l.stopPropagation(),
41
+ preventDefault: () => l.preventDefault(),
42
+ nativeEvent: l.nativeEvent
56
43
  };
57
- onChange == null ? void 0 : onChange(changeEvent);
58
- if (inGroup && value !== void 0) {
59
- group == null ? void 0 : group.toggleOption({ label: children, value, disabled: mergedDisabled, onChange });
60
- }
44
+ i == null || i(R), a && c !== void 0 && (e == null || e.toggleOption({ label: b, value: c, disabled: n, onChange: i }));
61
45
  };
62
- return /* @__PURE__ */ jsxs(
46
+ return /* @__PURE__ */ h(
63
47
  "label",
64
48
  {
65
- className: classNames(
49
+ className: u(
66
50
  "bj-checkbox-wrapper",
67
- mergedChecked && "bj-checkbox-wrapper--checked",
68
- mergedDisabled && "bj-checkbox-wrapper--disabled",
69
- direction === "rtl" && "bj-checkbox-wrapper--rtl",
70
- className
51
+ t && "bj-checkbox-wrapper--checked",
52
+ n && "bj-checkbox-wrapper--disabled",
53
+ w === "rtl" && "bj-checkbox-wrapper--rtl",
54
+ C
71
55
  ),
72
- onMouseEnter,
73
- onMouseLeave,
74
- style,
56
+ onMouseEnter: _,
57
+ onMouseLeave: B,
58
+ style: N,
75
59
  children: [
76
- /* @__PURE__ */ jsxs(
60
+ /* @__PURE__ */ h(
77
61
  "span",
78
62
  {
79
- className: classNames(
63
+ className: u(
80
64
  "bj-checkbox",
81
- mergedChecked && "bj-checkbox--checked",
82
- mergedDisabled && "bj-checkbox--disabled",
83
- indeterminate && "bj-checkbox--indeterminate",
84
- `bj-checkbox--${mergedVariant}`
65
+ t && "bj-checkbox--checked",
66
+ n && "bj-checkbox--disabled",
67
+ o && "bj-checkbox--indeterminate",
68
+ `bj-checkbox--${I}`
85
69
  ),
86
70
  children: [
87
- /* @__PURE__ */ jsx(
71
+ /* @__PURE__ */ d(
88
72
  "input",
89
73
  {
90
- ...inputProps,
91
- "aria-checked": indeterminate ? "mixed" : mergedChecked,
92
- checked: mergedChecked,
74
+ ...E,
75
+ "aria-checked": o ? "mixed" : t,
76
+ checked: t,
93
77
  className: "bj-checkbox__input",
94
- disabled: mergedDisabled,
95
- name: mergedName,
96
- onChange: handleChange,
97
- ref: forwardedRef,
78
+ disabled: n,
79
+ name: P,
80
+ onChange: M,
81
+ ref: p,
98
82
  type: "checkbox",
99
- value: typeof value === "boolean" ? String(value) : value
83
+ value: typeof c == "boolean" ? String(c) : c
100
84
  }
101
85
  ),
102
- /* @__PURE__ */ jsxs("span", { className: "bj-checkbox__inner", children: [
103
- mergedChecked && !indeterminate && /* @__PURE__ */ jsx(BuIcon, { className: "bj-checkbox__check-icon", type: "icon-a-dagouxi" }),
104
- indeterminate && /* @__PURE__ */ jsx("span", { className: "bj-checkbox__indeterminate-mark" })
86
+ /* @__PURE__ */ h("span", { className: "bj-checkbox__inner", children: [
87
+ t && !o && /* @__PURE__ */ d($, { className: "bj-checkbox__check-icon", type: "icon-a-dagouxi" }),
88
+ o && /* @__PURE__ */ d("span", { className: "bj-checkbox__indeterminate-mark" })
105
89
  ] })
106
90
  ]
107
91
  }
108
92
  ),
109
- children !== void 0 && /* @__PURE__ */ jsx("span", { className: "bj-checkbox__label", children })
93
+ b !== void 0 && /* @__PURE__ */ d("span", { className: "bj-checkbox__label", children: b })
110
94
  ]
111
95
  }
112
96
  );
113
97
  });
114
- BCheckBox.displayName = "BCheckBox";
98
+ z.displayName = "BCheckBox";
115
99
  export {
116
- BCheckBox as default
100
+ z as default
117
101
  };
@@ -1,73 +1 @@
1
- "use strict";
2
- const jsxRuntime = require("react/jsx-runtime");
3
- const react = require("react");
4
- const BCheckBox = require("./BCheckBox.js");
5
- const context = require("./context.js");
6
- function normalizeOptions(options) {
7
- return (options ?? []).map((option) => typeof option === "string" || typeof option === "number" ? { label: option, value: option } : option);
8
- }
9
- const Group = react.forwardRef(({
10
- defaultValue = [],
11
- value: controlledValue,
12
- onChange,
13
- options,
14
- children,
15
- disabled,
16
- name,
17
- className,
18
- style,
19
- direction = "ltr",
20
- variant = "dark"
21
- }, ref) => {
22
- const [internalValue, setInternalValue] = react.useState(defaultValue);
23
- const [registeredValues, setRegisteredValues] = react.useState([]);
24
- const mergedValue = controlledValue ?? internalValue;
25
- const normalizedOptions = react.useMemo(() => normalizeOptions(options), [options]);
26
- react.useEffect(() => {
27
- if (controlledValue !== void 0) setInternalValue(controlledValue);
28
- }, [controlledValue]);
29
- const registerValue = (optionValue) => {
30
- setRegisteredValues((values) => values.includes(optionValue) ? values : [...values, optionValue]);
31
- };
32
- const cancelValue = (optionValue) => {
33
- setRegisteredValues((values) => values.filter((value) => value !== optionValue));
34
- };
35
- const toggleOption = (option) => {
36
- const nextValue = mergedValue.includes(option.value) ? mergedValue.filter((value) => value !== option.value) : [...mergedValue, option.value];
37
- if (controlledValue === void 0) setInternalValue(nextValue);
38
- const optionOrder = normalizedOptions.length > 0 ? normalizedOptions.map((item) => item.value) : registeredValues;
39
- onChange == null ? void 0 : onChange(nextValue.filter((value) => registeredValues.includes(value)).sort((first, second) => optionOrder.indexOf(first) - optionOrder.indexOf(second)));
40
- };
41
- const contextValue = react.useMemo(() => ({
42
- name,
43
- value: mergedValue,
44
- disabled,
45
- variant,
46
- registerValue,
47
- cancelValue,
48
- toggleOption
49
- }), [disabled, mergedValue, name, registeredValues, variant]);
50
- const content = normalizedOptions.length > 0 ? normalizedOptions.map((option) => /* @__PURE__ */ jsxRuntime.jsx(
51
- BCheckBox,
52
- {
53
- className: "bj-checkbox-group__item",
54
- disabled: option.disabled ?? disabled,
55
- onChange: option.onChange,
56
- style: option.style,
57
- value: option.value,
58
- children: option.label
59
- },
60
- String(option.value)
61
- )) : children;
62
- return /* @__PURE__ */ jsxRuntime.jsx(
63
- "div",
64
- {
65
- className: ["bj-checkbox-group", direction === "rtl" ? "bj-checkbox-group--rtl" : "", className].filter(Boolean).join(" "),
66
- ref,
67
- style,
68
- children: /* @__PURE__ */ jsxRuntime.jsx(context.CheckBoxGroupContext.Provider, { value: contextValue, children: content })
69
- }
70
- );
71
- });
72
- Group.displayName = "BCheckBox.Group";
73
- module.exports = Group;
1
+ "use strict";const d=require("react/jsx-runtime"),c=require("react"),z=require("./BCheckBox.js"),C=require("./context.js");function M(n){return(n??[]).map(t=>typeof t=="string"||typeof t=="number"?{label:t,value:t}:t)}const h=c.forwardRef(({defaultValue:n=[],value:t,onChange:i,options:f,children:j,disabled:o,name:m,className:k,style:B,direction:O="ltr",variant:v="dark"},y)=>{const[p,g]=c.useState(n),[x,b]=c.useState([]),u=t??p,l=c.useMemo(()=>M(f),[f]);c.useEffect(()=>{t!==void 0&&g(t)},[t]);const q=e=>{b(r=>r.includes(e)?r:[...r,e])},V=e=>{b(r=>r.filter(a=>a!==e))},G=e=>{const r=u.includes(e.value)?u.filter(s=>s!==e.value):[...u,e.value];t===void 0&&g(r);const a=l.length>0?l.map(s=>s.value):x;i==null||i(r.filter(s=>x.includes(s)).sort((s,S)=>a.indexOf(s)-a.indexOf(S)))},N=c.useMemo(()=>({name:m,value:u,disabled:o,variant:v,registerValue:q,cancelValue:V,toggleOption:G}),[o,u,m,x,v]),R=l.length>0?l.map(e=>d.jsx(z,{className:"bj-checkbox-group__item",disabled:e.disabled??o,onChange:e.onChange,style:e.style,value:e.value,children:e.label},String(e.value))):j;return d.jsx("div",{className:["bj-checkbox-group",O==="rtl"?"bj-checkbox-group--rtl":"",k].filter(Boolean).join(" "),ref:y,style:B,children:d.jsx(C.CheckBoxGroupContext.Provider,{value:N,children:R})})});h.displayName="BCheckBox.Group";module.exports=h;
@@ -1,74 +1,67 @@
1
- import { jsx } from "react/jsx-runtime";
2
- import { forwardRef, useState, useMemo, useEffect } from "react";
3
- import BCheckBox from "./BCheckBox.mjs";
4
- import { CheckBoxGroupContext } from "./context.mjs";
5
- function normalizeOptions(options) {
6
- return (options ?? []).map((option) => typeof option === "string" || typeof option === "number" ? { label: option, value: option } : option);
1
+ import { jsx as o } from "react/jsx-runtime";
2
+ import { forwardRef as S, useState as b, useMemo as h, useEffect as _ } from "react";
3
+ import w from "./BCheckBox.mjs";
4
+ import { CheckBoxGroupContext as E } from "./context.mjs";
5
+ function I(u) {
6
+ return (u ?? []).map((r) => typeof r == "string" || typeof r == "number" ? { label: r, value: r } : r);
7
7
  }
8
- const Group = forwardRef(({
9
- defaultValue = [],
10
- value: controlledValue,
11
- onChange,
12
- options,
13
- children,
14
- disabled,
15
- name,
16
- className,
17
- style,
18
- direction = "ltr",
19
- variant = "dark"
20
- }, ref) => {
21
- const [internalValue, setInternalValue] = useState(defaultValue);
22
- const [registeredValues, setRegisteredValues] = useState([]);
23
- const mergedValue = controlledValue ?? internalValue;
24
- const normalizedOptions = useMemo(() => normalizeOptions(options), [options]);
25
- useEffect(() => {
26
- if (controlledValue !== void 0) setInternalValue(controlledValue);
27
- }, [controlledValue]);
28
- const registerValue = (optionValue) => {
29
- setRegisteredValues((values) => values.includes(optionValue) ? values : [...values, optionValue]);
30
- };
31
- const cancelValue = (optionValue) => {
32
- setRegisteredValues((values) => values.filter((value) => value !== optionValue));
33
- };
34
- const toggleOption = (option) => {
35
- const nextValue = mergedValue.includes(option.value) ? mergedValue.filter((value) => value !== option.value) : [...mergedValue, option.value];
36
- if (controlledValue === void 0) setInternalValue(nextValue);
37
- const optionOrder = normalizedOptions.length > 0 ? normalizedOptions.map((item) => item.value) : registeredValues;
38
- onChange == null ? void 0 : onChange(nextValue.filter((value) => registeredValues.includes(value)).sort((first, second) => optionOrder.indexOf(first) - optionOrder.indexOf(second)));
39
- };
40
- const contextValue = useMemo(() => ({
41
- name,
42
- value: mergedValue,
43
- disabled,
44
- variant,
45
- registerValue,
46
- cancelValue,
47
- toggleOption
48
- }), [disabled, mergedValue, name, registeredValues, variant]);
49
- const content = normalizedOptions.length > 0 ? normalizedOptions.map((option) => /* @__PURE__ */ jsx(
50
- BCheckBox,
8
+ const M = S(({
9
+ defaultValue: u = [],
10
+ value: r,
11
+ onChange: i,
12
+ options: m,
13
+ children: p,
14
+ disabled: n,
15
+ name: d,
16
+ className: k,
17
+ style: B,
18
+ direction: O = "ltr",
19
+ variant: x = "dark"
20
+ }, j) => {
21
+ const [y, v] = b(u), [f, g] = b([]), s = r ?? y, c = h(() => I(m), [m]);
22
+ _(() => {
23
+ r !== void 0 && v(r);
24
+ }, [r]);
25
+ const V = (e) => {
26
+ g((t) => t.includes(e) ? t : [...t, e]);
27
+ }, G = (e) => {
28
+ g((t) => t.filter((a) => a !== e));
29
+ }, N = (e) => {
30
+ const t = s.includes(e.value) ? s.filter((l) => l !== e.value) : [...s, e.value];
31
+ r === void 0 && v(t);
32
+ const a = c.length > 0 ? c.map((l) => l.value) : f;
33
+ i == null || i(t.filter((l) => f.includes(l)).sort((l, R) => a.indexOf(l) - a.indexOf(R)));
34
+ }, z = h(() => ({
35
+ name: d,
36
+ value: s,
37
+ disabled: n,
38
+ variant: x,
39
+ registerValue: V,
40
+ cancelValue: G,
41
+ toggleOption: N
42
+ }), [n, s, d, f, x]), C = c.length > 0 ? c.map((e) => /* @__PURE__ */ o(
43
+ w,
51
44
  {
52
45
  className: "bj-checkbox-group__item",
53
- disabled: option.disabled ?? disabled,
54
- onChange: option.onChange,
55
- style: option.style,
56
- value: option.value,
57
- children: option.label
46
+ disabled: e.disabled ?? n,
47
+ onChange: e.onChange,
48
+ style: e.style,
49
+ value: e.value,
50
+ children: e.label
58
51
  },
59
- String(option.value)
60
- )) : children;
61
- return /* @__PURE__ */ jsx(
52
+ String(e.value)
53
+ )) : p;
54
+ return /* @__PURE__ */ o(
62
55
  "div",
63
56
  {
64
- className: ["bj-checkbox-group", direction === "rtl" ? "bj-checkbox-group--rtl" : "", className].filter(Boolean).join(" "),
65
- ref,
66
- style,
67
- children: /* @__PURE__ */ jsx(CheckBoxGroupContext.Provider, { value: contextValue, children: content })
57
+ className: ["bj-checkbox-group", O === "rtl" ? "bj-checkbox-group--rtl" : "", k].filter(Boolean).join(" "),
58
+ ref: j,
59
+ style: B,
60
+ children: /* @__PURE__ */ o(E.Provider, { value: z, children: C })
68
61
  }
69
62
  );
70
63
  });
71
- Group.displayName = "BCheckBox.Group";
64
+ M.displayName = "BCheckBox.Group";
72
65
  export {
73
- Group as default
66
+ M as default
74
67
  };
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const react = require("react");
4
- const CheckBoxGroupContext = react.createContext(null);
5
- exports.CheckBoxGroupContext = CheckBoxGroupContext;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=e.createContext(null);exports.CheckBoxGroupContext=t;
@@ -1,5 +1,5 @@
1
- import { createContext } from "react";
2
- const CheckBoxGroupContext = createContext(null);
1
+ import { createContext as o } from "react";
2
+ const e = o(null);
3
3
  export {
4
- CheckBoxGroupContext
4
+ e as CheckBoxGroupContext
5
5
  };
@@ -1,8 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const BCheckBox = require("./BCheckBox.js");
4
- const Group = require("./Group.js");
5
- const CompoundBCheckBox = BCheckBox;
6
- CompoundBCheckBox.Group = Group;
7
- CompoundBCheckBox.__ANT_CHECKBOX = true;
8
- exports.BCheckBox = CompoundBCheckBox;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./BCheckBox.js"),r=require("./Group.js"),e=o;e.Group=r;e.__ANT_CHECKBOX=!0;exports.BCheckBox=e;
@@ -1,8 +1,8 @@
1
- import BCheckBox from "./BCheckBox.mjs";
2
- import Group from "./Group.mjs";
3
- const CompoundBCheckBox = BCheckBox;
4
- CompoundBCheckBox.Group = Group;
5
- CompoundBCheckBox.__ANT_CHECKBOX = true;
1
+ import r from "./BCheckBox.mjs";
2
+ import B from "./Group.mjs";
3
+ const o = r;
4
+ o.Group = B;
5
+ o.__ANT_CHECKBOX = !0;
6
6
  export {
7
- CompoundBCheckBox as BCheckBox
7
+ o as BCheckBox
8
8
  };
@@ -1,186 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const react = require("react");
5
- const reactDom = require("react-dom");
6
- const BInput = require("../BasicInput/BInput.js");
7
- const index = require("../CheckBox/index.js");
8
- const Icon = require("../Icon/Icon.js");
9
- const BOverlayScrollbar = require("../OverlayScrollbar/BOverlayScrollbar.js");
10
- ;/* empty css */
11
- const ContentTooltip = require("../Tooltip/ContentTooltip.js");
12
- require("../Tooltip/TooltipWrapper.js");
13
- const no_data_light = require("../ProductField/no_data_light.svg.js");
14
- ;/* empty css */
15
- function classNames(...values) {
16
- return values.filter(Boolean).join(" ");
17
- }
18
- function getOptionText(option) {
19
- return typeof option.label === "string" || typeof option.label === "number" ? String(option.label) : String(option.value);
20
- }
21
- function TruncatedOptionLabel({ option }) {
22
- const labelRef = react.useRef(null);
23
- const [visible, setVisible] = react.useState(false);
24
- const [anchorRect, setAnchorRect] = react.useState(null);
25
- const isTextLabel = typeof option.label === "string" || typeof option.label === "number";
26
- const label = isTextLabel ? String(option.label) : option.label;
27
- function handleMouseEnter() {
28
- const element = labelRef.current;
29
- if (isTextLabel && element && element.scrollWidth > element.clientWidth) {
30
- setAnchorRect(element.getBoundingClientRect());
31
- setVisible(true);
32
- }
33
- }
34
- return /* @__PURE__ */ jsxRuntime.jsxs(
35
- "span",
36
- {
37
- ref: labelRef,
38
- className: "bj-dropdown__option-label",
39
- onMouseEnter: handleMouseEnter,
40
- onMouseLeave: () => setVisible(false),
41
- children: [
42
- label,
43
- visible && anchorRect && typeof document !== "undefined" && reactDom.createPortal(
44
- /* @__PURE__ */ jsxRuntime.jsx(
45
- "span",
46
- {
47
- className: "bj-dropdown__option-tooltip-anchor",
48
- style: {
49
- position: "fixed",
50
- top: anchorRect.top,
51
- left: anchorRect.left,
52
- width: anchorRect.width,
53
- height: anchorRect.height
54
- },
55
- children: /* @__PURE__ */ jsxRuntime.jsx(ContentTooltip, { className: "bj-dropdown__option-tooltip", content: label, placement: "top" })
56
- }
57
- ),
58
- document.body
59
- )
60
- ]
61
- }
62
- );
63
- }
64
- function DefaultOptionContent({ option, doubleLine }) {
65
- if (!doubleLine) return /* @__PURE__ */ jsxRuntime.jsx(TruncatedOptionLabel, { option });
66
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bj-dropdown__option-content", children: [
67
- /* @__PURE__ */ jsxRuntime.jsx(TruncatedOptionLabel, { option }),
68
- option.description !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-dropdown__option-description", children: option.description })
69
- ] });
70
- }
71
- function BDropdown({
72
- className,
73
- style,
74
- options,
75
- value,
76
- defaultValue = [],
77
- multiple = false,
78
- optionMode = "single-line",
79
- searchable = false,
80
- searchValue,
81
- searchPlaceholder = "搜索",
82
- onSearch,
83
- filterOption = true,
84
- emptyText,
85
- labels,
86
- t = (text) => text,
87
- optionRender,
88
- onChange,
89
- footer = true,
90
- showReset = true,
91
- showConfirm = true,
92
- resetText = t("重置"),
93
- confirmText = t("确定"),
94
- onReset,
95
- onConfirm
96
- }) {
97
- const dropdownRef = react.useRef(null);
98
- const optionsRef = react.useRef(null);
99
- const [internalValue, setInternalValue] = react.useState(defaultValue);
100
- const [internalSearchValue, setInternalSearchValue] = react.useState("");
101
- const selectedValue = value ?? internalValue;
102
- const isMultiple = multiple === true;
103
- const isDoubleLine = optionMode === "double-line";
104
- const currentSearchValue = searchValue ?? internalSearchValue;
105
- const resolvedEmptyText = emptyText ?? (labels == null ? void 0 : labels.emptyText) ?? t("暂无结果");
106
- const visibleOptions = !onSearch && filterOption !== false && currentSearchValue ? options.filter((option) => typeof filterOption === "function" ? filterOption(currentSearchValue, option) : getOptionText(option).toLocaleLowerCase().includes(currentSearchValue.toLocaleLowerCase())) : options;
107
- function updateValue(nextValue, option) {
108
- if (value === void 0) {
109
- setInternalValue(nextValue);
110
- }
111
- onChange == null ? void 0 : onChange(nextValue, option);
112
- }
113
- function handleSearch(nextSearchValue) {
114
- if (searchValue === void 0) {
115
- setInternalSearchValue(nextSearchValue);
116
- }
117
- onSearch == null ? void 0 : onSearch(nextSearchValue);
118
- }
119
- function handleOptionChange(option) {
120
- if (option.disabled) return;
121
- const nextValue = isMultiple ? selectedValue.includes(option.value) ? selectedValue.filter((item) => item !== option.value) : [...selectedValue, option.value] : [option.value];
122
- updateValue(nextValue, option);
123
- }
124
- function handleReset() {
125
- if (value === void 0) {
126
- setInternalValue([]);
127
- }
128
- onReset == null ? void 0 : onReset();
129
- }
130
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: dropdownRef, className: classNames("bj-dropdown", isDoubleLine && "bj-dropdown--double-line", !isMultiple && "bj-dropdown--single", className), role: "dialog", style, children: [
131
- searchable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "bj-dropdown__search", children: /* @__PURE__ */ jsxRuntime.jsx(
132
- BInput,
133
- {
134
- "aria-label": "搜索选项",
135
- allowClear: { clearIcon: /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "bj-dropdown__search-clear-icon", type: "icon-a-guanbixi" }) },
136
- onChange: (event) => handleSearch(event.target.value),
137
- onClear: () => handleSearch(""),
138
- placeholder: searchPlaceholder,
139
- prefix: /* @__PURE__ */ jsxRuntime.jsx(Icon, { type: "icon-a-sousuoxi" }),
140
- inputMode: "search",
141
- role: "searchbox",
142
- type: "text",
143
- value: currentSearchValue
144
- }
145
- ) }),
146
- /* @__PURE__ */ jsxRuntime.jsxs("div", { ref: optionsRef, className: classNames("bj-dropdown__options", "bj-overlay-scrollbar-hidden", visibleOptions.length === 0 && "bj-dropdown__options--empty", !isMultiple && "bj-dropdown__options--single"), children: [
147
- visibleOptions.map((option) => isMultiple ? /* @__PURE__ */ jsxRuntime.jsx(
148
- index.BCheckBox,
149
- {
150
- checked: selectedValue.includes(option.value),
151
- className: classNames("bj-dropdown__option", isDoubleLine && option.description !== void 0 && "bj-dropdown__option--double-line"),
152
- disabled: option.disabled,
153
- onChange: () => handleOptionChange(option),
154
- skipGroup: true,
155
- variant: "white",
156
- children: optionRender ? optionRender(option) : /* @__PURE__ */ jsxRuntime.jsx(DefaultOptionContent, { doubleLine: isDoubleLine && option.description !== void 0, option })
157
- },
158
- String(option.value)
159
- ) : /* @__PURE__ */ jsxRuntime.jsxs(
160
- "button",
161
- {
162
- "aria-pressed": selectedValue.includes(option.value),
163
- className: classNames("bj-dropdown__option", "bj-dropdown__option--single", isDoubleLine && option.description !== void 0 && "bj-dropdown__option--double-line", selectedValue.includes(option.value) && "bj-dropdown__option--selected"),
164
- disabled: option.disabled,
165
- onClick: () => handleOptionChange(option),
166
- type: "button",
167
- children: [
168
- optionRender ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-dropdown__option-label", children: optionRender(option) }) : /* @__PURE__ */ jsxRuntime.jsx(DefaultOptionContent, { doubleLine: isDoubleLine && option.description !== void 0, option }),
169
- selectedValue.includes(option.value) && /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "bj-dropdown__option-icon", type: "icon-a-dagouxi" })
170
- ]
171
- },
172
- String(option.value)
173
- )),
174
- visibleOptions.length === 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "bj-dropdown__empty", children: [
175
- /* @__PURE__ */ jsxRuntime.jsx("img", { alt: "", className: "bj-dropdown__empty-image", src: no_data_light }),
176
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-dropdown__empty-text", children: resolvedEmptyText })
177
- ] })
178
- ] }),
179
- /* @__PURE__ */ jsxRuntime.jsx(BOverlayScrollbar, { containerRef: dropdownRef, gap: 2, size: 2, targetRef: optionsRef }),
180
- footer !== false && (footer !== true ? footer : /* @__PURE__ */ jsxRuntime.jsxs("div", { className: classNames("bj-dropdown__actions", !isMultiple && "bj-dropdown__actions--single"), children: [
181
- showReset && /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: handleReset, type: "button", children: resetText }),
182
- isMultiple && showConfirm && /* @__PURE__ */ jsxRuntime.jsx("button", { onClick: () => onConfirm == null ? void 0 : onConfirm(selectedValue), type: "button", children: confirmText })
183
- ] }))
184
- ] });
185
- }
186
- exports.BDropdown = BDropdown;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const n=require("react/jsx-runtime"),r=require("react"),U=require("react-dom"),X=require("../BasicInput/BInput.js"),Y=require("../CheckBox/index.js"),k=require("../Icon/Icon.js"),Z=require("../OverlayScrollbar/BOverlayScrollbar.js");;/* empty css */const $=require("../Tooltip/ContentTooltip.js");require("../Tooltip/TooltipWrapper.js");const ee=require("../ProductField/no_data_light.svg.js");;/* empty css */function u(...s){return s.filter(Boolean).join(" ")}function ne(s){return typeof s.label=="string"||typeof s.label=="number"?String(s.label):String(s.value)}function D({option:s}){const i=r.useRef(null),[b,o]=r.useState(!1),[l,m]=r.useState(null),p=typeof s.label=="string"||typeof s.label=="number",j=p?String(s.label):s.label;function _(){const a=i.current;p&&a&&a.scrollWidth>a.clientWidth&&(m(a.getBoundingClientRect()),o(!0))}return n.jsxs("span",{ref:i,className:"bj-dropdown__option-label",onMouseEnter:_,onMouseLeave:()=>o(!1),children:[j,b&&l&&typeof document<"u"&&U.createPortal(n.jsx("span",{className:"bj-dropdown__option-tooltip-anchor",style:{position:"fixed",top:l.top,left:l.left,width:l.width,height:l.height},children:n.jsx($,{className:"bj-dropdown__option-tooltip",content:j,placement:"top"})}),document.body)]})}function I({option:s,doubleLine:i}){return i?n.jsxs("span",{className:"bj-dropdown__option-content",children:[n.jsx(D,{option:s}),s.description!==void 0&&n.jsx("span",{className:"bj-dropdown__option-description",children:s.description})]}):n.jsx(D,{option:s})}function se({className:s,style:i,options:b,value:o,defaultValue:l=[],multiple:m=!1,optionMode:p="single-line",searchable:j=!1,searchValue:_,searchPlaceholder:a="搜索",onSearch:f,filterOption:v=!0,emptyText:O,labels:g,t:y=h=>h,optionRender:x,onChange:N,footer:q=!0,showReset:E=!0,showConfirm:P=!0,resetText:W=y("重置"),confirmText:z=y("确定"),onReset:L,onConfirm:S}){const h=r.useRef(null),C=r.useRef(null),[A,M]=r.useState(l),[G,F]=r.useState(""),t=o??A,d=m===!0,c=p==="double-line",w=_??G,H=O??(g==null?void 0:g.emptyText)??y("暂无结果"),B=!f&&v!==!1&&w?b.filter(e=>typeof v=="function"?v(w,e):ne(e).toLocaleLowerCase().includes(w.toLocaleLowerCase())):b;function J(e,T){o===void 0&&M(e),N==null||N(e,T)}function R(e){_===void 0&&F(e),f==null||f(e)}function V(e){if(e.disabled)return;const T=d?t.includes(e.value)?t.filter(Q=>Q!==e.value):[...t,e.value]:[e.value];J(T,e)}function K(){o===void 0&&M([]),L==null||L()}return n.jsxs("div",{ref:h,className:u("bj-dropdown",c&&"bj-dropdown--double-line",!d&&"bj-dropdown--single",s),role:"dialog",style:i,children:[j&&n.jsx("div",{className:"bj-dropdown__search",children:n.jsx(X,{"aria-label":"搜索选项",allowClear:{clearIcon:n.jsx(k,{className:"bj-dropdown__search-clear-icon",type:"icon-a-guanbixi"})},onChange:e=>R(e.target.value),onClear:()=>R(""),placeholder:a,prefix:n.jsx(k,{type:"icon-a-sousuoxi"}),inputMode:"search",role:"searchbox",type:"text",value:w})}),n.jsxs("div",{ref:C,className:u("bj-dropdown__options","bj-overlay-scrollbar-hidden",B.length===0&&"bj-dropdown__options--empty",!d&&"bj-dropdown__options--single"),children:[B.map(e=>d?n.jsx(Y.BCheckBox,{checked:t.includes(e.value),className:u("bj-dropdown__option",c&&e.description!==void 0&&"bj-dropdown__option--double-line"),disabled:e.disabled,onChange:()=>V(e),skipGroup:!0,variant:"white",children:x?x(e):n.jsx(I,{doubleLine:c&&e.description!==void 0,option:e})},String(e.value)):n.jsxs("button",{"aria-pressed":t.includes(e.value),className:u("bj-dropdown__option","bj-dropdown__option--single",c&&e.description!==void 0&&"bj-dropdown__option--double-line",t.includes(e.value)&&"bj-dropdown__option--selected"),disabled:e.disabled,onClick:()=>V(e),type:"button",children:[x?n.jsx("span",{className:"bj-dropdown__option-label",children:x(e)}):n.jsx(I,{doubleLine:c&&e.description!==void 0,option:e}),t.includes(e.value)&&n.jsx(k,{className:"bj-dropdown__option-icon",type:"icon-a-dagouxi"})]},String(e.value))),B.length===0&&n.jsxs("div",{className:"bj-dropdown__empty",children:[n.jsx("img",{alt:"",className:"bj-dropdown__empty-image",src:ee}),n.jsx("span",{className:"bj-dropdown__empty-text",children:H})]})]}),n.jsx(Z,{containerRef:h,gap:2,size:2,targetRef:C}),q!==!1&&(q!==!0?q:n.jsxs("div",{className:u("bj-dropdown__actions",!d&&"bj-dropdown__actions--single"),children:[E&&n.jsx("button",{onClick:K,type:"button",children:W}),d&&P&&n.jsx("button",{onClick:()=>S==null?void 0:S(t),type:"button",children:z})]}))]})}exports.BDropdown=se;