fictoan-react 1.11.6 → 1.11.8

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.
@@ -905,10 +905,8 @@ function _iterableToArrayLimit$e(r, l) {
905
905
  if (null != t) {
906
906
  var e, n, i, u, a = [], f = true, o = false;
907
907
  try {
908
- if (i = (t = t.call(r)).next, 0 === l) {
909
- if (Object(t) !== t) return;
910
- f = false;
911
- } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
908
+ if (i = (t = t.call(r)).next, 0 === l) ;
909
+ else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
912
910
  } catch (r2) {
913
911
  o = true, n = r2;
914
912
  } finally {
@@ -957,34 +955,46 @@ var CodeBlock = /* @__PURE__ */ React.forwardRef(function(_ref, ref) {
957
955
  if (!withSyntaxHighlighting) return;
958
956
  var loadPrismWithLanguage = /* @__PURE__ */ function() {
959
957
  var _ref2 = _asyncToGenerator(/* @__PURE__ */ _regeneratorRuntime().mark(function _callee() {
960
- var _yield$Promise$all, _yield$Promise$all2, prism;
958
+ var prism;
961
959
  return _regeneratorRuntime().wrap(function _callee$(_context) {
962
960
  while (1) switch (_context.prev = _context.next) {
963
961
  case 0:
964
962
  setIsLoading(true);
965
963
  _context.prev = 1;
966
964
  _context.next = 4;
967
- return Promise.all([import("prismjs"), language !== "plain" ? import("prismjs/components/prism-".concat(language)) : Promise.resolve()]);
965
+ return import("prismjs");
968
966
  case 4:
969
- _yield$Promise$all = _context.sent;
970
- _yield$Promise$all2 = _slicedToArray$e(_yield$Promise$all, 1);
971
- prism = _yield$Promise$all2[0];
967
+ prism = _context.sent;
968
+ if (!(language !== "plain")) {
969
+ _context.next = 11;
970
+ break;
971
+ }
972
+ _context.next = 8;
973
+ return import("prismjs/components/prism-".concat(language));
974
+ case 8:
975
+ _context.t0 = _context.sent;
976
+ _context.next = 12;
977
+ break;
978
+ case 11:
979
+ _context.t0 = null;
980
+ case 12:
981
+ _context.t0;
972
982
  setPrismModule(prism["default"]);
973
- _context.next = 13;
983
+ _context.next = 19;
974
984
  break;
975
- case 10:
976
- _context.prev = 10;
977
- _context.t0 = _context["catch"](1);
978
- console.warn("Failed to load syntax highlighting for ".concat(language, ":"), _context.t0);
979
- case 13:
980
- _context.prev = 13;
981
- setIsLoading(false);
982
- return _context.finish(13);
983
985
  case 16:
986
+ _context.prev = 16;
987
+ _context.t1 = _context["catch"](1);
988
+ console.warn("Failed to load syntax highlighting for ".concat(language, ":"), _context.t1);
989
+ case 19:
990
+ _context.prev = 19;
991
+ setIsLoading(false);
992
+ return _context.finish(19);
993
+ case 22:
984
994
  case "end":
985
995
  return _context.stop();
986
996
  }
987
- }, _callee, null, [[1, 10, 13, 16]]);
997
+ }, _callee, null, [[1, 16, 19, 22]]);
988
998
  }));
989
999
  return function loadPrismWithLanguage2() {
990
1000
  return _ref2.apply(this, arguments);
@@ -4218,7 +4228,7 @@ var NotificationItem = /* @__PURE__ */ React.forwardRef(function(_ref, ref) {
4218
4228
  className: "sr-only"
4219
4229
  }, "Close notification")));
4220
4230
  });
4221
- var _excluded$g = ["children", "allowMultipleSelections", "showTickIcon", "onSelectionChange", "tickPosition"], _excluded2$2 = ["id", "children", "disabled"];
4231
+ var _excluded$g = ["children", "allowMultipleSelections", "showTickIcon", "onSelectionChange", "tickPosition", "selectionLimit"], _excluded2$2 = ["id", "children", "disabled"];
4222
4232
  function _extends$g() {
4223
4233
  return _extends$g = Object.assign ? Object.assign.bind() : function(n) {
4224
4234
  for (var e = 1; e < arguments.length; e++) {
@@ -4251,8 +4261,10 @@ function _iterableToArrayLimit$5(r, l) {
4251
4261
  if (null != t) {
4252
4262
  var e, n, i, u, a = [], f = true, o = false;
4253
4263
  try {
4254
- if (i = (t = t.call(r)).next, 0 === l) ;
4255
- else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
4264
+ if (i = (t = t.call(r)).next, 0 === l) {
4265
+ if (Object(t) !== t) return;
4266
+ f = false;
4267
+ } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = true) ;
4256
4268
  } catch (r2) {
4257
4269
  o = true, n = r2;
4258
4270
  } finally {
@@ -4293,12 +4305,27 @@ var OptionCardsContext = /* @__PURE__ */ createContext({
4293
4305
  toggleSelection: function toggleSelection() {
4294
4306
  },
4295
4307
  showTickIcon: false,
4296
- tickPosition: "top-right"
4308
+ tickPosition: "top-right",
4309
+ selectAllOptions: function selectAllOptions() {
4310
+ },
4311
+ clearAllOptions: function clearAllOptions() {
4312
+ },
4313
+ registerOption: function registerOption() {
4314
+ },
4315
+ unregisterOption: function unregisterOption() {
4316
+ }
4297
4317
  });
4298
4318
  var OptionCardsGroup = function OptionCardsGroup2(_ref) {
4299
- var children = _ref.children, _ref$allowMultipleSel = _ref.allowMultipleSelections, allowMultipleSelections = _ref$allowMultipleSel === void 0 ? false : _ref$allowMultipleSel, showTickIcon = _ref.showTickIcon, onSelectionChange = _ref.onSelectionChange, _ref$tickPosition = _ref.tickPosition, tickPosition = _ref$tickPosition === void 0 ? "top-right" : _ref$tickPosition;
4319
+ var children = _ref.children, _ref$allowMultipleSel = _ref.allowMultipleSelections, allowMultipleSelections = _ref$allowMultipleSel === void 0 ? false : _ref$allowMultipleSel, showTickIcon = _ref.showTickIcon, onSelectionChange = _ref.onSelectionChange, _ref$tickPosition = _ref.tickPosition, tickPosition = _ref$tickPosition === void 0 ? "top-right" : _ref$tickPosition, selectionLimit = _ref.selectionLimit;
4300
4320
  _objectWithoutProperties$g(_ref, _excluded$g);
4301
4321
  var _useState = useState(/* @__PURE__ */ new Set()), _useState2 = _slicedToArray$5(_useState, 2), selectedIds = _useState2[0], setSelectedIds = _useState2[1];
4322
+ var availableOptionsRef = useRef(/* @__PURE__ */ new Map());
4323
+ var registerOption2 = useCallback(function(id, disabled) {
4324
+ availableOptionsRef.current.set(id, disabled);
4325
+ }, []);
4326
+ var unregisterOption2 = useCallback(function(id) {
4327
+ availableOptionsRef.current["delete"](id);
4328
+ }, []);
4302
4329
  var toggleSelection2 = useCallback(function(id) {
4303
4330
  setSelectedIds(function(prevSelectedIds) {
4304
4331
  var newSelectedIds = new Set(prevSelectedIds);
@@ -4306,6 +4333,9 @@ var OptionCardsGroup = function OptionCardsGroup2(_ref) {
4306
4333
  if (newSelectedIds.has(id)) {
4307
4334
  newSelectedIds["delete"](id);
4308
4335
  } else {
4336
+ if (selectionLimit && newSelectedIds.size >= selectionLimit) {
4337
+ return prevSelectedIds;
4338
+ }
4309
4339
  newSelectedIds.add(id);
4310
4340
  }
4311
4341
  } else {
@@ -4319,17 +4349,47 @@ var OptionCardsGroup = function OptionCardsGroup2(_ref) {
4319
4349
  onSelectionChange === null || onSelectionChange === void 0 || onSelectionChange(newSelectedIds);
4320
4350
  return newSelectedIds;
4321
4351
  });
4322
- }, [allowMultipleSelections, onSelectionChange]);
4352
+ }, [allowMultipleSelections, onSelectionChange, selectionLimit]);
4353
+ var selectAllOptions2 = useCallback(function() {
4354
+ if (!allowMultipleSelections) return;
4355
+ setSelectedIds(function(prevSelectedIds) {
4356
+ var newSelectedIds = new Set(prevSelectedIds);
4357
+ var enabledOptions = Array.from(availableOptionsRef.current.entries()).filter(function(_ref2) {
4358
+ var _ref3 = _slicedToArray$5(_ref2, 2);
4359
+ _ref3[0];
4360
+ var disabled = _ref3[1];
4361
+ return !disabled;
4362
+ }).map(function(_ref4) {
4363
+ var _ref5 = _slicedToArray$5(_ref4, 1), id = _ref5[0];
4364
+ return id;
4365
+ });
4366
+ var optionsToAdd = selectionLimit ? enabledOptions.slice(0, selectionLimit) : enabledOptions;
4367
+ optionsToAdd.forEach(function(id) {
4368
+ return newSelectedIds.add(id);
4369
+ });
4370
+ onSelectionChange === null || onSelectionChange === void 0 || onSelectionChange(newSelectedIds);
4371
+ return newSelectedIds;
4372
+ });
4373
+ }, [allowMultipleSelections, selectionLimit, onSelectionChange]);
4374
+ var clearAllOptions2 = useCallback(function() {
4375
+ setSelectedIds(/* @__PURE__ */ new Set());
4376
+ onSelectionChange === null || onSelectionChange === void 0 || onSelectionChange(/* @__PURE__ */ new Set());
4377
+ }, [onSelectionChange]);
4323
4378
  var isSelected2 = useCallback(function(id) {
4324
4379
  return selectedIds.has(id);
4325
4380
  }, [selectedIds]);
4381
+ var contextValue = {
4382
+ isSelected: isSelected2,
4383
+ toggleSelection: toggleSelection2,
4384
+ showTickIcon,
4385
+ tickPosition,
4386
+ selectAllOptions: selectAllOptions2,
4387
+ clearAllOptions: clearAllOptions2,
4388
+ registerOption: registerOption2,
4389
+ unregisterOption: unregisterOption2
4390
+ };
4326
4391
  return /* @__PURE__ */ React.createElement(OptionCardsContext.Provider, {
4327
- value: {
4328
- isSelected: isSelected2,
4329
- toggleSelection: toggleSelection2,
4330
- showTickIcon,
4331
- tickPosition
4332
- }
4392
+ value: contextValue
4333
4393
  }, /* @__PURE__ */ React.createElement(Div, {
4334
4394
  "data-option-cards-group": true,
4335
4395
  className: "tick-".concat(tickPosition)
@@ -4345,13 +4405,19 @@ var useOptionCard = function useOptionCard2(id) {
4345
4405
  showTickIcon: context.showTickIcon
4346
4406
  };
4347
4407
  };
4348
- var OptionCard = function OptionCard2(_ref2) {
4349
- var id = _ref2.id, children = _ref2.children, _ref2$disabled = _ref2.disabled, disabled = _ref2$disabled === void 0 ? false : _ref2$disabled, props = _objectWithoutProperties$g(_ref2, _excluded2$2);
4350
- var _useOptionCard = useOptionCard(id), isSelected2 = _useOptionCard.isSelected, toggleSelection2 = _useOptionCard.toggleSelection, showTickIcon = _useOptionCard.showTickIcon;
4408
+ var OptionCard = function OptionCard2(_ref6) {
4409
+ var id = _ref6.id, children = _ref6.children, _ref6$disabled = _ref6.disabled, disabled = _ref6$disabled === void 0 ? false : _ref6$disabled, props = _objectWithoutProperties$g(_ref6, _excluded2$2);
4410
+ var _useContext2 = useContext(OptionCardsContext), isSelected2 = _useContext2.isSelected, toggleSelection2 = _useContext2.toggleSelection, showTickIcon = _useContext2.showTickIcon, registerOption2 = _useContext2.registerOption, unregisterOption2 = _useContext2.unregisterOption;
4351
4411
  var _useState3 = useState(false), _useState4 = _slicedToArray$5(_useState3, 2), showDeselect = _useState4[0], setShowDeselect = _useState4[1];
4352
4412
  var _useState5 = useState(true), _useState6 = _slicedToArray$5(_useState5, 2), isInitialHover = _useState6[0], setIsInitialHover = _useState6[1];
4413
+ React.useEffect(function() {
4414
+ registerOption2(id, disabled);
4415
+ return function() {
4416
+ return unregisterOption2(id);
4417
+ };
4418
+ }, [id, disabled, registerOption2, unregisterOption2]);
4353
4419
  var classNames = [];
4354
- if (isSelected2) {
4420
+ if (isSelected2(id)) {
4355
4421
  classNames.push("selected");
4356
4422
  }
4357
4423
  if (disabled) {
@@ -4361,7 +4427,7 @@ var OptionCard = function OptionCard2(_ref2) {
4361
4427
  classNames.push("show-deselect");
4362
4428
  }
4363
4429
  var handleMouseEnter = function handleMouseEnter2() {
4364
- if (isSelected2 && !isInitialHover) {
4430
+ if (isSelected2(id) && !isInitialHover) {
4365
4431
  setShowDeselect(true);
4366
4432
  }
4367
4433
  };
@@ -4374,7 +4440,7 @@ var OptionCard = function OptionCard2(_ref2) {
4374
4440
  var _props$onClick;
4375
4441
  setIsInitialHover(true);
4376
4442
  setShowDeselect(false);
4377
- toggleSelection2();
4443
+ toggleSelection2(id);
4378
4444
  (_props$onClick = props.onClick) === null || _props$onClick === void 0 || _props$onClick.call(props, e);
4379
4445
  }
4380
4446
  };
@@ -4383,7 +4449,7 @@ var OptionCard = function OptionCard2(_ref2) {
4383
4449
  e.preventDefault();
4384
4450
  setIsInitialHover(true);
4385
4451
  setShowDeselect(false);
4386
- toggleSelection2();
4452
+ toggleSelection2(id);
4387
4453
  }
4388
4454
  };
4389
4455
  return /* @__PURE__ */ React.createElement(Element, _extends$g({
@@ -4392,7 +4458,7 @@ var OptionCard = function OptionCard2(_ref2) {
4392
4458
  role: "button",
4393
4459
  tabIndex: disabled ? -1 : 0,
4394
4460
  "aria-disabled": disabled ? "true" : "false",
4395
- "aria-selected": isSelected2 ? "true" : "false",
4461
+ "aria-selected": isSelected2(id) ? "true" : "false",
4396
4462
  classNames,
4397
4463
  onClick: handleClick,
4398
4464
  onKeyDown: handleKeyDown,
@@ -1 +1 @@
1
- {"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../../src/components/CodeBlock/CodeBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAOxE,OAAO,iBAAiB,CAAC;AAGzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAY1D,MAAM,WAAW,oBAAoB;IACjC,MAAuB,CAAC,EAAG,MAAM,GAAG,MAAM,CAAC;IAC3C,QAAuB,CAAC,EAAG,MAAM,CAAC;IAClC,cAAuB,CAAC,EAAG,OAAO,CAAC;IACnC,eAAuB,CAAC,EAAG,OAAO,CAAC;IACnC,WAAuB,CAAC,EAAG,MAAM,CAAC;IAClC,sBAAuB,CAAC,EAAG,OAAO,CAAC;IACnC,eAAuB,CAAC,EAAG,OAAO,CAAC;IACnC,QAAuB,CAAC,EAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACxD;AAED,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAClD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,EAAE,MAAM,oBAAoB,CAAC,GACnG,oBAAoB,CAAC;AAGzB,eAAO,MAAM,SAAS,oKAyQpB,CAAC"}
1
+ {"version":3,"file":"CodeBlock.d.ts","sourceRoot":"","sources":["../../../src/components/CodeBlock/CodeBlock.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmD,MAAM,OAAO,CAAC;AAOxE,OAAO,iBAAiB,CAAC;AAGzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAY1D,MAAM,WAAW,oBAAoB;IACjC,MAAuB,CAAC,EAAG,MAAM,GAAG,MAAM,CAAC;IAC3C,QAAuB,CAAC,EAAG,MAAM,CAAC;IAClC,cAAuB,CAAC,EAAG,OAAO,CAAC;IACnC,eAAuB,CAAC,EAAG,OAAO,CAAC;IACnC,WAAuB,CAAC,EAAG,MAAM,CAAC;IAClC,sBAAuB,CAAC,EAAG,OAAO,CAAC;IACnC,eAAuB,CAAC,EAAG,OAAO,CAAC;IACnC,QAAuB,CAAC,EAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;CACxD;AAED,MAAM,MAAM,oBAAoB,GAAG,cAAc,CAAC;AAClD,MAAM,MAAM,cAAc,GAAG,IAAI,CAAC,kBAAkB,CAAC,oBAAoB,CAAC,EAAE,MAAM,oBAAoB,CAAC,GACnG,oBAAoB,CAAC;AAGzB,eAAO,MAAM,SAAS,oKAuQpB,CAAC"}
@@ -8,6 +8,7 @@ export interface OptionCardsProviderProps {
8
8
  showTickIcon?: boolean;
9
9
  tickPosition?: TickPosition;
10
10
  onSelectionChange?: (selectedIds: Set<string>) => void;
11
+ selectionLimit?: number;
11
12
  }
12
13
  export interface OptionCardProps extends CardProps {
13
14
  id: string;
@@ -20,5 +21,9 @@ export declare const useOptionCard: (id: string) => {
20
21
  toggleSelection: () => void;
21
22
  showTickIcon: boolean | undefined;
22
23
  };
24
+ export declare const useOptionCards: () => {
25
+ selectAllOptions: (() => void) | undefined;
26
+ clearAllOptions: (() => void) | undefined;
27
+ };
23
28
  export declare const OptionCard: React.FC<OptionCardProps>;
24
29
  //# sourceMappingURL=OptionCard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"OptionCard.d.ts","sourceRoot":"","sources":["../../../src/components/OptionCard/OptionCard.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAuC,SAAS,EAAe,MAAM,OAAO,CAAC;AAK3F,OAAO,EAAyB,SAAS,EAAE,MAAM,cAAc,CAAC;AAGhE,OAAO,mBAAmB,CAAC;AAG3B,MAAM,MAAM,YAAY,GAClB,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AAoB,SAAS,CAAC;IACtC,uBAAwB,CAAC,EAAG,OAAO,CAAC;IACpC,YAAwB,CAAC,EAAG,OAAO,CAAC;IACpC,YAAwB,CAAC,EAAG,YAAY,CAAC;IACzC,iBAAwB,CAAC,EAAG,CAAC,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,CAAC;IAC/D,cAAuB,CAAC,EAAG,MAAM,CAAC;CACrC;AAED,MAAM,WAAW,eAAgB,SAAQ,SAAS;IAC9C,EAAE,EAAW,MAAM,CAAC;IACpB,QAAQ,EAAK,SAAS,CAAC;IACvB,QAAS,CAAC,EAAG,OAAO,CAAC;CACxB;AAyBD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC,wBAAwB,CAgG/D,CAAC;AAEF,eAAO,MAAM,aAAa,OAAQ,MAAM;;;;CAOvC,CAAC;AAEF,eAAO,MAAM,cAAc;6BA7HI,IAAI;4BACJ,IAAI;CA+HlC,CAAC;AAEF,eAAO,MAAM,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAqFhD,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  "use client;";
3
- import { A, g, h, B, i, b, a, C, c, s, t, d, _, f, e, D, E, q, F, l, m, n, H, ac, ad, ae, af, ag, ah, k, I, o, L, y, M, z, G, N, K, J, W, X, O, P, Q, U, r, R, x, w, V, S, p, a1, $, a0, Z, a2, a3, j, a4, u, v, a5, a6, ai, T, a7, aa, a9, ab, Y, a8 } from "../Heading-CkXicuup.js";
3
+ import { A, g, h, B, i, b, a, C, c, s, t, d, _, f, e, D, E, q, F, l, m, n, H, ac, ad, ae, af, ag, ah, k, I, o, L, y, M, z, G, N, K, J, W, X, O, P, Q, U, r, R, x, w, V, S, p, a1, $, a0, Z, a2, a3, j, a4, u, v, a5, a6, ai, T, a7, aa, a9, ab, Y, a8 } from "../Heading-BIYw4xou.js";
4
4
  export {
5
5
  A as Accordion,
6
6
  g as Article,