bj-web-components 0.2.26 → 0.2.28

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 (109) hide show
  1. package/dist/favicon.ico +0 -0
  2. package/dist/file.svg +1 -0
  3. package/dist/globe.svg +1 -0
  4. package/dist/index.d.ts +1141 -0
  5. package/dist/index.js +51 -0
  6. package/dist/index.mjs +51 -0
  7. package/dist/miniapp.d.ts +1 -0
  8. package/dist/miniapp.js +1 -0
  9. package/dist/miniapp.mjs +1 -0
  10. package/dist/mobile.d.ts +1 -0
  11. package/dist/mobile.js +1 -0
  12. package/dist/mobile.mjs +1 -0
  13. package/dist/next.svg +1 -0
  14. package/dist/react.d.ts +1 -0
  15. package/dist/react.js +1 -0
  16. package/dist/react.mjs +1 -0
  17. package/dist/shared.d.ts +1 -0
  18. package/dist/shared.js +1 -0
  19. package/dist/shared.mjs +1 -0
  20. package/dist/style.css +3744 -0
  21. package/dist/vercel.svg +1 -0
  22. package/dist/web/BasicInput/BInput.js +208 -0
  23. package/dist/web/BasicInput/BInput.mjs +209 -0
  24. package/dist/web/BasicInput/utils.js +47 -0
  25. package/dist/web/BasicInput/utils.mjs +47 -0
  26. package/dist/web/CategoryDropdown/CategoryDropdown.js +307 -0
  27. package/dist/web/CategoryDropdown/CategoryDropdown.mjs +308 -0
  28. package/dist/web/CheckBox/BCheckBox.js +116 -0
  29. package/dist/web/CheckBox/BCheckBox.mjs +117 -0
  30. package/dist/web/CheckBox/Group.js +73 -0
  31. package/dist/web/CheckBox/Group.mjs +74 -0
  32. package/dist/web/CheckBox/context.js +5 -0
  33. package/dist/web/CheckBox/context.mjs +5 -0
  34. package/dist/web/CheckBox/index.js +8 -0
  35. package/dist/web/CheckBox/index.mjs +8 -0
  36. package/dist/web/Dropdown/BDropdown.js +186 -0
  37. package/dist/web/Dropdown/BDropdown.mjs +186 -0
  38. package/dist/web/EmptyInputBox/EmptyInputBox.js +77 -0
  39. package/dist/web/EmptyInputBox/EmptyInputBox.mjs +78 -0
  40. package/dist/web/FileCard/FileCard.js +157 -0
  41. package/dist/web/FileCard/FileCard.mjs +158 -0
  42. package/dist/web/Icon/Icon.js +9 -0
  43. package/dist/web/Icon/Icon.mjs +10 -0
  44. package/dist/web/Input/Input.js +181 -0
  45. package/dist/web/Input/Input.mjs +182 -0
  46. package/dist/web/InputNumber/BInputNumber.js +311 -0
  47. package/dist/web/InputNumber/BInputNumber.mjs +312 -0
  48. package/dist/web/InputNumber/StepHandler.js +69 -0
  49. package/dist/web/InputNumber/StepHandler.mjs +70 -0
  50. package/dist/web/InputNumber/hooks/useCursor.js +40 -0
  51. package/dist/web/InputNumber/hooks/useCursor.mjs +41 -0
  52. package/dist/web/InputNumber/hooks/useFrame.js +12 -0
  53. package/dist/web/InputNumber/hooks/useFrame.mjs +13 -0
  54. package/dist/web/InputNumber/utils/decimal.js +147 -0
  55. package/dist/web/InputNumber/utils/decimal.mjs +147 -0
  56. package/dist/web/Modal/Modal.js +84 -0
  57. package/dist/web/Modal/Modal.mjs +85 -0
  58. package/dist/web/OverlayScrollbar/BOverlayScrollbar.js +232 -0
  59. package/dist/web/OverlayScrollbar/BOverlayScrollbar.mjs +233 -0
  60. package/dist/web/Pagination/Pagination.js +328 -0
  61. package/dist/web/Pagination/Pagination.mjs +329 -0
  62. package/dist/web/ProductField/ProductField.js +272 -0
  63. package/dist/web/ProductField/ProductField.mjs +273 -0
  64. package/dist/web/ProductField/arrow-up.svg.js +3 -0
  65. package/dist/web/ProductField/arrow-up.svg.mjs +4 -0
  66. package/dist/web/ProductField/checkbox-no.svg.js +3 -0
  67. package/dist/web/ProductField/checkbox-no.svg.mjs +4 -0
  68. package/dist/web/ProductField/checkbox-ok.svg.js +3 -0
  69. package/dist/web/ProductField/checkbox-ok.svg.mjs +4 -0
  70. package/dist/web/ProductField/no_data_light.svg.js +3 -0
  71. package/dist/web/ProductField/no_data_light.svg.mjs +4 -0
  72. package/dist/web/ProductField/search.svg.js +3 -0
  73. package/dist/web/ProductField/search.svg.mjs +4 -0
  74. package/dist/web/ProductField/sort.svg.js +3 -0
  75. package/dist/web/ProductField/sort.svg.mjs +4 -0
  76. package/dist/web/SkuInputCard/SkuInputCard.js +276 -0
  77. package/dist/web/SkuInputCard/SkuInputCard.mjs +277 -0
  78. package/dist/web/SkuInputCard/spin_loading_red.gif.js +3 -0
  79. package/dist/web/SkuInputCard/spin_loading_red.gif.mjs +4 -0
  80. package/dist/web/Switch/Switch.js +70 -0
  81. package/dist/web/Switch/Switch.mjs +71 -0
  82. package/dist/web/Table/BTable.js +950 -0
  83. package/dist/web/Table/BTable.mjs +950 -0
  84. package/dist/web/Table/Column.js +5 -0
  85. package/dist/web/Table/Column.mjs +6 -0
  86. package/dist/web/Table/ColumnGroup.js +5 -0
  87. package/dist/web/Table/ColumnGroup.mjs +6 -0
  88. package/dist/web/Table/utils/columns.js +48 -0
  89. package/dist/web/Table/utils/columns.mjs +48 -0
  90. package/dist/web/Table/utils/sortFilter.js +84 -0
  91. package/dist/web/Table/utils/sortFilter.mjs +84 -0
  92. package/dist/web/Tabs/BTabs.js +150 -0
  93. package/dist/web/Tabs/BTabs.mjs +150 -0
  94. package/dist/web/Tabs/TabPane.js +8 -0
  95. package/dist/web/Tabs/TabPane.mjs +8 -0
  96. package/dist/web/Tooltip/ConfirmTooltip.js +26 -0
  97. package/dist/web/Tooltip/ConfirmTooltip.mjs +27 -0
  98. package/dist/web/Tooltip/ContentTooltip.js +94 -0
  99. package/dist/web/Tooltip/ContentTooltip.mjs +95 -0
  100. package/dist/web/Tooltip/ProgressTooltip.js +36 -0
  101. package/dist/web/Tooltip/ProgressTooltip.mjs +37 -0
  102. package/dist/web/Tooltip/TooltipWrapper.js +12 -0
  103. package/dist/web/Tooltip/TooltipWrapper.mjs +13 -0
  104. package/dist/web/Tooltip/useAutoPlacement.js +41 -0
  105. package/dist/web/Tooltip/useAutoPlacement.mjs +41 -0
  106. package/dist/web.d.ts +1141 -0
  107. package/dist/web.js +51 -0
  108. package/dist/web.mjs +51 -0
  109. package/package.json +1 -1
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ const jsxRuntime = require("react/jsx-runtime");
3
+ const react = require("react");
4
+ const Icon = require("../Icon/Icon.js");
5
+ const context = require("./context.js");
6
+ ;/* empty css */
7
+ function classNames(...values) {
8
+ return values.filter(Boolean).join(" ");
9
+ }
10
+ const BCheckBox = react.forwardRef((props, forwardedRef) => {
11
+ const {
12
+ checked: controlledChecked,
13
+ defaultChecked = false,
14
+ disabled,
15
+ indeterminate = false,
16
+ children,
17
+ className,
18
+ style,
19
+ onChange,
20
+ onMouseEnter,
21
+ onMouseLeave,
22
+ value,
23
+ skipGroup = false,
24
+ direction = "ltr",
25
+ name,
26
+ variant = "dark",
27
+ ...inputProps
28
+ } = props;
29
+ const group = react.useContext(context.CheckBoxGroupContext);
30
+ const [internalChecked, setInternalChecked] = react.useState(defaultChecked);
31
+ const previousValue = react.useRef(value);
32
+ const inGroup = Boolean(group && !skipGroup);
33
+ const mergedChecked = inGroup ? group.value.includes(value) : controlledChecked ?? internalChecked;
34
+ const mergedDisabled = (group == null ? void 0 : group.disabled) || disabled;
35
+ const mergedName = inGroup ? group == null ? void 0 : group.name : name;
36
+ const mergedVariant = inGroup ? (group == null ? void 0 : group.variant) ?? variant : variant;
37
+ react.useEffect(() => {
38
+ if (!inGroup || value === void 0) return;
39
+ group == null ? void 0 : group.registerValue(value);
40
+ return () => group == null ? void 0 : group.cancelValue(value);
41
+ }, [group, inGroup, value]);
42
+ react.useEffect(() => {
43
+ if (!inGroup || previousValue.current === value) return;
44
+ if (previousValue.current !== void 0) group == null ? void 0 : group.cancelValue(previousValue.current);
45
+ if (value !== void 0) group == null ? void 0 : group.registerValue(value);
46
+ previousValue.current = value;
47
+ }, [group, inGroup, value]);
48
+ const handleChange = (event) => {
49
+ if (mergedDisabled) return;
50
+ const nextChecked = event.target.checked;
51
+ if (!inGroup && controlledChecked === void 0) setInternalChecked(nextChecked);
52
+ const changeEvent = {
53
+ target: { ...props, checked: nextChecked },
54
+ stopPropagation: () => event.stopPropagation(),
55
+ preventDefault: () => event.preventDefault(),
56
+ nativeEvent: event.nativeEvent
57
+ };
58
+ onChange == null ? void 0 : onChange(changeEvent);
59
+ if (inGroup && value !== void 0) {
60
+ group == null ? void 0 : group.toggleOption({ label: children, value, disabled: mergedDisabled, onChange });
61
+ }
62
+ };
63
+ return /* @__PURE__ */ jsxRuntime.jsxs(
64
+ "label",
65
+ {
66
+ className: classNames(
67
+ "bj-checkbox-wrapper",
68
+ mergedChecked && "bj-checkbox-wrapper--checked",
69
+ mergedDisabled && "bj-checkbox-wrapper--disabled",
70
+ direction === "rtl" && "bj-checkbox-wrapper--rtl",
71
+ className
72
+ ),
73
+ onMouseEnter,
74
+ onMouseLeave,
75
+ style,
76
+ children: [
77
+ /* @__PURE__ */ jsxRuntime.jsxs(
78
+ "span",
79
+ {
80
+ className: classNames(
81
+ "bj-checkbox",
82
+ mergedChecked && "bj-checkbox--checked",
83
+ mergedDisabled && "bj-checkbox--disabled",
84
+ indeterminate && "bj-checkbox--indeterminate",
85
+ `bj-checkbox--${mergedVariant}`
86
+ ),
87
+ children: [
88
+ /* @__PURE__ */ jsxRuntime.jsx(
89
+ "input",
90
+ {
91
+ ...inputProps,
92
+ "aria-checked": indeterminate ? "mixed" : mergedChecked,
93
+ checked: mergedChecked,
94
+ className: "bj-checkbox__input",
95
+ disabled: mergedDisabled,
96
+ name: mergedName,
97
+ onChange: handleChange,
98
+ ref: forwardedRef,
99
+ type: "checkbox",
100
+ value: typeof value === "boolean" ? String(value) : value
101
+ }
102
+ ),
103
+ /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "bj-checkbox__inner", children: [
104
+ mergedChecked && !indeterminate && /* @__PURE__ */ jsxRuntime.jsx(Icon, { className: "bj-checkbox__check-icon", type: "icon-a-dagouxi" }),
105
+ indeterminate && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-checkbox__indeterminate-mark" })
106
+ ] })
107
+ ]
108
+ }
109
+ ),
110
+ children !== void 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "bj-checkbox__label", children })
111
+ ]
112
+ }
113
+ );
114
+ });
115
+ BCheckBox.displayName = "BCheckBox";
116
+ module.exports = BCheckBox;
@@ -0,0 +1,117 @@
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";
5
+ /* empty css */
6
+ function classNames(...values) {
7
+ return values.filter(Boolean).join(" ");
8
+ }
9
+ const BCheckBox = forwardRef((props, forwardedRef) => {
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
56
+ };
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
+ }
61
+ };
62
+ return /* @__PURE__ */ jsxs(
63
+ "label",
64
+ {
65
+ className: classNames(
66
+ "bj-checkbox-wrapper",
67
+ mergedChecked && "bj-checkbox-wrapper--checked",
68
+ mergedDisabled && "bj-checkbox-wrapper--disabled",
69
+ direction === "rtl" && "bj-checkbox-wrapper--rtl",
70
+ className
71
+ ),
72
+ onMouseEnter,
73
+ onMouseLeave,
74
+ style,
75
+ children: [
76
+ /* @__PURE__ */ jsxs(
77
+ "span",
78
+ {
79
+ className: classNames(
80
+ "bj-checkbox",
81
+ mergedChecked && "bj-checkbox--checked",
82
+ mergedDisabled && "bj-checkbox--disabled",
83
+ indeterminate && "bj-checkbox--indeterminate",
84
+ `bj-checkbox--${mergedVariant}`
85
+ ),
86
+ children: [
87
+ /* @__PURE__ */ jsx(
88
+ "input",
89
+ {
90
+ ...inputProps,
91
+ "aria-checked": indeterminate ? "mixed" : mergedChecked,
92
+ checked: mergedChecked,
93
+ className: "bj-checkbox__input",
94
+ disabled: mergedDisabled,
95
+ name: mergedName,
96
+ onChange: handleChange,
97
+ ref: forwardedRef,
98
+ type: "checkbox",
99
+ value: typeof value === "boolean" ? String(value) : value
100
+ }
101
+ ),
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" })
105
+ ] })
106
+ ]
107
+ }
108
+ ),
109
+ children !== void 0 && /* @__PURE__ */ jsx("span", { className: "bj-checkbox__label", children })
110
+ ]
111
+ }
112
+ );
113
+ });
114
+ BCheckBox.displayName = "BCheckBox";
115
+ export {
116
+ BCheckBox as default
117
+ };
@@ -0,0 +1,73 @@
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;
@@ -0,0 +1,74 @@
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);
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,
51
+ {
52
+ 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
58
+ },
59
+ String(option.value)
60
+ )) : children;
61
+ return /* @__PURE__ */ jsx(
62
+ "div",
63
+ {
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 })
68
+ }
69
+ );
70
+ });
71
+ Group.displayName = "BCheckBox.Group";
72
+ export {
73
+ Group as default
74
+ };
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,5 @@
1
+ import { createContext } from "react";
2
+ const CheckBoxGroupContext = createContext(null);
3
+ export {
4
+ CheckBoxGroupContext
5
+ };
@@ -0,0 +1,8 @@
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;
@@ -0,0 +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;
6
+ export {
7
+ CompoundBCheckBox as BCheckBox
8
+ };
@@ -0,0 +1,186 @@
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;