chop-logic-components 4.2.0 → 4.4.0

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 (83) hide show
  1. package/dist/components/atoms/avatar/Avatar.css +1 -0
  2. package/dist/components/atoms/avatar/Avatar.d.ts +7 -0
  3. package/dist/components/atoms/avatar/Avatar2.js +44 -0
  4. package/dist/components/atoms/button/Button2.js +11 -11
  5. package/dist/components/atoms/button/icon-button/IconButton2.js +4 -4
  6. package/dist/components/atoms/button/inner-button/InnerButton2.js +4 -4
  7. package/dist/components/atoms/button/primary-button/PrimaryButton2.js +4 -4
  8. package/dist/components/atoms/button/secondary-button/SecondaryButton2.js +4 -4
  9. package/dist/components/atoms/editable-text/EditView.js +4 -4
  10. package/dist/components/atoms/editable-text/EditableText2.js +8 -8
  11. package/dist/components/atoms/icon/Icon2.js +10 -10
  12. package/dist/components/atoms/image/BasicImage.d.ts +2 -0
  13. package/dist/components/atoms/image/BasicImage.js +4 -9
  14. package/dist/components/atoms/image/Image.css +1 -1
  15. package/dist/components/atoms/image/Image2.js +16 -16
  16. package/dist/components/atoms/image/ResponsivePicture.d.ts +1 -0
  17. package/dist/components/atoms/image/ResponsivePicture.js +16 -9
  18. package/dist/components/atoms/index.d.ts +2 -0
  19. package/dist/components/atoms/input/Input2.js +5 -5
  20. package/dist/components/atoms/label/Label2.js +4 -4
  21. package/dist/components/atoms/link/Link2.js +4 -4
  22. package/dist/components/atoms/tag/Tag.css +1 -0
  23. package/dist/components/atoms/tag/Tag.d.ts +7 -0
  24. package/dist/components/atoms/tag/Tag2.js +15 -0
  25. package/dist/components/atoms/tooltip/Tooltip2.js +9 -8
  26. package/dist/components/contexts/form/FormContext.d.ts +1 -0
  27. package/dist/components/contexts/form/FormContext.js +1 -1
  28. package/dist/components/contexts/theme/ThemeProvider.js +8 -8
  29. package/dist/components/hocs/with-error-boundary/with-error-boundary.js +8 -8
  30. package/dist/components/hocs/with-figure-caption/Figure.css +1 -1
  31. package/dist/components/molecules/alert/Alert2.js +19 -19
  32. package/dist/components/molecules/checkbox/CheckboxStateful.js +6 -6
  33. package/dist/components/molecules/checkbox/CheckboxStateless.js +6 -6
  34. package/dist/components/molecules/multi-select/MultiSelect.Combobox.js +6 -6
  35. package/dist/components/molecules/multi-select/MultiSelect.js +7 -7
  36. package/dist/components/molecules/multi-select/Option.js +8 -8
  37. package/dist/components/molecules/numeric-input/NumericInput.controller.js +2 -1
  38. package/dist/components/molecules/numeric-input/NumericInputStateful.js +8 -8
  39. package/dist/components/molecules/numeric-input/NumericInputStateless.js +8 -8
  40. package/dist/components/molecules/search/Search2.js +16 -16
  41. package/dist/components/molecules/select/Select2.js +7 -7
  42. package/dist/components/molecules/select/combobox/Combobox2.js +6 -6
  43. package/dist/components/molecules/select/option/Option2.js +6 -6
  44. package/dist/components/molecules/text-input/TextInputStateless.js +8 -8
  45. package/dist/components/organisms/dialog/Dialog2.js +14 -14
  46. package/dist/components/organisms/form/Form.controller.d.ts +17 -9
  47. package/dist/components/organisms/form/Form.controller.js +41 -21
  48. package/dist/components/organisms/form/Form.css +1 -1
  49. package/dist/components/organisms/form/Form2.js +38 -29
  50. package/dist/components/organisms/gallery/Gallery.helpers.js +2 -2
  51. package/dist/components/organisms/gallery/Gallery2.js +8 -8
  52. package/dist/components/organisms/gallery/full-screen-viewer/FullscreenViewer2.js +7 -7
  53. package/dist/components/organisms/gallery/viewer-navigation/ViewerNavigation2.js +8 -8
  54. package/dist/components/organisms/grid/Grid.controller.js +4 -2
  55. package/dist/components/organisms/grid/checkbox/GridCheckbox2.js +4 -4
  56. package/dist/components/organisms/index.d.ts +1 -0
  57. package/dist/components/organisms/menu/Menu2.js +5 -5
  58. package/dist/components/organisms/menu/list-item/MenuListItem2.js +8 -8
  59. package/dist/components/organisms/menu/sub-menu/SubMenu2.js +17 -17
  60. package/dist/components/organisms/preview-card/PreviewCard.css +1 -0
  61. package/dist/components/organisms/preview-card/PreviewCard.d.ts +4 -0
  62. package/dist/components/organisms/preview-card/PreviewCard2.js +57 -0
  63. package/dist/components/organisms/tabs/Tabs2.js +11 -11
  64. package/dist/components/organisms/tabs/button/TabButton2.js +23 -23
  65. package/dist/components/organisms/tabs/edit-input/TabEditInput2.js +9 -9
  66. package/dist/components/organisms/tabs/list/TabList2.js +12 -12
  67. package/dist/enums/index.d.ts +1 -0
  68. package/dist/enums/index.js +1 -0
  69. package/dist/enums/link-target.d.ts +6 -0
  70. package/dist/enums/link-target.js +6 -0
  71. package/dist/hooks/index.d.ts +1 -0
  72. package/dist/hooks/index.js +1 -0
  73. package/dist/hooks/use-click-outside/use-click-outside.js +1 -1
  74. package/dist/hooks/use-form-pending/index.js +2 -0
  75. package/dist/hooks/use-form-pending/use-form-pending.d.ts +1 -0
  76. package/dist/hooks/use-form-pending/use-form-pending.js +9 -0
  77. package/dist/hooks/use-remaining-timer/use-remaining-timer.js +3 -1
  78. package/dist/index.es.js +62 -57
  79. package/dist/types/form.d.ts +6 -3
  80. package/dist/types/image.d.ts +16 -3
  81. package/dist/types/index.d.ts +2 -1
  82. package/dist/types/preview-card.d.ts +38 -0
  83. package/package.json +18 -18
