@dss-kit/ui-kit 0.3.10 → 1.0.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 (63) hide show
  1. package/dist/components/builders/Modal/Modal.js +3 -3
  2. package/dist/components/builders/Modal/ModalFooter/ModalFooter.js +7 -7
  3. package/dist/components/builders/Modal/ModalHeader/ModalHeader.js +15 -15
  4. package/dist/components/builders/Modal/ModalMain/styles.js +3 -3
  5. package/dist/components/builders/Modal/styles.js +2 -2
  6. package/dist/components/builders/Table/Table.js +66 -58
  7. package/dist/components/builders/Table/Table.utils.js +5 -5
  8. package/dist/components/builders/Table/TableBodyRow/TableBodyRow.js +5 -5
  9. package/dist/components/builders/Table/TableHeadRow/TableHeadRow.js +4 -4
  10. package/dist/components/builders/Table/TablePagination/TablePagination.js +44 -44
  11. package/dist/components/builders/Table/TableWrapper/TableWrapper.js +19 -19
  12. package/dist/components/charts/LineChart/constants.js +16 -16
  13. package/dist/components/charts/LineChart/utils.js +2 -2
  14. package/dist/components/charts/PieProgressChart/constants.js +16 -10
  15. package/dist/components/controls/Button/Button.js +35 -35
  16. package/dist/components/controls/Button/styles.js +4 -4
  17. package/dist/components/controls/Checkbox/styles.js +7 -7
  18. package/dist/components/controls/IconButton/styles.js +27 -27
  19. package/dist/components/controls/Input/styles.js +10 -10
  20. package/dist/components/controls/MarkdownTextEditor/MarkdownTextEditor.js +32 -32
  21. package/dist/components/controls/MarkdownTextEditor/components/EditorToolbar/ActionMenuButton/ActionMenuButton.js +13 -13
  22. package/dist/components/controls/MarkdownTextEditor/components/EditorToolbar/ActionMenuButton/ActionMenuButton.styles.js +2 -2
  23. package/dist/components/controls/MarkdownTextEditor/components/EditorToolbar/EditorToolbar.js +43 -43
  24. package/dist/components/controls/MarkdownTextEditor/nodes/CustomLinkNode/parts/CustomLinkNodeComponent/CustomLinkNodeComponent.styles.js +3 -3
  25. package/dist/components/controls/MarkdownTextEditor/nodes/ImageRowNode/parts/ImageRowNodeComponent/ImageRowNodeComponent.styles.js +2 -2
  26. package/dist/components/controls/MarkdownTextEditor/themes/editor.theme.js +1 -1
  27. package/dist/components/controls/OtpInput/styles.js +11 -11
  28. package/dist/components/controls/RadioGroup/Radio.js +48 -48
  29. package/dist/components/controls/SegmentControl/SegmentControl.js +12 -12
  30. package/dist/components/controls/SegmentControl/styles.js +8 -8
  31. package/dist/components/controls/Select/styles.js +19 -19
  32. package/dist/components/controls/Switch/styles.js +12 -12
  33. package/dist/components/controls/Tabs/Tabs.js +10 -10
  34. package/dist/components/shared/Avatar/Avatar.js +8 -8
  35. package/dist/components/shared/Badge/Badge.js +40 -40
  36. package/dist/components/shared/Hint/styles.js +6 -6
  37. package/dist/components/shared/MarkdownText/MarkdownText.js +10 -10
  38. package/dist/components/shared/MarkdownText/MarkdownText.styles.js +4 -4
  39. package/dist/components/shared/Popover/PopoverContent/PopoverContent.js +2 -2
  40. package/dist/components/shared/Skeleton/Skeleton.js +11 -11
  41. package/dist/components/shared/Tag/Tag.js +14 -14
  42. package/dist/components/shared/Toast/Toast.js +30 -30
  43. package/dist/components/shared/Tooltip/Tooltip.js +28 -28
  44. package/dist/components/shared/Tooltip/constants.js +3 -3
  45. package/dist/index.js +37 -34
  46. package/dist/providers/ThemeProviderScoped/ThemeProviderScoped.const.d.ts +8 -0
  47. package/dist/providers/ThemeProviderScoped/ThemeProviderScoped.context.d.ts +12 -0
  48. package/dist/providers/ThemeProviderScoped/ThemeProviderScoped.context.js +12 -0
  49. package/dist/providers/ThemeProviderScoped/ThemeProviderScoped.d.ts +1 -1
  50. package/dist/providers/ThemeProviderScoped/ThemeProviderScoped.js +37 -26
  51. package/dist/providers/ThemeProviderScoped/ThemeProviderScoped.types.d.ts +30 -5
  52. package/dist/providers/ThemeProviderScoped/index.d.ts +1 -0
  53. package/dist/root.css +1 -1
  54. package/dist/ui-kit.cjs +8 -8
  55. package/dist/ui-kit.css +1 -1
  56. package/dist/utils/theme/index.d.ts +141 -141
  57. package/dist/utils/theme/index.js +14 -14
  58. package/dist/utils/theme/palette.d.ts +184 -0
  59. package/dist/utils/theme/palette.js +187 -0
  60. package/package.json +1 -1
  61. package/dist/providers/ThemeProviderScoped/styles.module.scss.js +0 -7
  62. package/dist/utils/theme/color.d.ts +0 -184
  63. package/dist/utils/theme/color.js +0 -187
