@mw-kit/mw-ui 1.8.0 → 1.8.2

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/index.js CHANGED
@@ -13464,30 +13464,60 @@ var SelectAllContainer = import_styled_components43.default.div`
13464
13464
 
13465
13465
  // src/components/Input/components/Select/hooks/SelectMultiple/components/Header/index.tsx
13466
13466
  var import_jsx_runtime324 = require("react/jsx-runtime");
13467
- var Header3 = () => {
13467
+ var CheckAll = () => {
13468
13468
  const context = useContext3();
13469
- if (!context.props.search) {
13470
- return /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(import_react33.default.Fragment, {});
13471
- }
13472
13469
  const {
13473
13470
  checked: [checked, setChecked],
13474
- searchInput: [searchInput, setSearchInput],
13475
13471
  options
13476
13472
  } = context;
13473
+ const maxCheck = options.reduce((count, o, idx) => {
13474
+ var _a;
13475
+ if (o.disabled) return count;
13476
+ const rule = (_a = o.rules) == null ? void 0 : _a.some((rule2) => rule2(idx, o.data) !== true);
13477
+ if (rule) return count;
13478
+ return count + 1;
13479
+ }, 0);
13477
13480
  const onClick = () => {
13478
- setChecked(
13479
- (prev) => prev.length === options.length ? [] : options.map((o) => ({ value: o.value, data: o.data }))
13480
- );
13481
+ setChecked((prev) => {
13482
+ if (prev.length >= maxCheck) return [];
13483
+ const checked2 = options.reduce(
13484
+ (checked3, o, idx) => {
13485
+ var _a;
13486
+ if (o.disabled) return checked3;
13487
+ const rule = (_a = o.rules) == null ? void 0 : _a.some((rule2) => rule2(idx, o.data) !== true);
13488
+ if (rule) return checked3;
13489
+ return [...checked3, { value: o.value, data: o.data }];
13490
+ },
13491
+ []
13492
+ );
13493
+ return checked2;
13494
+ });
13481
13495
  };
13482
- return /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)(HeaderContainer2, { children: [
13483
- context.props.selectAll && /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)(SelectAllContainer, { children: [
13484
- /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)("b", { children: [
13485
- "Selecionados (",
13486
- checked.length,
13487
- ")"
13488
- ] }),
13489
- /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(Link_default2, { children: "Selecionar todos", onClick })
13496
+ return /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)(SelectAllContainer, { children: [
13497
+ /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)("b", { children: [
13498
+ "Selecionados (",
13499
+ checked.length,
13500
+ ")"
13490
13501
  ] }),
13502
+ /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(
13503
+ Link_default2,
13504
+ {
13505
+ children: checked.length >= maxCheck ? "Desmarcar todos" : "Selecionar todos",
13506
+ onClick
13507
+ }
13508
+ )
13509
+ ] });
13510
+ };
13511
+ var Header3 = () => {
13512
+ const context = useContext3();
13513
+ if (!context.props.search) {
13514
+ return /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(import_react33.default.Fragment, {});
13515
+ }
13516
+ const {
13517
+ searchInput: [searchInput, setSearchInput]
13518
+ } = context;
13519
+ return /* @__PURE__ */ (0, import_jsx_runtime324.jsxs)(HeaderContainer2, { children: [
13520
+ context.props.selectAll && /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(CheckAll, {}),
13491
13521
  /* @__PURE__ */ (0, import_jsx_runtime324.jsx)(
13492
13522
  Input_default,
13493
13523
  {
package/dist/index.mjs CHANGED
@@ -13408,30 +13408,60 @@ var SelectAllContainer = styled40.div`
13408
13408
 
13409
13409
  // src/components/Input/components/Select/hooks/SelectMultiple/components/Header/index.tsx
13410
13410
  import { jsx as jsx324, jsxs as jsxs159 } from "react/jsx-runtime";