@@ -0,0 +1,57 @@
1
+ import { LinkTarget as e } from "../../../enums/link-target.js";
2
+ import { getClassName as t } from "../../../utils/get-class-name.js";
3
+ import n from "../../atoms/avatar/Avatar2.js";
4
+ import r from "../../atoms/header/Header2.js";
5
+ import i from "../../atoms/image/Image2.js";
6
+ import a from "../../atoms/tag/Tag2.js";
7
+ import './PreviewCard.css';/* empty css */
8
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
9
+ //#region src/components/organisms/preview-card/PreviewCard.tsx
10
+ var c = ({ link: c, linkTarget: l = e.Self, image: u, title: d, summary: f, authors: p = [], tags: m = [], className: h, ...g }) => {
11
+ let _ = t(["cl-preview-card", h]), v = l === e.Blank, y = d || "Preview card", b = `View article: ${d}`;
12
+ return /* @__PURE__ */ s("article", {
13
+ className: _,
14
+ "aria-label": y,
15
+ ...g,
16
+ children: [
17
+ /* @__PURE__ */ o("a", {
18
+ href: c,
19
+ target: l,
20
+ rel: v ? "noopener noreferrer" : void 0,
21
+ "aria-label": b,
22
+ className: "cl-preview-card__image-link",
23
+ children: /* @__PURE__ */ o(i, {
24
+ ...u,
25
+ className: "cl-preview-card__image"
26
+ })
27
+ }),
28
+ /* @__PURE__ */ o(r, {
29
+ as: "h6",
30
+ className: "cl-preview-card__title",
31
+ children: d
32
+ }),
33
+ f && /* @__PURE__ */ o("p", {
34
+ className: "cl-preview-card__summary",
35
+ children: f
36
+ }),
37
+ p.length > 0 && /* @__PURE__ */ o("ul", {
38
+ className: "cl-preview-card__authors",
39
+ "aria-label": "Authors",
40
+ children: p.map((e) => /* @__PURE__ */ s("li", {
41
+ className: "cl-preview-card__author-item",
42
+ children: [/* @__PURE__ */ o(n, { ...e }), /* @__PURE__ */ o("span", { children: e.name })]
43
+ }, e.id))
44
+ }),
45
+ m.length > 0 && /* @__PURE__ */ o("ul", {
46
+ className: "cl-preview-card__tags",
47
+ "aria-label": "Tags",
48
+ children: m.map((e) => /* @__PURE__ */ o("li", {
49
+ className: "cl-preview-card__tag-item",
50
+ children: /* @__PURE__ */ o(a, { ...e })
51
+ }, e.id))
52
+ })
53
+ ]
54
+ });
55
+ };
56
+ //#endregion
57
+ export { c as default };
@@ -1,16 +1,16 @@
1
- import { getClassName as e } from "../../../utils/get-class-name.js";
2
- import { OrientationMode as t } from "../../../enums/orientation-mode.js";
1
+ import { OrientationMode as e } from "../../../enums/orientation-mode.js";
2
+ import { getClassName as t } from "../../../utils/get-class-name.js";
3
3
  import { TabContent as n } from "./content/TabContent2.js";
4
4
  import { TabList as r } from "./list/TabList2.js";
5
5
  import './Tabs.css';/* empty css */
6
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
7
- import { useState as o } from "react";
6
+ import { useState as i } from "react";
7
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
8
8
  //#region src/components/organisms/tabs/Tabs.tsx