@@ -1,77 +1,77 @@
1
1
  import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
2
  import { cx as t, css as u } from "@emotion/css";
3
- import { forwardRef as T, useMemo as c } from "react";
3
+ import { forwardRef as T, useMemo as i } from "react";
4
4
  import s from "../../../assets/svg/toast/alert-triangle.svg.js";
5
5
  import f from "../../../assets/svg/toast/check-circle.svg.js";
6
6
  import j from "../../../assets/svg/toast/info-circle.svg.js";
7
7
  import v from "../../../assets/svg/toast/x.svg.js";
8
8
  import { theme as r } from "../../../utils/theme/index.js";
9
- import { Box as i } from "../../builders/Box/Box.js";
9
+ import { Box as c } from "../../builders/Box/Box.js";
10
10
  import { Text as m } from "../../builders/Text/Text.js";
11
- const M = {
11
+ const W = {
12
12
  positive: /* @__PURE__ */ e(f, {}),
13
13
  negative: /* @__PURE__ */ e(s, {}),
14
14
  warning: /* @__PURE__ */ e(s, {}),
15
15
  info: /* @__PURE__ */ e(j, {}),
16
16
  neutral: /* @__PURE__ */ e(f, {})
17
- }, W = u({
18
- boxShadow: `0 4px 20px 0 ${r.color.effect.shadowM}`
19
- }), A = u({
17
+ }, A = u({
18
+ boxShadow: `0 4px 20px 0 ${r.color.effect.shadow_m}`
19
+ }), M = u({
20
20
  cursor: "pointer",
21
21
  "&:hover": {
22
22
  opacity: 0.8
23
23
  }
24
24
  }), K = T(
25
25
  ({
26
- title: g,
26
+ title: p,
27
27
  subtitle: l,
28
- icon: a,
28
+ icon: g,
29
29
  variant: o = "neutral",
30
- w: d = "full",
31
- onClose: p,
30
+ w: a = "full",
31
+ onClose: d,
32
32
  className: y,
33
33
  iconBoxClassName: h,
34
34
  titleClassName: x,
35
35
  subtitleClassName: C,
36
- closeIconClassName: b,
37
- ...w
38
- }, S) => {
39
- const I = c(() => o === "neutral" ? r.color.icon.accent : o === "info" ? r.color.icon.accent : o === "positive" ? r.color.icon.positive : o === "negative" ? r.color.icon.negative : o === "warning" ? r.color.icon.warning : r.color.icon.inverse, [o]), P = c(() => o === "neutral" ? r.color.icon.tertiary : r.color.icon.inverse, [o]), N = c(() => o === "neutral" ? r.color.fill.accentSecondary : r.color.fill.bgPrimary, [o]), R = c(() => o === "neutral" ? r.color.fill.bgPrimary : o === "info" ? r.color.fill.accentPrimary : o === "positive" ? r.color.fill.positivePrimary : o === "negative" ? r.color.fill.negativePrimary : o === "warning" ? r.color.fill.warningPrimary : r.color.fill.accentPrimary, [o]), k = c(() => o === "neutral" ? r.color.text.primary : r.color.text.primaryInverse, [o]), B = c(() => o === "neutral" ? r.color.text.tertiaryInverse : r.color.text.primaryInverse, [o]);
36
+ closeIconClassName: _,
37
+ ...b
38
+ }, w) => {
39
+ const S = i(() => o === "neutral" ? r.color.icon.accent : o === "info" ? r.color.icon.accent : o === "positive" ? r.color.icon.positive : o === "negative" ? r.color.icon.negative : o === "warning" ? r.color.icon.warning : r.color.icon.inverse, [o]), N = i(() => o === "neutral" ? r.color.icon.tertiary : r.color.icon.inverse, [o]), R = i(() => o === "neutral" ? r.color.fill.accent_secondary : r.color.fill.bg_primary, [o]), k = i(() => o === "neutral" ? r.color.fill.bg_primary : o === "info" ? r.color.fill.accent_primary : o === "positive" ? r.color.fill.positive_primary : o === "negative" ? r.color.fill.negative_primary : o === "warning" ? r.color.fill.warning_primary : r.color.fill.accent_primary, [o]), I = i(() => o === "neutral" ? r.color.text.primary : r.color.text.primary_inverse, [o]), B = i(() => o === "neutral" ? r.color.text.tertiary_inverse : r.color.text.primary_inverse, [o]);
40
40
  return /* @__PURE__ */ n(
41
- i,
41
+ c,
42
42
  {
43
43
  row: !0,
44
- w: d,
45
- ref: S,
44
+ w: a,
45
+ ref: w,
46
46
  p: r.spacing.md,
47
47
  gap: r.spacing.md,
48
- backgroundColor: R,
48
+ backgroundColor: k,
49
49
  borderRadius: r.cornerRadius.lg,
50
- className: t(W, y),
51
- ...w,
50
+ className: t(A, y),
51
+ ...b,
52
52
  children: [
53
53
  /* @__PURE__ */ e(
54
- i,
54
+ c,
55
55
  {
56
56
  w: 48,
57
57
  h: 48,
58
58
  center: !0,
59
- backgroundColor: N,
59
+ backgroundColor: R,
60
60
  borderRadius: r.cornerRadius.md,
61
- style: { color: I },
61
+ style: { color: S },
62
62
  className: h,
63
- children: a || M[o]
63
+ children: g || W[o]
64
64
  }
65
65
  ),
66
- /* @__PURE__ */ n(i, { flex: 1, children: [
66
+ /* @__PURE__ */ n(c, { flex: 1, children: [
67
67
  /* @__PURE__ */ e(
68
68
  m,
69
69
  {
70
70
  variant: "body-1",
71
71
  fontWeight: "semibold",
72
- color: k,
72
+ color: I,
73
73
  className: x,
74
- children: g
74
+ children: p
75
75
  }
76
76
  ),
77
77
  l && /* @__PURE__ */ e(
@@ -85,13 +85,13 @@ const M = {
85
85
  }
86
86
  )
87
87
  ] }),
88
- /* @__PURE__ */ e(i, { onClick: p, children: /* @__PURE__ */ e(
88
+ /* @__PURE__ */ e(c, { onClick: d, children: /* @__PURE__ */ e(
89
89
  v,
90
90
  {
91
91
  width: 24,
92
92
  height: 24,
93
- color: P,
94
- className: t(A, b)
93
+ color: N,
94
+ className: t(M, _)
95
95
  }
96
96
  ) })
97
97
  ]
@@ -3,26 +3,26 @@ import { css as c, cx as T, keyframes as ho } from "@emotion/css";
3
3
  import { useFloating as go, offset as wo, flip as yo, shift as So, arrow as xo, autoUpdate as vo, useHover as bo, useFocus as Ao, useDismiss as Oo, useRole as Ro, useInteractions as To, useMergeRefs as Do } from "@floating-ui/react";
4
4
  import { useState as D, useId as Po, useCallback as ko, useMemo as Eo, cloneElement as Fo } from "react";
5
5
  import { tooltipStyles as P, tooltipArrowShapes as Co, tooltipArrowOverlap as p, tooltipArrowHeight as Io, tooltipArrowSize as No } from "./constants.js";
6
- import { getTooltipArrowPosition as Mo, getTooltipRadiusOverrides as Ho, getTooltipArrowDimensions as Ko, getTooltipArrowShapeKey as $o } from "./utils.js";
6
+ import { getTooltipArrowPosition as Ho, getTooltipRadiusOverrides as Ko, getTooltipArrowDimensions as Mo, getTooltipArrowShapeKey as $o } from "./utils.js";
7
7
  import { Portal as jo } from "../../builders/Portal/Portal.js";
8
8
  import { Box as w } from "../../builders/Box/Box.js";
9
9
  import { theme as zo } from "../../../utils/theme/index.js";
10
10
  import { Text as Bo } from "../../builders/Text/Text.js";
11
- const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
11
+ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, _o = ho`
12
12
  from { opacity: 0; transform: translateY(2px); }
13
13
  to { opacity: 1; transform: translateY(0); }
14
- `, Go = c({
15
- boxShadow: `0 4px 20px 0 ${Uo.effect.shadowM}`,
16
- animation: `${qo} 0.16s ease-out`,
14
+ `, qo = c({
15
+ boxShadow: `0 4px 20px 0 ${Uo.effect.shadow_m}`,
16
+ animation: `${_o} 0.16s ease-out`,
17
17
  fontSize: "12px",
18
18
  lineHeight: "16px",
19
19
  fontWeight: "500",
20
20
  wordBreak: "break-word"
21
- }), Jo = c({
21
+ }), Go = c({
22
22
  position: "absolute",
23
23
  // Треугольник через clip-path
24
24
  clipPath: "var(--tooltip-arrow-shape)"
25
- }), Lo = ({
25
+ }), Jo = ({
26
26
  color: d = "primary",
27
27
  children: n,
28
28
  content: s,
@@ -35,9 +35,9 @@ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
35
35
  offset: I = 5,
36
36
  showArrow: a = !0,
37
37
  openDelay: N = 400,
38
- closeDelay: M = 0,
39
- closeOnEsc: H = !0,
40
- zIndex: K = 1,
38
+ closeDelay: H = 0,
39
+ closeOnEsc: K = !0,
40
+ zIndex: M = 1,
41
41
  maxWidth: $,
42
42
  className: j,
43
43
  contentClassName: z,
@@ -45,10 +45,10 @@ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
45
45
  textClassName: U,
46
46
  style: W,
47
47
  id: Y,
48
- p: q = Yo.md,
49
- borderRadius: G = Wo.sm
48
+ p: _ = Yo.md,
49
+ borderRadius: q = Wo.sm
50
50
  }) => {
51
- const [J, L] = D(E), [S, Q] = D(null), x = F ?? J, v = C ?? L, V = Po(), f = Y ?? `tooltip-${V}`, X = s == null || s === "", t = !k && !X, Z = ko(
51
+ const [G, J] = D(E), [S, L] = D(null), x = F ?? G, v = C ?? J, Q = Po(), f = Y ?? `tooltip-${Q}`, V = s == null || s === "", t = !k && !V, X = ko(
52
52
  (fo) => {
53
53
  t && v(fo);
54
54
  },
@@ -56,13 +56,13 @@ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
56
56
  ), u = I + (a ? Io : 0), {
57
57
  context: e,
58
58
  refs: b,
59
- floatingStyles: _,
59
+ floatingStyles: Z,
60
60
  middlewareData: oo,
61
61
  placement: h
62
62
  } = go({
63
63
  placement: m,
64
64
  open: t ? x : !1,
65
- onOpenChange: Z,
65
+ onOpenChange: X,
66
66
  whileElementsMounted: vo,
67
67
  middleware: [
68
68
  wo(u),
@@ -74,11 +74,11 @@ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
74
74
  So({ padding: u }),
75
75
  ...a && S ? [xo({ element: S, padding: 0 })] : []
76
76
  ]
77
- }), to = oo.arrow, o = h.split("-")[0], i = h.includes("-") ? h.split("-")[1] : null, A = Mo(to, o, i), eo = $o(o, i), so = Ho(
77
+ }), to = oo.arrow, o = h.split("-")[0], i = h.includes("-") ? h.split("-")[1] : null, A = Ho(to, o, i), eo = $o(o, i), so = Ko(
78
78
  o,
79
79
  i,
80
80
  a
81
- ), r = Ko(
81
+ ), r = Mo(
82
82
  o,
83
83
  i,
84
84
  No
@@ -115,13 +115,13 @@ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
115
115
  enabled: y === "hover" && t,
116
116
  delay: {
117
117
  open: N,
118
- close: M
118
+ close: H
119
119
  },
120
120
  move: !1
121
121
  }), ao = Ao(e, {
122
122
  enabled: y === "hover" && t
123
123
  }), lo = Oo(e, {
124
- enabled: H && t,
124
+ enabled: K && t,
125
125
  escapeKey: !0
126
126
  }), po = Ro(e, { role: "tooltip" }), g = To([no, ao, lo, po]), co = n.ref, O = Do([b.setReference, co]), mo = Eo(
127
127
  () => Fo(
@@ -141,10 +141,10 @@ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
141
141
  w,
142
142
  {
143
143
  absolute: !0,
144
- zIndex: K,
144
+ zIndex: M,
145
145
  className: j,
146
146
  ref: b.setFloating,
147
- style: { ..._, ...W },
147
+ style: { ...Z, ...W },
148
148
  ...g.getFloatingProps({
149
149
  id: f
150
150
  }),
@@ -153,10 +153,10 @@ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
153
153
  {
154
154
  relative: !0,
155
155
  maxWidth: $,
156
- p: q,
157
- borderRadius: G,
156
+ p: _,
157
+ borderRadius: q,
158
158
  className: T(
159
- Go,
159
+ qo,
160
160
  ro,
161
161
  z
162
162
  ),
@@ -164,9 +164,9 @@ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
164
164
  a && /* @__PURE__ */ l(
165
165
  w,
166
166
  {
167
- ref: Q,
167
+ ref: L,
168
168
  className: T(
169
- Jo,
169
+ Go,
170
170
  io,
171
171
  B
172
172
  )
@@ -189,7 +189,7 @@ const { color: Uo, cornerRadius: Wo, spacing: Yo } = zo, qo = ho`
189
189
  ) })
190
190
  ] });
191
191
  };
192
- Lo.displayName = "Tooltip";
192
+ Jo.displayName = "Tooltip";
193
193
  export {
194
- Lo as Tooltip
194
+ Jo as Tooltip
195
195
  };
@@ -21,12 +21,12 @@ const { color: o } = t, l = {
21
21
  // ◄ (tooltip справа, стрелка влево)
22
22
  }, p = 10, n = 6, e = 1, i = {
23
23
  primary: {
24
- backgroundColor: o.fill.bgPrimary,
24
+ backgroundColor: o.fill.bg_primary,
25
25
  color: o.text.primary
26
26
  },
27
27
  inverse: {
28
- backgroundColor: o.fill.bgPrimaryInverse,
29
- color: o.text.primaryInverse
28
+ backgroundColor: o.fill.bg_primary_inverse,
29
+ color: o.text.primary_inverse
30
30
  }
31
31
  };
32
32
  export {
package/dist/index.js CHANGED
@@ -2,20 +2,20 @@
2
2
  import { UiKitLocaleProvider as t } from "./locale/UiKitLocaleProvider/UiKitLocaleProvider.js";
3
3
  import { Box as m } from "./components/builders/Box/Box.js";
4
4
  import { Loader as f } from "./components/builders/Loader/Loader.js";
5
- import { Modal as n } from "./components/builders/Modal/index.js";
5
+ import { Modal as i } from "./components/builders/Modal/index.js";
6
6
  import { Portal as T } from "./components/builders/Portal/Portal.js";
7
7
  import { Ripple as l } from "./components/builders/Ripple/Ripple.js";
8
8
  import { Table as C } from "./components/builders/Table/Table.js";
9
9
  import { createColumnHelper as B } from "@tanstack/react-table";
10
- import { AnimatedText as g, Text as k } from "./components/builders/Text/Text.js";
11
- import { LineChart as E } from "./components/charts/LineChart/LineChart.js";
10
+ import { AnimatedText as h, Text as g } from "./components/builders/Text/Text.js";
11
+ import { LineChart as A } from "./components/charts/LineChart/LineChart.js";
12
12
  import { PieProgressChart as S } from "./components/charts/PieProgressChart/PieProgressChart.js";
13
13
  import { Button as P } from "./components/controls/Button/Button.js";
14
14
  import { Checkbox as _ } from "./components/controls/Checkbox/Checkbox.js";
15
15
  import { IconButton as I } from "./components/controls/IconButton/IconButton.js";
16
16
  import { Input as v } from "./components/controls/Input/Input.js";
17
- import { MarkdownToolbarAction as O } from "./components/controls/MarkdownTextEditor/hooks/useToolbarActions/useToolbarActions.const.js";
18
- import { MARKDOWN_TEXT_EDITOR_LOCALE_KEY as H } from "./components/controls/MarkdownTextEditor/MarkdownTextEditor.locale.js";
17
+ import { MarkdownToolbarAction as K } from "./components/controls/MarkdownTextEditor/hooks/useToolbarActions/useToolbarActions.const.js";
18
+ import { MARKDOWN_TEXT_EDITOR_LOCALE_KEY as D } from "./components/controls/MarkdownTextEditor/MarkdownTextEditor.locale.js";
19
19
  import { MarkdownTextEditor as U } from "./components/controls/MarkdownTextEditor/MarkdownTextEditor.js";
20
20
  import { OtpInput as y } from "./components/controls/OtpInput/OtpInput.js";
21
21
  import { Radio as F } from "./components/controls/RadioGroup/Radio.js";
@@ -29,46 +29,47 @@ import { Avatar as eo } from "./components/shared/Avatar/Avatar.js";
29
29
  import { Badge as po } from "./components/shared/Badge/Badge.js";
30
30
  import { Hint as xo } from "./components/shared/Hint/Hint.js";
31
31
  import { MarkdownText as ao } from "./components/shared/MarkdownText/MarkdownText.js";
32
- import { Popover as io } from "./components/shared/Popover/Popover.js";
32
+ import { Popover as no } from "./components/shared/Popover/Popover.js";
33
33
  import { Skeleton as so } from "./components/shared/Skeleton/Skeleton.js";
34
34
  import { Tag as Co } from "./components/shared/Tag/Tag.js";
35
35
  import { Toast as Bo } from "./components/shared/Toast/Toast.js";
36
- import { useToast as go } from "./components/shared/Toast/Toast.hooks.js";
37
- import { toast as Ao } from "./components/shared/Toast/Toast.utils.js";
38
- import { ToastContainer as ho } from "./components/shared/Toast/ToastContainer.js";
36
+ import { useToast as ho } from "./components/shared/Toast/Toast.hooks.js";
37
+ import { toast as ko } from "./components/shared/Toast/Toast.utils.js";
38
+ import { ToastContainer as Eo } from "./components/shared/Toast/ToastContainer.js";
39
39
  import { Tooltip as Mo } from "./components/shared/Tooltip/Tooltip.js";
40
40
  import { ThemeProviderScoped as Ro } from "./providers/ThemeProviderScoped/ThemeProviderScoped.js";
41
41
  import { THEME_DATA_ATTRIBUTE as bo } from "./providers/ThemeProviderScoped/ThemeProviderScoped.const.js";
42
- import { useControlled as Lo } from "./utils/hooks/useControlled.js";
43
- import { useBreakpoint as wo } from "./utils/hooks/breakpoints/useBreakpoint/useBreakpoint.js";
44
- import { Breakpoints as Do, BreakpointsBase as Ho } from "./utils/hooks/breakpoints/useBreakpoint/useBreakpoint.const.js";
45
- import { getFontWeightClass as Uo } from "./utils/styles/getFontWeightClass/getFontWeightClass.js";
46
- import { getSizeClass as yo } from "./utils/styles/getSizeClass/getSizeClass.js";
47
- import { getStyleClass as Fo } from "./utils/styles/getStyleClass/getStyleClass.js";
48
- import { theme as No } from "./utils/theme/index.js";
42
+ import { ThemeContext as Lo, useUiKitTheme as vo } from "./providers/ThemeProviderScoped/ThemeProviderScoped.context.js";
43
+ import { useControlled as Ko } from "./utils/hooks/useControlled.js";
44
+ import { useBreakpoint as Do } from "./utils/hooks/breakpoints/useBreakpoint/useBreakpoint.js";
45
+ import { Breakpoints as Uo, BreakpointsBase as Wo } from "./utils/hooks/breakpoints/useBreakpoint/useBreakpoint.const.js";
46
+ import { getFontWeightClass as zo } from "./utils/styles/getFontWeightClass/getFontWeightClass.js";
47
+ import { getSizeClass as Go } from "./utils/styles/getSizeClass/getSizeClass.js";
48
+ import { getStyleClass as Xo } from "./utils/styles/getStyleClass/getStyleClass.js";
49
+ import { theme as jo } from "./utils/theme/index.js";
49
50
  export {
50
- g as AnimatedText,
51
+ h as AnimatedText,
51
52
  eo as Avatar,
52
53
  po as Badge,
53
54
  m as Box,
54
55
  oo as Breadcrumbs,
55
- Do as Breakpoints,
56
- Ho as BreakpointsBase,
56
+ Uo as Breakpoints,
57
+ Wo as BreakpointsBase,
57
58
  P as Button,
58
59
  _ as Checkbox,
59
60
  xo as Hint,
60
61
  I as IconButton,
61
62
  v as Input,
62
- E as LineChart,
63
+ A as LineChart,
63
64
  f as Loader,
64
- H as MARKDOWN_TEXT_EDITOR_LOCALE_KEY,
65
+ D as MARKDOWN_TEXT_EDITOR_LOCALE_KEY,
65
66
  ao as MarkdownText,
66
67
  U as MarkdownTextEditor,
67
- O as MarkdownToolbarAction,
68
- n as Modal,
68
+ K as MarkdownToolbarAction,
69
+ i as Modal,
69
70
  y as OtpInput,
70
71
  S as PieProgressChart,
71
- io as Popover,
72
+ no as Popover,
72
73
  T as Portal,
73
74
  F as Radio,
74
75
  N as RadioGroup,
@@ -81,19 +82,21 @@ export {
81
82
  C as Table,
82
83
  Z as Tabs,
83
84
  Co as Tag,
84
- k as Text,
85
+ g as Text,
86
+ Lo as ThemeContext,
85
87
  Ro as ThemeProviderScoped,
86
88
  Bo as Toast,
87
- ho as ToastContainer,
89
+ Eo as ToastContainer,
88
90
  Mo as Tooltip,
89
91
  t as UiKitLocaleProvider,
90
92
  B as createColumnHelper,
91
- Uo as getFontWeightClass,
92
- yo as getSizeClass,
93
- Fo as getStyleClass,
94
- No as theme,
95
- Ao as toast,
96
- wo as useBreakpoint,
97
- Lo as useControlled,
98
- go as useToast
93
+ zo as getFontWeightClass,
94
+ Go as getSizeClass,
95
+ Xo as getStyleClass,
96
+ jo as theme,
97
+ ko as toast,
98
+ Do as useBreakpoint,
99
+ Ko as useControlled,
100
+ ho as useToast,
101
+ vo as useUiKitTheme
99
102
  };
@@ -1 +1,9 @@
1
+ /**
2
+ * Атрибут, которым выбирается тема. Часть публичного контракта: приложение
3
+ * обязано выставить его на `<html>` до первого пейнта (SSR или инлайн-скрипт
4
+ * в `<head>`), иначе фон документа мигнёт светлым — см. docs/styles/themes.
5
+ *
6
+ * Экспортируется именно чтобы anti-flash-скрипты не хардкодили имя: если оно
7
+ * когда-нибудь изменится, потребители сломаются молча.
8
+ */
1
9
  export declare const THEME_DATA_ATTRIBUTE: "data-theme";
@@ -0,0 +1,12 @@
1
+ import { UiKitTheme } from './ThemeProviderScoped.types';
2
+ export interface IThemeContext {
3
+ theme: UiKitTheme;
4
+ setTheme: (theme: UiKitTheme) => void;
5
+ }
6
+ export declare const ThemeContext: import('react').Context<IThemeContext | null>;
7
+ /**
8
+ * Текущая тема и её сеттер — доступны любому компоненту внутри `ThemeProviderScoped`.
9
+ * `setTheme` меняет тему только в uncontrolled-режиме (когда `theme` снаружи не передан);
10
+ * если тема контролируется извне, используйте `onThemeChange` на `ThemeProviderScoped`.
11
+ */
12
+ export declare function useUiKitTheme(): IThemeContext;
@@ -0,0 +1,12 @@
1
+ import { createContext as t, useContext as o } from "react";
2
+ const r = t(null);
3
+ function i() {
4
+ const e = o(r);
5
+ if (!e)
6
+ throw new Error("useUiKitTheme must be used within a ThemeProviderScoped");
7
+ return e;
8
+ }
9
+ export {
10
+ r as ThemeContext,
11
+ i as useUiKitTheme
12
+ };
@@ -1,2 +1,2 @@
1
1
  import { IThemeProviderProps } from './ThemeProviderScoped.types';
2
- export declare function ThemeProviderScoped({ className, children, theme, position, applyThemeToRoot, }: IThemeProviderProps): import("react/jsx-runtime").JSX.Element;
2
+ export declare function ThemeProviderScoped({ className, children, theme: controlledTheme, defaultTheme, onThemeChange, position, }: IThemeProviderProps): import("react/jsx-runtime").JSX.Element;
@@ -1,35 +1,46 @@
1
- import { jsx as t, jsxs as n } from "react/jsx-runtime";
2
- import d from "classnames";
3
- import { useRef as c, useEffect as p } from "react";
4
- import { PortalHostContext as u } from "../../components/builders/Portal/context.js";
5
- import { ToastContainer as l } from "../../components/shared/Toast/ToastContainer.js";
6
- import a from "./styles.module.scss.js";
7
- import { THEME_DATA_ATTRIBUTE as i } from "./ThemeProviderScoped.const.js";
8
- function h({
9
- className: s,
10
- children: m,
11
- theme: r,
12
- position: f = "top-right",
13
- applyThemeToRoot: o = !1
1
+ import { jsx as r, jsxs as T } from "react/jsx-runtime";
2
+ import { useRef as a, useCallback as C, useMemo as x, useEffect as E } from "react";
3
+ import { PortalHostContext as A } from "../../components/builders/Portal/context.js";
4
+ import { ToastContainer as P } from "../../components/shared/Toast/ToastContainer.js";
5
+ import { THEME_DATA_ATTRIBUTE as l } from "./ThemeProviderScoped.const.js";
6
+ import { ThemeContext as R } from "./ThemeProviderScoped.context.js";
7
+ import { useControlled as b } from "../../utils/hooks/useControlled.js";
8
+ function B({
9
+ className: c,
10
+ children: u,
11
+ theme: t,
12
+ defaultTheme: f = "light",
13
+ onThemeChange: i,
14
+ position: p = "top-right"
14
15
  }) {
15
- const e = c(null);
16
- return p(() => {
17
- !o || typeof r != "string" || document.documentElement.setAttribute(i, r);
18
- }, [o, r]), // Прокидываем ref в контекст, чтобы вложенный Portal знал, куда монтировать DOM.
19
- /* @__PURE__ */ t(u.Provider, { value: e, children: /* @__PURE__ */ n(
16
+ const m = a(null), [h, s] = b(
17
+ t,
18
+ f
19
+ ), o = t !== void 0, e = o ? t : h, n = C(
20
+ (d) => {
21
+ o || s(d), i?.(d);
22
+ },
23
+ [o, i, s]
24
+ ), v = x(
25
+ () => ({ theme: e, setTheme: n }),
26
+ [e, n]
27
+ );
28
+ return E(() => {
29
+ document.documentElement.setAttribute(l, e);
30
+ }, [e]), /* @__PURE__ */ r(R.Provider, { value: v, children: /* @__PURE__ */ r(A.Provider, { value: m, children: /* @__PURE__ */ T(
20
31
  "div",
21
32
  {
22
- ref: e,
23
- className: d(a.themeProviderScoped, s),
24
- id: "theme-provider-scoped",
25
- [i]: r,
33
+ ref: m,
34
+ className: c,
35
+ id: "dss-theme-provider",
36
+ [l]: e,
26
37
  children: [
27
- m,
28
- /* @__PURE__ */ t(l, { position: f })
38
+ u,
39
+ /* @__PURE__ */ r(P, { position: p })
29
40
  ]
30
41
  }
31
- ) });
42
+ ) }) });
32
43
  }
33
44
  export {
34
- h as ThemeProviderScoped
45
+ B as ThemeProviderScoped
35
46
  };
@@ -1,13 +1,38 @@
1
1
  import { PropsWithChildren } from 'react';
2
2
  import { ToastPosition } from '../../components/shared/Toast';
3
3
  import { IClassnameProp } from '../../types';
4
- export type UiKitTheme = "dark" | "light" | "brand" | "crimson-light" | "crimson-dark";
4
+ export type UiKitTheme = "dark" | "light";
5
5
  export interface IThemeProviderProps extends IClassnameProp, PropsWithChildren {
6
+ /**
7
+ * Активная тема в controlled-режиме — компонент всегда следует этому значению,
8
+ * `setTheme` из `useUiKitTheme()` сам его не меняет (см. `onThemeChange`).
9
+ *
10
+ * Нужен, только если источник истины о теме живёт СНАРУЖИ этого дерева —
11
+ * например, в Redux/сторе, который может измениться независимо от вызовов
12
+ * `setTheme()` изнутри (WebView-мост, другая вкладка и т.п.), и/или тему
13
+ * читают ещё где-то помимо потомков этого провайдера. Если единственный,
14
+ * кто вообще меняет тему — компонент внутри дерева через `useUiKitTheme()`,
15
+ * controlled не нужен — используйте `defaultTheme`, это заметно проще.
16
+ */
6
17
  theme?: UiKitTheme;
7
- position?: ToastPosition;
8
18
  /**
9
- * Синхронизирует атрибут темы на document при смене темы.
10
- * Нужно для фона `html`/`body` и iOS overscroll
19
+ * Начальная тема в uncontrolled-режиме (когда `theme` не передан) — обычный
20
+ * случай, если единственный источник смены темы — вызовы `setTheme()` из
21
+ * `useUiKitTheme()` внутри дерева. Компонент сам хранит и обновляет
22
+ * состояние дальше, никакой обвязки снаружи не требуется.
23
+ * @default "light"
11
24
  */
12
- applyThemeToRoot?: boolean;
25
+ defaultTheme?: UiKitTheme;
26
+ /**
27
+ * Вызывается при каждом `setTheme()` из `useUiKitTheme()` — в обоих режимах,
28
+ * и controlled, и uncontrolled. Предназначен для side-effect'ов
29
+ * (например, сохранить тему в cookie/localStorage), а не для самого
30
+ * переключения:
31
+ * - в uncontrolled-режиме компонент и так обновит своё состояние сам —
32
+ * этот колбэк тут не единственный (и не обязательный) способ сменить тему;
33
+ * - в controlled-режиме это единственный способ реально сменить тему:
34
+ * сохраните новое значение снаружи и передайте его обратно через `theme`.
35
+ */
36
+ onThemeChange?: (theme: UiKitTheme) => void;
37
+ position?: ToastPosition;
13
38
  }
@@ -1,3 +1,4 @@
1
1
  export * from './ThemeProviderScoped';
2
2
  export * from './ThemeProviderScoped.const';
3
+ export * from './ThemeProviderScoped.context';
3
4
  export type * from './ThemeProviderScoped.types';