13411
- var Header3 = () => {
13411
+ var CheckAll = () => {
13412
13412
  const context = useContext3();
13413
- if (!context.props.search) {
13414
- return /* @__PURE__ */ jsx324(React30.Fragment, {});
13415
- }
13416
13413
  const {
13417
13414
  checked: [checked, setChecked],
13418
- searchInput: [searchInput, setSearchInput],
13419
13415
  options
13420
13416
  } = context;
13417
+ const maxCheck = options.reduce((count, o, idx) => {
13418
+ var _a;
13419
+ if (o.disabled) return count;
13420
+ const rule = (_a = o.rules) == null ? void 0 : _a.some((rule2) => rule2(idx, o.data) !== true);
13421
+ if (rule) return count;
13422
+ return count + 1;
13423
+ }, 0);
13421
13424
  const onClick = () => {
13422
- setChecked(
13423
- (prev) => prev.length === options.length ? [] : options.map((o) => ({ value: o.value, data: o.data }))
13424
- );
13425
+ setChecked((prev) => {
13426
+ if (prev.length >= maxCheck) return [];
13427
+ const checked2 = options.reduce(
13428
+ (checked3, o, idx) => {
13429
+ var _a;
13430
+ if (o.disabled) return checked3;
13431
+ const rule = (_a = o.rules) == null ? void 0 : _a.some((rule2) => rule2(idx, o.data) !== true);
13432
+ if (rule) return checked3;
13433
+ return [...checked3, { value: o.value, data: o.data }];
13434
+ },
13435
+ []
13436
+ );
13437
+ return checked2;
13438
+ });
13425
13439
  };
13426
- return /* @__PURE__ */ jsxs159(HeaderContainer2, { children: [
13427
- context.props.selectAll && /* @__PURE__ */ jsxs159(SelectAllContainer, { children: [
13428
- /* @__PURE__ */ jsxs159("b", { children: [
13429
- "Selecionados (",
13430
- checked.length,
13431
- ")"
13432
- ] }),
13433
- /* @__PURE__ */ jsx324(Link_default2, { children: "Selecionar todos", onClick })
13440
+ return /* @__PURE__ */ jsxs159(SelectAllContainer, { children: [
13441
+ /* @__PURE__ */ jsxs159("b", { children: [
13442
+ "Selecionados (",
13443
+ checked.length,
13444
+ ")"
13434
13445
  ] }),
13446
+ /* @__PURE__ */ jsx324(
13447
+ Link_default2,
13448
+ {
13449
+ children: checked.length >= maxCheck ? "Desmarcar todos" : "Selecionar todos",
13450
+ onClick
13451
+ }
13452
+ )
13453
+ ] });
13454
+ };
13455
+ var Header3 = () => {
13456
+ const context = useContext3();
13457
+ if (!context.props.search) {
13458
+ return /* @__PURE__ */ jsx324(React30.Fragment, {});
13459
+ }
13460
+ const {
13461
+ searchInput: [searchInput, setSearchInput]
13462
+ } = context;
13463
+ return /* @__PURE__ */ jsxs159(HeaderContainer2, { children: [
13464
+ context.props.selectAll && /* @__PURE__ */ jsx324(CheckAll, {}),
13435
13465
  /* @__PURE__ */ jsx324(
13436
13466
  Input_default,
13437
13467
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mw-kit/mw-ui",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "Made with create-react-library",
5
5
  "author": "fmgusmao",
6
6
  "license": "MIT",
@@ -33,8 +33,8 @@
33
33
  },
34
34
  "dependencies": {},
35
35
  "peerDependencies": {
36
- "react": "^18.1.0",
37
- "react-dom": "^18.1.0",
36
+ "react": "^18.3.1",
37
+ "react-dom": "^18.3.1",
38
38
  "semantic-ui-css": "^2.5.0",
39
39
  "semantic-ui-react": "^2.1.5",
40
40
  "styled-components": "^6.1.19",
@@ -84,7 +84,7 @@
84
84
  "@testing-library/user-event": "^13.2.1",
85
85
  "@trivago/prettier-plugin-sort-imports": "^4.1.1",
86
86
  "@types/jest": "^27.0.1",
87
- "@types/node": "^24.0.12",
87
+ "@types/node": "^22.16.3",
88
88
  "@types/react": "^18.3.1",
89
89
  "@types/react-dom": "^18.3.1",
90
90
  "@typescript-eslint/eslint-plugin": "^7.18.0",