9
- var s = ({ tabs: s, defaultTabId: c, className: l, mode: u = t.Horizontal, stretched: d = !1, editable: f = !1, extendable: p = !1, extendedTabLabel: m = "New Tab", extendedTabContent: h, onTabTitleChange: g, onTabAdd: _, onTabSelect: v, onTabDelete: y, ...b }) => {
10
- let [x, S] = o(s), C = s.length, [w, T] = o(C + 1), E = x.map((e) => e.id), D = E.map((e) => `tabpanel_${e}`), [O, k] = o(c && E.includes(c) ? c : E[0]), A = e([
9
+ var s = ({ tabs: s, defaultTabId: c, className: l, mode: u = e.Horizontal, stretched: d = !1, editable: f = !1, extendable: p = !1, extendedTabLabel: m = "New Tab", extendedTabContent: h, onTabTitleChange: g, onTabAdd: _, onTabSelect: v, onTabDelete: y, ...b }) => {
10
+ let [x, S] = i(s), C = s.length, [w, T] = i(C + 1), E = x.map((e) => e.id), D = E.map((e) => `tabpanel_${e}`), [O, k] = i(c && E.includes(c) ? c : E[0]), A = t([
11
11
  "cl-tabs",
12
12
  l,
13
- { "cl-tabs_vertical": u === t.Vertical }
13
+ { "cl-tabs_vertical": u === e.Vertical }
14
14
  ]), j = (e) => {
15
15
  k(e), v?.(e);
16
16
  }, M = (e, t) => {
@@ -22,7 +22,7 @@ var s = ({ tabs: s, defaultTabId: c, className: l, mode: u = t.Horizontal, stret
22
22
  let e = `added-tab-${w}`, t = {
23
23
  id: e,
24
24
  title: m || `Tab ${w}`,
25
- content: h || /* @__PURE__ */ i("div", {})
25
+ content: h || /* @__PURE__ */ a("div", {})
26
26
  };
27
27
  S((e) => [...e, t]), T((e) => e + 1), _?.(), j(e);
28
28
  }, P = (e) => {
@@ -32,10 +32,10 @@ var s = ({ tabs: s, defaultTabId: c, className: l, mode: u = t.Horizontal, stret
32
32
  }
33
33
  y?.(e);
34
34
  };
35
- return /* @__PURE__ */ a("div", {
35
+ return /* @__PURE__ */ o("div", {
36
36
  ...b,
37
37
  className: A,
38
- children: [/* @__PURE__ */ i(r, {
38
+ children: [/* @__PURE__ */ a(r, {
39
39
  tabs: x,
40
40
  selectedTabId: O,
41
41
  tabPanelIds: D,
@@ -48,7 +48,7 @@ var s = ({ tabs: s, defaultTabId: c, className: l, mode: u = t.Horizontal, stret
48
48
  extendable: p,
49
49
  onTabAdd: N,
50
50
  onTabDelete: P
51
- }), /* @__PURE__ */ i(n, {
51
+ }), /* @__PURE__ */ a(n, {
52
52
  tabs: x,
53
53
  selectedTabId: O,
54
54
  extendedTabContent: h,
@@ -1,26 +1,26 @@
1
- import { getClassName as e } from "../../../../utils/get-class-name.js";
2
- import { ButtonView as t } from "../../../../enums/button-view.js";
3
- import { ElementSize as n } from "../../../../enums/element-size.js";
4
- import { IconName as r } from "../../../../enums/icon-name.js";
5
- import { OrientationMode as i } from "../../../../enums/orientation-mode.js";
1
+ import { ButtonView as e } from "../../../../enums/button-view.js";
2
+ import { ElementSize as t } from "../../../../enums/element-size.js";
3
+ import { IconName as n } from "../../../../enums/icon-name.js";
4
+ import { OrientationMode as r } from "../../../../enums/orientation-mode.js";
5
+ import { getClassName as i } from "../../../../utils/get-class-name.js";
6
6
  import a from "../../../atoms/button/Button2.js";
7
7
  import { TabEditInput as o } from "../edit-input/TabEditInput2.js";
8
8
  import './TabButton.css';/* empty css */
9
- import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
10
- import { useEffect as u, useId as d, useRef as f, useState as p } from "react";
9
+ import { useEffect as s, useId as c, useRef as l, useState as u } from "react";
10
+ import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
11
11
  //#region src/components/organisms/tabs/button/TabButton.tsx
12
12
  var m = ({ title: m, onTabSelect: h, onTabTitleChange: g, onTabDelete: _, tabId: v, isSelected: y, isDisabled: b = !1, stretched: x = !1, editable: S = !1, extendable: C = !1, tabPanelId: w, mode: T }) => {
13
- let [E, D] = p(!1), [O, k] = p(m), A = f(null), j = d(), M = S && !b && y, N = C && !b && !!_ && y, P = M || N, F = e(["cl-tab__wrapper", {
13
+ let [E, D] = u(!1), [O, k] = u(m), A = l(null), j = c(), M = S && !b && y, N = C && !b && !!_ && y, P = M || N, F = i(["cl-tab__wrapper", {
14
14
  "cl-tab__wrapper_disabled": b,
15
- "cl-tab__wrapper_vertical": T === i.Vertical,
15
+ "cl-tab__wrapper_vertical": T === r.Vertical,
16
16
  "cl-tab__wrapper_selected": y,
17
17
  "cl-tab__wrapper_stretched": x,
18
18
  "cl-tab__wrapper_editable": S,
19
19
  "cl-tab__wrapper_inactive": !y
20
20
  }]);
21
- u(() => {
21
+ s(() => {
22
22
  E && A.current && (A.current.focus(), A.current.select());
23
- }, [E]), u(() => {
23
+ }, [E]), s(() => {
24
24
  k(m);
25
25
  }, [m]);
26
26
  let I = () => {
@@ -38,9 +38,9 @@ var m = ({ title: m, onTabSelect: h, onTabTitleChange: g, onTabDelete: _, tabId:
38
38
  }, H = () => {
39
39
  k(m), D(!1);
40
40
  };
41
- return /* @__PURE__ */ c("span", {
41
+ return /* @__PURE__ */ f("span", {
42
42
  className: F,
43
- children: E ? /* @__PURE__ */ c(o, {
43
+ children: E ? /* @__PURE__ */ f(o, {
44
44
  tabId: v,
45
45
  editValue: O,
46
46
  isEditMode: E,
@@ -50,7 +50,7 @@ var m = ({ title: m, onTabSelect: h, onTabTitleChange: g, onTabDelete: _, tabId:
50
50
  onSave: V,
51
51
  onCancel: H,
52
52
  cancelButtonId: j
53
- }) : /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c("button", {
53
+ }) : /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f("button", {
54
54
  role: "tab",
55
55
  id: v,
56
56
  onClick: L,
@@ -59,22 +59,22 @@ var m = ({ title: m, onTabSelect: h, onTabTitleChange: g, onTabDelete: _, tabId:
59
59
  className: "cl-tab",
60
60
  disabled: b,
61
61
  children: O
62
- }), P && /* @__PURE__ */ l("span", {
62
+ }), P && /* @__PURE__ */ p("span", {
63
63
  className: "cl-tab__buttons",
64
- children: [M && /* @__PURE__ */ c(a, {
65
- view: t.Icon,
66
- icon: r.Edit3,
64
+ children: [M && /* @__PURE__ */ f(a, {
65
+ view: e.Icon,
66
+ icon: n.Edit3,
67
67
  onClick: I,
68
68
  label: "Edit tab",
69
69
  tooltip: "Edit tab",
70
- iconSize: n.Small
71
- }), N && /* @__PURE__ */ c(a, {
72
- view: t.Icon,
73
- icon: r.Trash2,
70
+ iconSize: t.Small
71
+ }), N && /* @__PURE__ */ f(a, {
72
+ view: e.Icon,
73
+ icon: n.Trash2,
74
74
  onClick: () => _?.(v),
75
75
  label: "Delete tab",
76
76
  tooltip: "Delete tab",
77
- iconSize: n.Small
77
+ iconSize: t.Small
78
78
  })]
79
79
  })] })
80
80
  });
@@ -3,16 +3,16 @@ import { ElementSize as t } from "../../../../enums/element-size.js";
3
3
  import { IconName as n } from "../../../../enums/icon-name.js";
4
4
  import r from "../../../atoms/button/Button2.js";
5
5
  import './TabEditInput.css';/* empty css */
6
- import { jsx as i, jsxs as a } from "react/jsx-runtime";
7
- import { useEffect as o, useRef as s } from "react";
6
+ import { useEffect as i, useRef as a } from "react";
7
+ import { jsx as o, jsxs as s } from "react/jsx-runtime";
8
8
  //#region src/components/organisms/tabs/edit-input/TabEditInput.tsx
9
9
  var c = ({ tabId: c, isEditMode: l, editValue: u, onInputChange: d, onInputBlur: f, onInputKeyDown: p, onSave: m, onCancel: h, cancelButtonId: g }) => {
10
- let _ = s(null);
11
- return o(() => {
10
+ let _ = a(null);
11
+ return i(() => {
12
12
  l && _.current && (_.current.focus(), _.current.select());
13
- }, [l]), /* @__PURE__ */ a("div", {
13
+ }, [l]), /* @__PURE__ */ s("div", {
14
14
  className: "cl-tab-edit-container",
15
- children: [/* @__PURE__ */ i("input", {
15
+ children: [/* @__PURE__ */ o("input", {
16
16
  ref: _,
17
17
  id: `${c}-input`,
18
18
  type: "text",
@@ -22,15 +22,15 @@ var c = ({ tabId: c, isEditMode: l, editValue: u, onInputChange: d, onInputBlur:
22
22
  onKeyDown: p,
23
23
  className: "cl-tab-edit-container__input",
24
24
  maxLength: 50
25
- }), /* @__PURE__ */ a("span", {
25
+ }), /* @__PURE__ */ s("span", {
26
26
  className: "cl-tab-edit-container__buttons",
27
- children: [/* @__PURE__ */ i(r, {
27
+ children: [/* @__PURE__ */ o(r, {
28
28
  view: e.Icon,
29
29
  icon: n.Check,
30
30
  onClick: m,
31
31
  label: "Save tab title",
32
32
  iconSize: t.Small
33
- }), /* @__PURE__ */ i(r, {
33
+ }), /* @__PURE__ */ o(r, {
34
34
  view: e.Icon,
35
35
  icon: n.X,
36
36
  onClick: h,
@@ -1,24 +1,24 @@
1
- import { getClassName as e } from "../../../../utils/get-class-name.js";
2
- import { moveFocusOnElementById as t } from "../../../../utils/move-focus-on-element-by-id.js";
3
- import { ButtonView as n } from "../../../../enums/button-view.js";
4
- import { IconName as r } from "../../../../enums/icon-name.js";
5
- import { OrientationMode as i } from "../../../../enums/orientation-mode.js";
1
+ import { ButtonView as e } from "../../../../enums/button-view.js";
2
+ import { IconName as t } from "../../../../enums/icon-name.js";
3
+ import { OrientationMode as n } from "../../../../enums/orientation-mode.js";
4
+ import { getClassName as r } from "../../../../utils/get-class-name.js";
5
+ import { moveFocusOnElementById as i } from "../../../../utils/move-focus-on-element-by-id.js";
6
6
  import a from "../../../atoms/button/Button2.js";
7
7
  import { TabButton as o } from "../button/TabButton2.js";
8
8
  import './TabList.css';/* empty css */
9
9
  import { jsx as s, jsxs as c } from "react/jsx-runtime";
10
10
  //#region src/components/organisms/tabs/list/TabList.tsx
11
11
  var l = ({ tabs: l, onTabSelect: u, onTabTitleChange: d, selectedTabId: f, tabPanelIds: p, mode: m, tabIds: h, stretched: g, editable: _ = !1, extendable: v = !1, onTabAdd: y, onTabDelete: b }) => {
12
- let x = e(["cl-tab-list", { "cl-tab-list_vertical": m === i.Vertical }]), S = (e) => {
13
- let n = h.indexOf(f);
12
+ let x = r(["cl-tab-list", { "cl-tab-list_vertical": m === n.Vertical }]), S = (e) => {
13
+ let t = h.indexOf(f);
14
14
  if (![
15
15
  "ArrowLeft",
16
16
  "ArrowUp",
17
17
  "ArrowRight",
18
18
  "ArrowDown"
19
- ].includes(e.key) || (e.preventDefault(), e.key === "ArrowUp" && m === i.Horizontal || e.key === "ArrowLeft" && m === i.Vertical)) return;
20
- let r = h[e.key === "ArrowLeft" || e.key === "ArrowUp" ? C(n, h.length) : w(n, h.length)];
21
- r && (t(r), u(r));
19
+ ].includes(e.key) || (e.preventDefault(), e.key === "ArrowUp" && m === n.Horizontal || e.key === "ArrowLeft" && m === n.Vertical)) return;
20
+ let r = h[e.key === "ArrowLeft" || e.key === "ArrowUp" ? C(t, h.length) : w(t, h.length)];
21
+ r && (i(r), u(r));
22
22
  }, C = (e, t) => e - 1 >= 0 ? e - 1 : t - 1, w = (e, t) => e === t - 1 ? 0 : e + 1;
23
23
  return /* @__PURE__ */ c("div", {
24
24
  role: "tablist",
@@ -41,8 +41,8 @@ var l = ({ tabs: l, onTabSelect: u, onTabTitleChange: d, selectedTabId: f, tabPa
41
41
  }, e)), v && /* @__PURE__ */ s(a, {
42
42
  label: "Add Tab",
43
43
  tooltip: "Add Tab",
44
- view: n.Icon,
45
- icon: r.PlusCircle,
44
+ view: e.Icon,
45
+ icon: t.PlusCircle,
46
46
  onClick: y
47
47
  })]
48
48
  });
@@ -2,6 +2,7 @@ export { AlertMode } from './alert-mode';
2
2
  export { ButtonView } from './button-view';
3
3
  export { ElementSize } from './element-size';
4
4
  export { IconName } from './icon-name';
5
+ export { LinkTarget } from './link-target';
5
6
  export { LoaderView } from './loader-view';
6
7
  export { OrientationMode } from './orientation-mode';
7
8
  export { SemanticColor } from './semantic-color';
@@ -2,6 +2,7 @@ export * from './alert-mode.js';
2
2
  export * from './button-view.js';
3
3
  export * from './element-size.js';
4
4
  export * from './icon-name.js';
5
+ export * from './link-target.js';
5
6
  export * from './loader-view.js';
6
7
  export * from './orientation-mode.js';
7
8
  export * from './semantic-color.js';
@@ -0,0 +1,6 @@
1
+ export declare enum LinkTarget {
2
+ Self = "_self",
3
+ Blank = "_blank",
4
+ Parent = "_parent",
5
+ Top = "_top"
6
+ }
@@ -0,0 +1,6 @@
1
+ //#region src/enums/link-target.ts
2
+ var e = /* @__PURE__ */ function(e) {
3
+ return e.Self = "_self", e.Blank = "_blank", e.Parent = "_parent", e.Top = "_top", e;
4
+ }({});
5
+ //#endregion
6
+ export { e as LinkTarget };
@@ -3,6 +3,7 @@ export { useClickOutside } from './use-click-outside/use-click-outside';
3
3
  export { useContainerDimensions } from './use-container-dimensions/use-container-dimensions';
4
4
  export { useDebounce } from './use-debounce/use-debounce';
5
5
  export { useElementIds } from './use-element-ids/use-element-ids';
6
+ export { useFormPending } from './use-form-pending/use-form-pending';
6
7
  export { useIsHovered } from './use-is-hovered/use-is-hovered';
7
8
  export { useIsMounted } from './use-is-mounted/use-is-mounted';
8
9
  export { useIsOverflow } from './use-is-overflow/use-is-overflow';
@@ -3,6 +3,7 @@ export * from './use-click-outside/index.js';
3
3
  export * from './use-container-dimensions/index.js';
4
4
  export * from './use-debounce/index.js';
5
5
  export * from './use-element-ids/index.js';
6
+ export * from './use-form-pending/index.js';
6
7
  export * from './use-is-hovered/index.js';
7
8
  export * from './use-is-mounted/index.js';
8
9
  export * from './use-is-overflow/index.js';
@@ -3,7 +3,7 @@ import { useEffect as e } from "react";
3
3
  var t = ({ ref: t, onClickOutsideHandler: n, dependentRef: r }) => {
4
4
  e(() => {
5
5
  let e = (e) => {
6
- let i = t?.current && !t.current.contains(e.target), a = r?.current ? !r?.current?.contains(e.target) : !0;
6
+ let i = t?.current && !t.current.contains(e.target), a = !r?.current || !r?.current?.contains(e.target);
7
7
  i && a && n();
8
8
  };
9
9
  return document.addEventListener("mousedown", e), () => {
@@ -0,0 +1,2 @@
1
+ export * from './use-form-pending.js';
2
+ export { default } from './use-form-pending.js';
@@ -0,0 +1 @@
1
+ export declare const useFormPending: () => boolean;
@@ -0,0 +1,9 @@
1
+ import { FormContext as e } from "../../components/contexts/form/FormContext.js";
2
+ import { useContext as t } from "react";
3
+ //#region src/hooks/use-form-pending/use-form-pending.ts
4
+ var n = () => {
5
+ let { isPending: n } = t(e);
6
+ return n ?? !1;
7
+ };
8
+ //#endregion
9
+ export { n as useFormPending };
@@ -15,7 +15,9 @@ function r({ isOpened: r, isHovered: i, onClose: a, autoClose: o = !0, autoClose
15
15
  u.current = Date.now() - d.current;
16
16
  let e = () => {
17
17
  let t = Date.now() - u.current;
18
- if (d.current = t, l(Math.max(0, 100 - t / s * 100)), t >= s) {
18
+ d.current = t;
19
+ let n = Math.max(0, 100 - t / s * 100);
20
+ if (l(n), t >= s) {
19
21
  a();
20
22
  return;
21
23
  }
package/dist/index.es.js CHANGED
@@ -1,57 +1,62 @@
1
- import { withTooltip as e } from "./components/hocs/with-tooltip/with-tooltip.js";
2
- import { AlertMode as t } from "./enums/alert-mode.js";
3
- import { ButtonView as n } from "./enums/button-view.js";
4
- import { ElementSize as r } from "./enums/element-size.js";
5
- import { IconName as i } from "./enums/icon-name.js";
6
- import { LoaderView as a } from "./enums/loader-view.js";
7
- import { OrientationMode as o } from "./enums/orientation-mode.js";
8
- import { SemanticColor as s } from "./enums/semantic-color.js";
9
- import { TooltipContainer as c } from "./enums/tooltip-container.js";
10
- import l from "./components/atoms/button/Button2.js";
11
- import u from "./components/atoms/editable-text/EditableText2.js";
12
- import d from "./components/atoms/error-message/ErrorMessage2.js";
13
- import f from "./components/atoms/header/Header2.js";
14
- import p from "./components/atoms/icon/Icon2.js";
15
- import { withErrorBoundary as m } from "./components/hocs/with-error-boundary/with-error-boundary.js";
16
- import { withFigureCaption as h } from "./components/hocs/with-figure-caption/with-figure-caption.js";
17
- import g from "./components/atoms/image/Image2.js";
18
- import _ from "./components/atoms/input/Input2.js";
19
- import v from "./components/atoms/label/Label2.js";
20
- import y from "./components/atoms/link/Link2.js";
21
- import b from "./components/atoms/portal/Portal.js";
22
- import { useAutoClose as x } from "./hooks/use-auto-close/use-auto-close.js";
23
- import { useClickOutside as S } from "./hooks/use-click-outside/use-click-outside.js";
24
- import { useContainerDimensions as C } from "./hooks/use-container-dimensions/use-container-dimensions.js";
25
- import { useDebounce as w } from "./hooks/use-debounce/use-debounce.js";
26
- import { useElementIds as T } from "./hooks/use-element-ids/use-element-ids.js";
27
- import { useIsHovered as E } from "./hooks/use-is-hovered/use-is-hovered.js";
28
- import { useIsMounted as D } from "./hooks/use-is-mounted/use-is-mounted.js";
29
- import { useIsOverflow as O } from "./hooks/use-is-overflow/use-is-overflow.js";
30
- import { useKeyPress as k } from "./hooks/use-key-press/use-key-press.js";
31
- import { useModalFocusTrap as A } from "./hooks/use-modal-focus-trap/use-modal-focus-trap.js";
32
- import { useRemainingTimer as j } from "./hooks/use-remaining-timer/use-remaining-timer.js";
33
- import { FormContext as M } from "./components/contexts/form/FormContext.js";
34
- import { CL_DARK_THEME_CLASS as N, CL_LIGHT_THEME_CLASS as P, ThemeContext as F } from "./components/contexts/theme/ThemeContext.js";
35
- import { ThemeProvider as I } from "./components/contexts/theme/ThemeProvider.js";
36
- import { useResetFormInput as L } from "./hooks/use-reset-form-input/use-reset-form-input.js";
37
- import { useTheme as R } from "./hooks/use-theme/use-theme.js";
38
- import { useTooltipPosition as z } from "./hooks/use-tooltip-position/use-tooltip-position.js";
39
- import { useWindowDimensions as B } from "./hooks/use-window-dimensions/use-window-dimensions.js";
40
- import V from "./components/atoms/tooltip/Tooltip2.js";
41
- import H from "./components/molecules/accordion/Accordion2.js";
42
- import U from "./components/molecules/alert/Alert2.js";
43
- import W from "./components/molecules/breadcrumbs/Breadcrumbs2.js";
44
- import G from "./components/molecules/checkbox/Checkbox2.js";
45
- import K from "./components/molecules/multi-select/MultiSelect.js";
46
- import q from "./components/molecules/numeric-input/NumericInput2.js";
47
- import J from "./components/molecules/search/Search2.js";
48
- import Y from "./components/molecules/select/Select2.js";
49
- import X from "./components/molecules/switch/Switch2.js";
50
- import Z from "./components/molecules/text-input/TextInput2.js";
51
- import Q from "./components/organisms/dialog/Dialog2.js";
52
- import $ from "./components/organisms/form/Form2.js";
53
- import ee from "./components/organisms/gallery/Gallery2.js";
54
- import te from "./components/organisms/grid/Grid2.js";
55
- import ne from "./components/organisms/menu/Menu2.js";
56
- import re from "./components/organisms/tabs/Tabs2.js";
57
- export { H as Accordion, U as Alert, t as AlertMode, W as Breadcrumbs, l as Button, n as ButtonView, N as CL_DARK_THEME_CLASS, P as CL_LIGHT_THEME_CLASS, G as Checkbox, Q as Dialog, u as EditableText, r as ElementSize, d as ErrorMessage, $ as Form, M as FormContext, ee as Gallery, te as Grid, f as Header, p as Icon, i as IconName, g as Image, _ as Input, v as Label, y as Link, a as LoaderView, ne as Menu, K as MultiSelect, q as NumericInput, o as OrientationMode, b as Portal, J as Search, Y as Select, s as SemanticColor, X as Switch, re as Tabs, Z as TextInput, F as ThemeContext, I as ThemeProvider, V as Tooltip, c as TooltipContainer, x as useAutoClose, S as useClickOutside, C as useContainerDimensions, w as useDebounce, T as useElementIds, E as useIsHovered, D as useIsMounted, O as useIsOverflow, k as useKeyPress, A as useModalFocusTrap, j as useRemainingTimer, L as useResetFormInput, R as useTheme, z as useTooltipPosition, B as useWindowDimensions, m as withErrorBoundary, h as withFigureCaption, e as withTooltip };
1
+ import { withErrorBoundary as e } from "./components/hocs/with-error-boundary/with-error-boundary.js";
2
+ import { withFigureCaption as t } from "./components/hocs/with-figure-caption/with-figure-caption.js";
3
+ import { withTooltip as n } from "./components/hocs/with-tooltip/with-tooltip.js";
4
+ import { AlertMode as r } from "./enums/alert-mode.js";
5
+ import { ButtonView as i } from "./enums/button-view.js";
6
+ import { ElementSize as a } from "./enums/element-size.js";
7
+ import { IconName as o } from "./enums/icon-name.js";
8
+ import { LinkTarget as s } from "./enums/link-target.js";
9
+ import { LoaderView as c } from "./enums/loader-view.js";
10
+ import { OrientationMode as l } from "./enums/orientation-mode.js";
11
+ import { SemanticColor as u } from "./enums/semantic-color.js";
12
+ import { TooltipContainer as d } from "./enums/tooltip-container.js";
13
+ import f from "./components/atoms/avatar/Avatar2.js";
14
+ import p from "./components/atoms/button/Button2.js";
15
+ import m from "./components/atoms/editable-text/EditableText2.js";
16
+ import h from "./components/atoms/error-message/ErrorMessage2.js";
17
+ import g from "./components/atoms/header/Header2.js";
18
+ import _ from "./components/atoms/icon/Icon2.js";
19
+ import v from "./components/atoms/image/Image2.js";
20
+ import y from "./components/atoms/input/Input2.js";
21
+ import b from "./components/atoms/label/Label2.js";
22
+ import x from "./components/atoms/link/Link2.js";
23
+ import S from "./components/atoms/portal/Portal.js";
24
+ import C from "./components/atoms/tag/Tag2.js";
25
+ import { useAutoClose as w } from "./hooks/use-auto-close/use-auto-close.js";
26
+ import { useClickOutside as T } from "./hooks/use-click-outside/use-click-outside.js";
27
+ import { useContainerDimensions as E } from "./hooks/use-container-dimensions/use-container-dimensions.js";
28
+ import { useDebounce as D } from "./hooks/use-debounce/use-debounce.js";
29
+ import { useElementIds as O } from "./hooks/use-element-ids/use-element-ids.js";
30
+ import { FormContext as k } from "./components/contexts/form/FormContext.js";
31
+ import { CL_DARK_THEME_CLASS as A, CL_LIGHT_THEME_CLASS as j, ThemeContext as M } from "./components/contexts/theme/ThemeContext.js";
32
+ import { ThemeProvider as N } from "./components/contexts/theme/ThemeProvider.js";
33
+ import { useFormPending as P } from "./hooks/use-form-pending/use-form-pending.js";
34
+ import { useIsHovered as F } from "./hooks/use-is-hovered/use-is-hovered.js";
35
+ import { useIsMounted as I } from "./hooks/use-is-mounted/use-is-mounted.js";
36
+ import { useIsOverflow as L } from "./hooks/use-is-overflow/use-is-overflow.js";
37
+ import { useKeyPress as R } from "./hooks/use-key-press/use-key-press.js";
38
+ import { useModalFocusTrap as z } from "./hooks/use-modal-focus-trap/use-modal-focus-trap.js";
39
+ import { useRemainingTimer as B } from "./hooks/use-remaining-timer/use-remaining-timer.js";
40
+ import { useResetFormInput as V } from "./hooks/use-reset-form-input/use-reset-form-input.js";
41
+ import { useTheme as H } from "./hooks/use-theme/use-theme.js";
42
+ import { useTooltipPosition as U } from "./hooks/use-tooltip-position/use-tooltip-position.js";
43
+ import { useWindowDimensions as W } from "./hooks/use-window-dimensions/use-window-dimensions.js";
44
+ import G from "./components/atoms/tooltip/Tooltip2.js";
45
+ import K from "./components/molecules/accordion/Accordion2.js";
46
+ import q from "./components/molecules/alert/Alert2.js";
47
+ import J from "./components/molecules/breadcrumbs/Breadcrumbs2.js";
48
+ import Y from "./components/molecules/checkbox/Checkbox2.js";
49
+ import X from "./components/molecules/multi-select/MultiSelect.js";
50
+ import Z from "./components/molecules/numeric-input/NumericInput2.js";
51
+ import Q from "./components/molecules/search/Search2.js";
52
+ import $ from "./components/molecules/select/Select2.js";
53
+ import ee from "./components/molecules/switch/Switch2.js";
54
+ import te from "./components/molecules/text-input/TextInput2.js";
55
+ import ne from "./components/organisms/dialog/Dialog2.js";
56
+ import re from "./components/organisms/form/Form2.js";
57
+ import ie from "./components/organisms/gallery/Gallery2.js";
58
+ import ae from "./components/organisms/grid/Grid2.js";
59
+ import oe from "./components/organisms/menu/Menu2.js";
60
+ import se from "./components/organisms/preview-card/PreviewCard2.js";
61
+ import ce from "./components/organisms/tabs/Tabs2.js";
62
+ export { K as Accordion, q as Alert, r as AlertMode, f as Avatar, J as Breadcrumbs, p as Button, i as ButtonView, A as CL_DARK_THEME_CLASS, j as CL_LIGHT_THEME_CLASS, Y as Checkbox, ne as Dialog, m as EditableText, a as ElementSize, h as ErrorMessage, re as Form, k as FormContext, ie as Gallery, ae as Grid, g as Header, _ as Icon, o as IconName, v as Image, y as Input, b as Label, x as Link, s as LinkTarget, c as LoaderView, oe as Menu, X as MultiSelect, Z as NumericInput, l as OrientationMode, S as Portal, se as PreviewCard, Q as Search, $ as Select, u as SemanticColor, ee as Switch, ce as Tabs, C as Tag, te as TextInput, M as ThemeContext, N as ThemeProvider, G as Tooltip, d as TooltipContainer, w as useAutoClose, T as useClickOutside, E as useContainerDimensions, D as useDebounce, O as useElementIds, P as useFormPending, F as useIsHovered, I as useIsMounted, L as useIsOverflow, R as useKeyPress, z as useModalFocusTrap, B as useRemainingTimer, V as useResetFormInput, H as useTheme, U as useTooltipPosition, W as useWindowDimensions, e as withErrorBoundary, t as withFigureCaption, n as withTooltip };
@@ -9,10 +9,13 @@ export interface FormInputParams {
9
9
  value: unknown;
10
10
  valid?: boolean;
11
11
  }
12
- export interface FormProps extends PropsWithChildren, ChopLogicComponentProps {
12
+ export interface FormProps<TActionState = void> extends PropsWithChildren, ChopLogicComponentProps {
13
13
  initialValues?: FormValues;
14
14
  hasReset?: boolean;
15
- onClickSubmit?: (data: FormValues) => void;
15
+ resetOnSuccess?: boolean;
16
+ action?: (prevState: TActionState, formData: FormData) => TActionState | Promise<TActionState>;
17
+ actionInitialState?: TActionState;
18
+ onActionComplete?: (state: TActionState) => void;
19
+ onSubmit?: (data: FormValues) => void | Promise<void>;
16
20
  onReset?: FormEventHandler<HTMLFormElement>;
17
- onSubmit?: FormEventHandler<HTMLFormElement>;
18
21
  }
@@ -1,9 +1,22 @@
1
- export interface ImageSource {
1
+ export interface ArtDirectionSource {
2
2
  src: string;
3
- descriptor?: string;
4
- media?: string;
3
+ media: string;
5
4
  type?: string;
5
+ descriptor?: never;
6
6
  }
7
+ export interface ResolutionSource {
8
+ src: string;
9
+ descriptor: string;
10
+ type?: string;
11
+ media?: never;
12
+ }
13
+ export interface PlainSource {
14
+ src: string;
15
+ type?: string;
16
+ media?: never;
17
+ descriptor?: never;
18
+ }
19
+ export type ImageSource = ArtDirectionSource | ResolutionSource | PlainSource;
7
20
  export interface ImageProps {
8
21
  src: string;
9
22
  alt: string;
@@ -10,12 +10,13 @@ export type { FormInputParams, FormProps, FormValidationState, FormValues } from
10
10
  export type { GalleryItem, GalleryMode, GalleryProps } from './gallery';
11
11
  export type { GridColumn, GridItem, GridProps, GridRowValue, RenderDataItemCallback } from './grid';
12
12
  export type { HeaderProps } from './header';
13
- export type { ImageProps, ImageSource } from './image';
13
+ export type { ArtDirectionSource, ImageProps, ImageSource, PlainSource, ResolutionSource, } from './image';
14
14
  export type { LinkProps } from './link';
15
15
  export type { LoaderProps } from './loader';
16
16
  export type { MenuItem, MenuProps } from './menu';
17
17
  export type { MultiSelectProps } from './multi-select';
18
18
  export type { NumericInputProps } from './numeric';
19
+ export type { Author, AvatarProps, PreviewCardProps, TagData, TagProps } from './preview-card';
19
20
  export type { SearchProps } from './search';
20
21
  export type { SelectProps } from './select';
21
22
  export type { SwitchProps } from './switch';
@@ -0,0 +1,38 @@
1
+ import { LinkTarget } from '../enums';
2
+ import { ChopLogicComponentProps } from './_common';
3
+ import { ImageProps } from './image';
4
+ export interface Author {
5
+ id: string;
6
+ name: string;
7
+ imageUrl: string;
8
+ tooltip?: string;
9
+ link?: string;
10
+ linkTarget?: LinkTarget;
11
+ }
12
+ export interface TagData {
13
+ id: string;
14
+ name: string;
15
+ description?: string;
16
+ color?: string;
17
+ }
18
+ export interface AvatarProps extends ChopLogicComponentProps {
19
+ name: string;
20
+ imageUrl: string;
21
+ tooltip?: string;
22
+ link?: string;
23
+ linkTarget?: LinkTarget;
24
+ }
25
+ export interface TagProps extends ChopLogicComponentProps {
26
+ name: string;
27
+ tooltip?: string;
28
+ color?: string;
29
+ }
30
+ export interface PreviewCardProps extends ChopLogicComponentProps {
31
+ link: string;
32
+ linkTarget?: LinkTarget;
33
+ image: ImageProps;
34
+ title: string;
35
+ authors: Author[];
36
+ tags: TagData[];
37
+ summary?: string;
38
+ }