@tcn/ui 0.8.1 → 0.9.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 (112) hide show
  1. package/dist/feedback/progress/progress_bar.js +13 -13
  2. package/dist/form/field/common/field_description.js +7 -8
  3. package/dist/form/field/common/field_description.js.map +1 -1
  4. package/dist/form/field/common/field_error.js +6 -6
  5. package/dist/form/field/common/field_label.js +7 -8
  6. package/dist/form/field/common/field_label.js.map +1 -1
  7. package/dist/form/field_set/field_set.js +7 -7
  8. package/dist/inputs/date_picker/date_picker_date.js +6 -6
  9. package/dist/inputs/date_picker/date_picker_day.js +6 -6
  10. package/dist/inputs/date_picker/date_picker_time_selector.js +5 -5
  11. package/dist/inputs/date_picker/date_picker_year_selector.js +5 -5
  12. package/dist/inputs/suggestions/suggestion_list.js +6 -6
  13. package/dist/layouts/index.d.ts +2 -0
  14. package/dist/layouts/index.d.ts.map +1 -1
  15. package/dist/layouts/index.js +46 -42
  16. package/dist/layouts/index.js.map +1 -1
  17. package/dist/layouts/responsive/breakpoint.d.ts +11 -0
  18. package/dist/layouts/responsive/breakpoint.d.ts.map +1 -0
  19. package/dist/layouts/responsive/breakpoint.js +15 -0
  20. package/dist/layouts/responsive/breakpoint.js.map +1 -0
  21. package/dist/layouts/responsive/responsive.d.ts +7 -0
  22. package/dist/layouts/responsive/responsive.d.ts.map +1 -0
  23. package/dist/layouts/responsive/responsive.js +11 -0
  24. package/dist/layouts/responsive/responsive.js.map +1 -0
  25. package/dist/layouts/responsive/responsive_container.d.ts +7 -0
  26. package/dist/layouts/responsive/responsive_container.d.ts.map +1 -0
  27. package/dist/layouts/responsive/responsive_container.js +30 -0
  28. package/dist/layouts/responsive/responsive_container.js.map +1 -0
  29. package/dist/layouts/responsive/responsive_viewport.d.ts +7 -0
  30. package/dist/layouts/responsive/responsive_viewport.d.ts.map +1 -0
  31. package/dist/layouts/responsive/responsive_viewport.js +12 -0
  32. package/dist/layouts/responsive/responsive_viewport.js.map +1 -0
  33. package/dist/surfaces/confirm/confirm.js +5 -5
  34. package/dist/surfaces/pop_confirm/pop_confirm.js +3 -2
  35. package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -1
  36. package/dist/typography/body_text/body_text.d.ts +2 -1
  37. package/dist/typography/body_text/body_text.d.ts.map +1 -1
  38. package/dist/typography/body_text/body_text.js +24 -23
  39. package/dist/typography/body_text/body_text.js.map +1 -1
  40. package/dist/typography/callout/callout.d.ts +2 -1
  41. package/dist/typography/callout/callout.d.ts.map +1 -1
  42. package/dist/typography/callout/callout.js +28 -27
  43. package/dist/typography/callout/callout.js.map +1 -1
  44. package/dist/typography/caption/caption.d.ts +2 -1
  45. package/dist/typography/caption/caption.d.ts.map +1 -1
  46. package/dist/typography/caption/caption.js +18 -17
  47. package/dist/typography/caption/caption.js.map +1 -1
  48. package/dist/typography/footnote/footnote.d.ts +2 -1
  49. package/dist/typography/footnote/footnote.d.ts.map +1 -1
  50. package/dist/typography/footnote/footnote.js +25 -24
  51. package/dist/typography/footnote/footnote.js.map +1 -1
  52. package/dist/typography/headline/headline.d.ts +2 -1
  53. package/dist/typography/headline/headline.d.ts.map +1 -1
  54. package/dist/typography/headline/headline.js +36 -33
  55. package/dist/typography/headline/headline.js.map +1 -1
  56. package/dist/typography/subheadline/subheadline.d.ts +2 -1
  57. package/dist/typography/subheadline/subheadline.d.ts.map +1 -1
  58. package/dist/typography/subheadline/subheadline.js +35 -32
  59. package/dist/typography/subheadline/subheadline.js.map +1 -1
  60. package/dist/utils/dnd/context.d.ts.map +1 -1
  61. package/dist/utils/dnd/context.js +9 -7
  62. package/dist/utils/dnd/context.js.map +1 -1
  63. package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -1
  64. package/dist/utils/dnd/hooks/use_drag_container.js +29 -15
  65. package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -1
  66. package/dist/utils/dnd/types.d.ts +3 -4
  67. package/dist/utils/dnd/types.d.ts.map +1 -1
  68. package/dist/utils/hooks/use_media_query.d.ts +5 -8
  69. package/dist/utils/hooks/use_media_query.d.ts.map +1 -1
  70. package/dist/utils/hooks/use_media_query.js +10 -11
  71. package/dist/utils/hooks/use_media_query.js.map +1 -1
  72. package/dist/utils/index.d.ts +1 -2
  73. package/dist/utils/index.d.ts.map +1 -1
  74. package/dist/utils/index.js +19 -21
  75. package/dist/utils/index.js.map +1 -1
  76. package/package.json +1 -1
  77. package/src/layouts/index.ts +2 -0
  78. package/src/layouts/responsive/breakpoint.tsx +29 -0
  79. package/src/layouts/responsive/responsive.stories.tsx +37 -0
  80. package/src/layouts/responsive/responsive.tsx +18 -0
  81. package/src/layouts/responsive/responsive_container.tsx +51 -0
  82. package/src/layouts/responsive/responsive_viewport.tsx +17 -0
  83. package/src/typography/body_text/body_text.tsx +21 -17
  84. package/src/typography/callout/callout.tsx +20 -16
  85. package/src/typography/caption/caption.tsx +20 -16
  86. package/src/typography/footnote/footnote.tsx +20 -16
  87. package/src/typography/headline/headline.tsx +60 -54
  88. package/src/typography/subheadline/subheadline.tsx +60 -54
  89. package/src/utils/dnd/__stories__/draggable.stories.tsx +34 -0
  90. package/src/utils/dnd/context.ts +1 -0
  91. package/src/utils/dnd/hooks/use_drag_container.ts +18 -1
  92. package/src/utils/dnd/types.ts +4 -1
  93. package/src/utils/hooks/use_media_query.ts +16 -27
  94. package/src/utils/index.ts +1 -3
  95. package/dist/body_text.module-h4XQE2pC.js +0 -5
  96. package/dist/body_text.module-h4XQE2pC.js.map +0 -1
  97. package/dist/callout.module-D8ECmxpO.js +0 -5
  98. package/dist/callout.module-D8ECmxpO.js.map +0 -1
  99. package/dist/caption.module-DDq0H4xZ.js +0 -5
  100. package/dist/caption.module-DDq0H4xZ.js.map +0 -1
  101. package/dist/footnote.module-DEyFuqOr.js +0 -5
  102. package/dist/footnote.module-DEyFuqOr.js.map +0 -1
  103. package/dist/headline.module-BiwHBtGf.js +0 -5
  104. package/dist/headline.module-BiwHBtGf.js.map +0 -1
  105. package/dist/subheadline.module-C-v7zMkQ.js +0 -5
  106. package/dist/subheadline.module-C-v7zMkQ.js.map +0 -1
  107. package/dist/utils/responsive/responsive_renderer.d.ts +0 -21
  108. package/dist/utils/responsive/responsive_renderer.d.ts.map +0 -1
  109. package/dist/utils/responsive/responsive_renderer.js +0 -12
  110. package/dist/utils/responsive/responsive_renderer.js.map +0 -1
  111. package/src/utils/responsive/responsive_renderer.stories.tsx +0 -77
  112. package/src/utils/responsive/responsive_renderer.tsx +0 -31
@@ -1,36 +1,39 @@
1
- import { jsx as g } from "react/jsx-runtime";
1
+ import { jsx as b } from "react/jsx-runtime";
2
+ import g from "react";
2
3
  import { clsx as p } from "clsx";
3
- import { s as u } from "../../subheadline.module-C-v7zMkQ.js";
4
- function j({
5
- size: n = "md",
6
- emphasis: l = "normal",
7
- hierarchy: o = "primary",
8
- color: e,
9
- children: s,
10
- className: t,
11
- style: i = {},
12
- padStart: r,
13
- padEnd: d,
14
- padBottom: f,
15
- padTop: m,
16
- pad: h,
17
- selectable: c = !0
18
- }) {
19
- let a;
20
- return n === "lg" ? a = "h3" : n === "md" ? a = "h4" : a = "h5", h && (i.padding = h), r && (i.paddingInlineStart = r), d && (i.paddingInlineEnd = d), m && (i.paddingTop = m), f && (i.paddingBottom = f), e && (i.color = e), /* @__PURE__ */ g(
21
- a,
22
- {
23
- "data-hierarchy": o,
24
- "data-emphasis": l,
25
- "data-selectable": c,
26
- className: p(u.subheadline, t, "tcn-subheadline"),
27
- style: i,
28
- "data-size": n,
29
- children: s
30
- }
31
- );
32
- }
4
+ import '../../subheadline.css';const _ = "_subheadline_ae8bc38", x = { subheadline: _ }, w = g.forwardRef(
5
+ function({
6
+ size: a = "md",
7
+ emphasis: o = "normal",
8
+ hierarchy: h = "primary",
9
+ color: n,
10
+ children: m,
11
+ className: s,
12
+ style: i = {},
13
+ padStart: d,
14
+ padEnd: r,
15
+ padBottom: f,
16
+ padTop: t,
17
+ pad: l,
18
+ selectable: c = !0
19
+ }, u) {
20
+ let e;
21
+ return a === "lg" ? e = "h3" : a === "md" ? e = "h4" : e = "h5", l && (i.padding = l), d && (i.paddingInlineStart = d), r && (i.paddingInlineEnd = r), t && (i.paddingTop = t), f && (i.paddingBottom = f), n && (i.color = n), /* @__PURE__ */ b(
22
+ e,
23
+ {
24
+ ref: u,
25
+ "data-hierarchy": h,
26
+ "data-emphasis": o,
27
+ "data-selectable": c,
28
+ className: p(x.subheadline, s, "tcn-subheadline"),
29
+ style: i,
30
+ "data-size": a,
31
+ children: m
32
+ }
33
+ );
34
+ }
35
+ );
33
36
  export {
34
- j as Subheadline
37
+ w as Subheadline
35
38
  };
36
39
  //# sourceMappingURL=subheadline.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"subheadline.js","sources":["../../../src/typography/subheadline/subheadline.tsx"],"sourcesContent":["import React from 'react';\nimport { clsx } from 'clsx';\nimport { Emphasis, Hierarchy, Size } from '../../utils/index.js';\nimport type { WithDetailedHTMLProps } from '../../stacks/types/as.js';\nimport styles from './subheadline.module.css';\n\nexport interface SubheadlineOwnProps {\n children?: string;\n size?: Size;\n emphasis?: Emphasis;\n hierarchy?: Hierarchy;\n color?: string;\n pad?: string;\n padStart?: string;\n padEnd?: string;\n padTop?: string;\n padBottom?: string;\n selectable?: boolean;\n}\n\nexport type SubheadlineProps = WithDetailedHTMLProps<\n SubheadlineOwnProps,\n 'h3' | 'h4' | 'h5'\n>;\n\nexport function Subheadline({\n size = 'md',\n emphasis = 'normal',\n hierarchy = 'primary',\n color,\n children,\n className,\n style = {},\n padStart,\n padEnd,\n padBottom,\n padTop,\n pad,\n selectable = true,\n}: SubheadlineProps) {\n let As: React.ElementType;\n\n if (size === 'lg') {\n As = 'h3';\n } else if (size === 'md') {\n As = 'h4';\n } else {\n As = 'h5';\n }\n\n if (pad) {\n style.padding = pad;\n }\n\n if (padStart) {\n style.paddingInlineStart = padStart;\n }\n\n if (padEnd) {\n style.paddingInlineEnd = padEnd;\n }\n\n if (padTop) {\n style.paddingTop = padTop;\n }\n\n if (padBottom) {\n style.paddingBottom = padBottom;\n }\n\n if (color) {\n style.color = color;\n }\n\n return (\n <As\n data-hierarchy={hierarchy}\n data-emphasis={emphasis}\n data-selectable={selectable}\n className={clsx(styles['subheadline'], className, 'tcn-subheadline')}\n style={style}\n data-size={size}\n >\n {children}\n </As>\n );\n}\n"],"names":["Subheadline","size","emphasis","hierarchy","color","children","className","style","padStart","padEnd","padBottom","padTop","pad","selectable","As","jsx","clsx","styles"],"mappings":";;;AAyBO,SAASA,EAAY;AAAA,EAC1B,MAAAC,IAAO;AAAA,EACP,UAAAC,IAAW;AAAA,EACX,WAAAC,IAAY;AAAA,EACZ,OAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,OAAAC,IAAQ,CAAA;AAAA,EACR,UAAAC;AAAA,EACA,QAAAC;AAAA,EACA,WAAAC;AAAA,EACA,QAAAC;AAAA,EACA,KAAAC;AAAA,EACA,YAAAC,IAAa;AACf,GAAqB;AACnB,MAAIC;AAEJ,SAAIb,MAAS,OACXa,IAAK,OACIb,MAAS,OAClBa,IAAK,OAELA,IAAK,MAGHF,MACFL,EAAM,UAAUK,IAGdJ,MACFD,EAAM,qBAAqBC,IAGzBC,MACFF,EAAM,mBAAmBE,IAGvBE,MACFJ,EAAM,aAAaI,IAGjBD,MACFH,EAAM,gBAAgBG,IAGpBN,MACFG,EAAM,QAAQH,IAId,gBAAAW;AAAA,IAACD;AAAA,IAAA;AAAA,MACC,kBAAgBX;AAAA,MAChB,iBAAeD;AAAA,MACf,mBAAiBW;AAAA,MACjB,WAAWG,EAAKC,EAAO,aAAgBX,GAAW,iBAAiB;AAAA,MACnE,OAAAC;AAAA,MACA,aAAWN;AAAA,MAEV,UAAAI;AAAA,IAAA;AAAA,EAAA;AAGP;"}
1
+ {"version":3,"file":"subheadline.js","sources":["../../../src/typography/subheadline/subheadline.tsx"],"sourcesContent":["import React from 'react';\nimport { clsx } from 'clsx';\nimport { Emphasis, Hierarchy, Size } from '../../utils/index.js';\nimport type { WithDetailedHTMLProps } from '../../stacks/types/as.js';\nimport styles from './subheadline.module.css';\n\nexport interface SubheadlineOwnProps {\n children?: string;\n size?: Size;\n emphasis?: Emphasis;\n hierarchy?: Hierarchy;\n color?: string;\n pad?: string;\n padStart?: string;\n padEnd?: string;\n padTop?: string;\n padBottom?: string;\n selectable?: boolean;\n}\n\nexport type SubheadlineProps = WithDetailedHTMLProps<\n SubheadlineOwnProps,\n 'h3' | 'h4' | 'h5'\n>;\n\nexport const Subheadline = React.forwardRef<HTMLHeadingElement, SubheadlineProps>(\n function Subheadline(\n {\n size = 'md',\n emphasis = 'normal',\n hierarchy = 'primary',\n color,\n children,\n className,\n style = {},\n padStart,\n padEnd,\n padBottom,\n padTop,\n pad,\n selectable = true,\n }: SubheadlineProps,\n ref\n ) {\n let As: React.ElementType;\n\n if (size === 'lg') {\n As = 'h3';\n } else if (size === 'md') {\n As = 'h4';\n } else {\n As = 'h5';\n }\n\n if (pad) {\n style.padding = pad;\n }\n\n if (padStart) {\n style.paddingInlineStart = padStart;\n }\n\n if (padEnd) {\n style.paddingInlineEnd = padEnd;\n }\n\n if (padTop) {\n style.paddingTop = padTop;\n }\n\n if (padBottom) {\n style.paddingBottom = padBottom;\n }\n\n if (color) {\n style.color = color;\n }\n\n return (\n <As\n ref={ref}\n data-hierarchy={hierarchy}\n data-emphasis={emphasis}\n data-selectable={selectable}\n className={clsx(styles['subheadline'], className, 'tcn-subheadline')}\n style={style}\n data-size={size}\n >\n {children}\n </As>\n );\n }\n);\n"],"names":["Subheadline","React","size","emphasis","hierarchy","color","children","className","style","padStart","padEnd","padBottom","padTop","pad","selectable","ref","As","jsx","clsx","styles"],"mappings":";;;0DAyBaA,IAAcC,EAAM;AAAA,EAC/B,SACE;AAAA,IACE,MAAAC,IAAO;AAAA,IACP,UAAAC,IAAW;AAAA,IACX,WAAAC,IAAY;AAAA,IACZ,OAAAC;AAAA,IACA,UAAAC;AAAA,IACA,WAAAC;AAAA,IACA,OAAAC,IAAQ,CAAA;AAAA,IACR,UAAAC;AAAA,IACA,QAAAC;AAAA,IACA,WAAAC;AAAA,IACA,QAAAC;AAAA,IACA,KAAAC;AAAA,IACA,YAAAC,IAAa;AAAA,EAAA,GAEfC,GACA;AACA,QAAIC;AAEJ,WAAId,MAAS,OACXc,IAAK,OACId,MAAS,OAClBc,IAAK,OAELA,IAAK,MAGHH,MACFL,EAAM,UAAUK,IAGdJ,MACFD,EAAM,qBAAqBC,IAGzBC,MACFF,EAAM,mBAAmBE,IAGvBE,MACFJ,EAAM,aAAaI,IAGjBD,MACFH,EAAM,gBAAgBG,IAGpBN,MACFG,EAAM,QAAQH,IAId,gBAAAY;AAAA,MAACD;AAAA,MAAA;AAAA,QACC,KAAAD;AAAA,QACA,kBAAgBX;AAAA,QAChB,iBAAeD;AAAA,QACf,mBAAiBW;AAAA,QACjB,WAAWI,EAAKC,EAAO,aAAgBZ,GAAW,iBAAiB;AAAA,QACnE,OAAAC;AAAA,QACA,aAAWN;AAAA,QAEV,UAAAI;AAAA,MAAA;AAAA,IAAA;AAAA,EAGP;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/utils/dnd/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAShD,eAAO,MAAM,oBAAoB,wCAA6C,CAAC;AAE/E,wBAAgB,gBAAgB,IAAI,aAAa,CAWhD"}
1
+ {"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../../src/utils/dnd/context.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAUhD,eAAO,MAAM,oBAAoB,wCAA6C,CAAC;AAE/E,wBAAgB,gBAAgB,IAAI,aAAa,CAWhD"}
@@ -1,20 +1,22 @@
1
- import { createContext as t, useContext as r } from "react";
2
- const n = {
1
+ import { createContext as n, useContext as o } from "react";
2
+ const t = {
3
3
  registerHandle: () => {
4
4
  },
5
5
  unregisterHandle: () => {
6
6
  },
7
7
  isDragging: !1,
8
- position: { x: 0, y: 0 }
9
- }, o = t(n);
8
+ position: { x: 0, y: 0 },
9
+ setPosition: () => {
10
+ }
11
+ }, r = n(t);
10
12
  function i() {
11
- const e = r(o);
12
- return e === n && console.warn(
13
+ const e = o(r);
14
+ return e === t && console.warn(
13
15
  "useDragContainer: No DragContainerContext found. Handles may will not register or trigger drag events."
14
16
  ), e;
15
17
  }
16
18
  export {
17
- o as DragContainerContext,
19
+ r as DragContainerContext,
18
20
  i as useDragContainer
19
21
  };
20
22
  //# sourceMappingURL=context.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sources":["../../../src/utils/dnd/context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { DragContainer } from './types.js';\n\nconst defaultValue: DragContainer = {\n registerHandle: () => {},\n unregisterHandle: () => {},\n isDragging: false,\n position: { x: 0, y: 0 },\n};\n\nexport const DragContainerContext = createContext<DragContainer>(defaultValue);\n\nexport function useDragContainer(): DragContainer {\n const context = useContext(DragContainerContext);\n\n if (context === defaultValue) {\n // biome-ignore lint/suspicious/noConsole: Let devs know if they're not using the context correctly\n console.warn(\n 'useDragContainer: No DragContainerContext found. Handles may will not register or trigger drag events.'\n );\n }\n\n return context;\n}\n"],"names":["defaultValue","DragContainerContext","createContext","useDragContainer","context","useContext"],"mappings":";AAGA,MAAMA,IAA8B;AAAA,EAClC,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,YAAY;AAAA,EACZ,UAAU,EAAE,GAAG,GAAG,GAAG,EAAA;AACvB,GAEaC,IAAuBC,EAA6BF,CAAY;AAEtE,SAASG,IAAkC;AAChD,QAAMC,IAAUC,EAAWJ,CAAoB;AAE/C,SAAIG,MAAYJ,KAEd,QAAQ;AAAA,IACN;AAAA,EAAA,GAIGI;AACT;"}
1
+ {"version":3,"file":"context.js","sources":["../../../src/utils/dnd/context.ts"],"sourcesContent":["import { createContext, useContext } from 'react';\nimport type { DragContainer } from './types.js';\n\nconst defaultValue: DragContainer = {\n registerHandle: () => {},\n unregisterHandle: () => {},\n isDragging: false,\n position: { x: 0, y: 0 },\n setPosition: () => {},\n};\n\nexport const DragContainerContext = createContext<DragContainer>(defaultValue);\n\nexport function useDragContainer(): DragContainer {\n const context = useContext(DragContainerContext);\n\n if (context === defaultValue) {\n // biome-ignore lint/suspicious/noConsole: Let devs know if they're not using the context correctly\n console.warn(\n 'useDragContainer: No DragContainerContext found. Handles may will not register or trigger drag events.'\n );\n }\n\n return context;\n}\n"],"names":["defaultValue","DragContainerContext","createContext","useDragContainer","context","useContext"],"mappings":";AAGA,MAAMA,IAA8B;AAAA,EAClC,gBAAgB,MAAM;AAAA,EAAC;AAAA,EACvB,kBAAkB,MAAM;AAAA,EAAC;AAAA,EACzB,YAAY;AAAA,EACZ,UAAU,EAAE,GAAG,GAAG,GAAG,EAAA;AAAA,EACrB,aAAa,MAAM;AAAA,EAAC;AACtB,GAEaC,IAAuBC,EAA6BF,CAAY;AAEtE,SAASG,IAAkC;AAChD,QAAMC,IAAUC,EAAWJ,CAAoB;AAE/C,SAAIG,MAAYJ,KAEd,QAAQ;AAAA,IACN;AAAA,EAAA,GAIGI;AACT;"}
@@ -1 +1 @@
1
- {"version":3,"file":"use_drag_container.d.ts","sourceRoot":"","sources":["../../../../src/utils/dnd/hooks/use_drag_container.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,EAAE,QAAQ,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,aAAa,CAgCpF"}
1
+ {"version":3,"file":"use_drag_container.d.ts","sourceRoot":"","sources":["../../../../src/utils/dnd/hooks/use_drag_container.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEjD,MAAM,WAAW,uBAAuB;IACtC,eAAe,CAAC,EAAE,QAAQ,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,uBAAuB,GAAG,aAAa,CAiDpF"}
@@ -1,28 +1,42 @@
1
- import { useState as n, useRef as b, useCallback as o } from "react";
1
+ import { useState as s, useRef as b, useCallback as o } from "react";
2
2
  import { useDraggable as k } from "./use_draggable.js";
3
- function m(l) {
4
- const [c, a] = n([]), r = b(l.initialPosition ?? { x: 0, y: 0 }), [s, g] = n(r.current), [u, i] = n(!1);
3
+ function m(g) {
4
+ const [u, a] = s([]), n = b(g.initialPosition ?? { x: 0, y: 0 }), [i, c] = s(n.current), [f, l] = s(!1);
5
5
  k({
6
- handles: c,
6
+ handles: u,
7
7
  startDragCallback: () => {
8
- i(!0);
8
+ l(!0);
9
9
  },
10
- dragCallback: (e, t) => {
11
- g({
12
- x: r.current.x + e,
13
- y: r.current.y + t
10
+ dragCallback: (t, e) => {
11
+ c({
12
+ x: n.current.x + t,
13
+ y: n.current.y + e
14
14
  });
15
15
  },
16
16
  endDragCallback: () => {
17
- i(!1), r.current = s;
17
+ l(!1), n.current = i;
18
18
  }
19
19
  });
20
- const f = o((e) => {
21
- a((t) => [...t, e]);
22
- }, []), d = o((e) => {
23
- a((t) => t.filter((D) => D !== e));
20
+ const d = o(
21
+ (t) => {
22
+ c((e) => {
23
+ const r = typeof t == "function" ? t(e) : t;
24
+ return n.current = r, r;
25
+ });
26
+ },
27
+ []
28
+ ), p = o((t) => {
29
+ a((e) => [...e, t]);
30
+ }, []), D = o((t) => {
31
+ a((e) => e.filter((r) => r !== t));
24
32
  }, []);
25
- return { registerHandle: f, unregisterHandle: d, position: s, isDragging: u };
33
+ return {
34
+ registerHandle: p,
35
+ unregisterHandle: D,
36
+ position: i,
37
+ isDragging: f,
38
+ setPosition: d
39
+ };
26
40
  }
27
41
  export {
28
42
  m as useMakeDragContainer
@@ -1 +1 @@
1
- {"version":3,"file":"use_drag_container.js","sources":["../../../../src/utils/dnd/hooks/use_drag_container.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport { useDraggable } from './use_draggable.js';\nimport type { Position } from '../../index.js';\nimport type { DragContainer } from '../types.js';\n\nexport interface UseDragContainerOptions {\n initialPosition?: Position;\n}\n\nexport function useMakeDragContainer(options: UseDragContainerOptions): DragContainer {\n const [handles, setHandles] = useState<React.RefObject<HTMLElement>[]>([]);\n const positionRef = useRef<Position>(options.initialPosition ?? { x: 0, y: 0 });\n const [position, setPosition] = useState(positionRef.current);\n const [isDragging, setIsDragging] = useState(false);\n\n useDraggable({\n handles: handles,\n startDragCallback: () => {\n setIsDragging(true);\n },\n dragCallback: (deltaX, deltaY) => {\n setPosition({\n x: positionRef.current.x + deltaX,\n y: positionRef.current.y + deltaY,\n });\n },\n endDragCallback: () => {\n setIsDragging(false);\n positionRef.current = position;\n },\n });\n\n const registerHandle = useCallback((handle: React.RefObject<HTMLElement>) => {\n setHandles(prev => [...prev, handle]);\n }, []);\n\n const unregisterHandle = useCallback((handle: React.RefObject<HTMLElement>) => {\n setHandles(prev => prev.filter(h => h !== handle));\n }, []);\n\n return { registerHandle, unregisterHandle, position, isDragging };\n}\n"],"names":["useMakeDragContainer","options","handles","setHandles","useState","positionRef","useRef","position","setPosition","isDragging","setIsDragging","useDraggable","deltaX","deltaY","registerHandle","useCallback","handle","prev","unregisterHandle","h"],"mappings":";;AASO,SAASA,EAAqBC,GAAiD;AACpF,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAyC,CAAA,CAAE,GACnEC,IAAcC,EAAiBL,EAAQ,mBAAmB,EAAE,GAAG,GAAG,GAAG,GAAG,GACxE,CAACM,GAAUC,CAAW,IAAIJ,EAASC,EAAY,OAAO,GACtD,CAACI,GAAYC,CAAa,IAAIN,EAAS,EAAK;AAElD,EAAAO,EAAa;AAAA,IACX,SAAAT;AAAA,IACA,mBAAmB,MAAM;AACvB,MAAAQ,EAAc,EAAI;AAAA,IACpB;AAAA,IACA,cAAc,CAACE,GAAQC,MAAW;AAChC,MAAAL,EAAY;AAAA,QACV,GAAGH,EAAY,QAAQ,IAAIO;AAAA,QAC3B,GAAGP,EAAY,QAAQ,IAAIQ;AAAA,MAAA,CAC5B;AAAA,IACH;AAAA,IACA,iBAAiB,MAAM;AACrB,MAAAH,EAAc,EAAK,GACnBL,EAAY,UAAUE;AAAA,IACxB;AAAA,EAAA,CACD;AAED,QAAMO,IAAiBC,EAAY,CAACC,MAAyC;AAC3E,IAAAb,EAAW,CAAAc,MAAQ,CAAC,GAAGA,GAAMD,CAAM,CAAC;AAAA,EACtC,GAAG,CAAA,CAAE,GAECE,IAAmBH,EAAY,CAACC,MAAyC;AAC7E,IAAAb,EAAW,OAAQc,EAAK,OAAO,CAAAE,MAAKA,MAAMH,CAAM,CAAC;AAAA,EACnD,GAAG,CAAA,CAAE;AAEL,SAAO,EAAE,gBAAAF,GAAgB,kBAAAI,GAAkB,UAAAX,GAAU,YAAAE,EAAA;AACvD;"}
1
+ {"version":3,"file":"use_drag_container.js","sources":["../../../../src/utils/dnd/hooks/use_drag_container.ts"],"sourcesContent":["import { useCallback, useRef, useState } from 'react';\nimport { useDraggable } from './use_draggable.js';\nimport type { Position } from '../../index.js';\nimport type { DragContainer } from '../types.js';\n\nexport interface UseDragContainerOptions {\n initialPosition?: Position;\n}\n\nexport function useMakeDragContainer(options: UseDragContainerOptions): DragContainer {\n const [handles, setHandles] = useState<React.RefObject<HTMLElement>[]>([]);\n const positionRef = useRef<Position>(options.initialPosition ?? { x: 0, y: 0 });\n const [position, setPosition] = useState(positionRef.current);\n const [isDragging, setIsDragging] = useState(false);\n\n useDraggable({\n handles: handles,\n startDragCallback: () => {\n setIsDragging(true);\n },\n dragCallback: (deltaX, deltaY) => {\n setPosition({\n x: positionRef.current.x + deltaX,\n y: positionRef.current.y + deltaY,\n });\n },\n endDragCallback: () => {\n setIsDragging(false);\n positionRef.current = position;\n },\n });\n\n const setPositionState = useCallback(\n (value: Position | ((prev: Position) => Position)) => {\n setPosition(prev => {\n const next = typeof value === 'function' ? value(prev) : value;\n positionRef.current = next;\n return next;\n });\n },\n []\n );\n\n const registerHandle = useCallback((handle: React.RefObject<HTMLElement>) => {\n setHandles(prev => [...prev, handle]);\n }, []);\n\n const unregisterHandle = useCallback((handle: React.RefObject<HTMLElement>) => {\n setHandles(prev => prev.filter(h => h !== handle));\n }, []);\n\n return {\n registerHandle,\n unregisterHandle,\n position,\n isDragging,\n setPosition: setPositionState,\n };\n}\n"],"names":["useMakeDragContainer","options","handles","setHandles","useState","positionRef","useRef","position","setPosition","isDragging","setIsDragging","useDraggable","deltaX","deltaY","setPositionState","useCallback","value","prev","next","registerHandle","handle","unregisterHandle","h"],"mappings":";;AASO,SAASA,EAAqBC,GAAiD;AACpF,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAyC,CAAA,CAAE,GACnEC,IAAcC,EAAiBL,EAAQ,mBAAmB,EAAE,GAAG,GAAG,GAAG,GAAG,GACxE,CAACM,GAAUC,CAAW,IAAIJ,EAASC,EAAY,OAAO,GACtD,CAACI,GAAYC,CAAa,IAAIN,EAAS,EAAK;AAElD,EAAAO,EAAa;AAAA,IACX,SAAAT;AAAA,IACA,mBAAmB,MAAM;AACvB,MAAAQ,EAAc,EAAI;AAAA,IACpB;AAAA,IACA,cAAc,CAACE,GAAQC,MAAW;AAChC,MAAAL,EAAY;AAAA,QACV,GAAGH,EAAY,QAAQ,IAAIO;AAAA,QAC3B,GAAGP,EAAY,QAAQ,IAAIQ;AAAA,MAAA,CAC5B;AAAA,IACH;AAAA,IACA,iBAAiB,MAAM;AACrB,MAAAH,EAAc,EAAK,GACnBL,EAAY,UAAUE;AAAA,IACxB;AAAA,EAAA,CACD;AAED,QAAMO,IAAmBC;AAAA,IACvB,CAACC,MAAqD;AACpD,MAAAR,EAAY,CAAAS,MAAQ;AAClB,cAAMC,IAAO,OAAOF,KAAU,aAAaA,EAAMC,CAAI,IAAID;AACzD,eAAAX,EAAY,UAAUa,GACfA;AAAA,MACT,CAAC;AAAA,IACH;AAAA,IACA,CAAA;AAAA,EAAC,GAGGC,IAAiBJ,EAAY,CAACK,MAAyC;AAC3E,IAAAjB,EAAW,CAAAc,MAAQ,CAAC,GAAGA,GAAMG,CAAM,CAAC;AAAA,EACtC,GAAG,CAAA,CAAE,GAECC,IAAmBN,EAAY,CAACK,MAAyC;AAC7E,IAAAjB,EAAW,OAAQc,EAAK,OAAO,CAAAK,MAAKA,MAAMF,CAAM,CAAC;AAAA,EACnD,GAAG,CAAA,CAAE;AAEL,SAAO;AAAA,IACL,gBAAAD;AAAA,IACA,kBAAAE;AAAA,IACA,UAAAd;AAAA,IACA,YAAAE;AAAA,IACA,aAAaK;AAAA,EAAA;AAEjB;"}
@@ -1,10 +1,9 @@
1
+ import { Position } from '../types/dimensions.js';
1
2
  export interface DragContainer {
2
3
  registerHandle: (handle: React.RefObject<HTMLElement>) => void;
3
4
  unregisterHandle: (handle: React.RefObject<HTMLElement>) => void;
4
5
  isDragging: boolean;
5
- position: {
6
- x: number;
7
- y: number;
8
- };
6
+ position: Position;
7
+ setPosition: (value: Position | ((prev: Position) => Position)) => void;
9
8
  }
10
9
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/dnd/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC/D,gBAAgB,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACjE,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACpC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/utils/dnd/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,WAAW,aAAa;IAC5B,cAAc,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IAC/D,gBAAgB,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,CAAC,KAAK,IAAI,CAAC;IACjE,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,QAAQ,CAAC;IACnB,WAAW,EAAE,CAAC,KAAK,EAAE,QAAQ,GAAG,CAAC,CAAC,IAAI,EAAE,QAAQ,KAAK,QAAQ,CAAC,KAAK,IAAI,CAAC;CACzE"}
@@ -1,9 +1,6 @@
1
- /**
2
- * Custom hook that returns a boolean indicating if the current viewport
3
- * matches the given media query.
4
- *
5
- * @param query - The media query to match against (e.g. "(min-width: 768px)")
6
- * @returns boolean indicating if the media query matches
7
- */
8
- export declare function useMediaQuery(query: string): boolean;
1
+ export interface ViewportSize {
2
+ width: number;
3
+ height: number;
4
+ }
5
+ export declare function useMediaQuery(): ViewportSize;
9
6
  //# sourceMappingURL=use_media_query.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use_media_query.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/use_media_query.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAsBpD"}
1
+ {"version":3,"file":"use_media_query.d.ts","sourceRoot":"","sources":["../../../src/utils/hooks/use_media_query.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,wBAAgB,aAAa,IAAI,YAAY,CAY5C"}
@@ -1,14 +1,13 @@
1
- import s from "react";
2
- function d(t) {
3
- const [c, a] = s.useState(!1);
4
- return s.useEffect(() => {
5
- const e = window.matchMedia(t);
6
- a(e.matches);
7
- const n = (r) => {
8
- a(r.matches);
9
- };
10
- return e.addEventListener("change", n), () => e.removeEventListener("change", n);
11
- }, [t]), c;
1
+ import { useState as i, useLayoutEffect as u } from "react";
2
+ import { useResizeObserver as n } from "./use_resize_observer.js";
3
+ function d() {
4
+ const [o, s] = i({ width: 0, height: 0 }), t = n((e, r) => {
5
+ s({ width: e, height: r });
6
+ });
7
+ return u(() => {
8
+ const e = document.body;
9
+ t(e);
10
+ }, [t]), o;
12
11
  }
13
12
  export {
14
13
  d as useMediaQuery
@@ -1 +1 @@
1
- {"version":3,"file":"use_media_query.js","sources":["../../../src/utils/hooks/use_media_query.ts"],"sourcesContent":["import React from 'react';\n\n/**\n * Custom hook that returns a boolean indicating if the current viewport\n * matches the given media query.\n *\n * @param query - The media query to match against (e.g. \"(min-width: 768px)\")\n * @returns boolean indicating if the media query matches\n */\nexport function useMediaQuery(query: string): boolean {\n const [matches, setMatches] = React.useState(false);\n\n React.useEffect(() => {\n const mediaQuery = window.matchMedia(query);\n\n // Set initial value\n setMatches(mediaQuery.matches);\n\n // Create event listener\n const handler = (event: MediaQueryListEvent) => {\n setMatches(event.matches);\n };\n\n // Add the listener\n mediaQuery.addEventListener('change', handler);\n\n // Clean up\n return () => mediaQuery.removeEventListener('change', handler);\n }, [query]);\n\n return matches;\n}\n"],"names":["useMediaQuery","query","matches","setMatches","React","mediaQuery","handler","event"],"mappings":";AASO,SAASA,EAAcC,GAAwB;AACpD,QAAM,CAACC,GAASC,CAAU,IAAIC,EAAM,SAAS,EAAK;AAElDA,SAAAA,EAAM,UAAU,MAAM;AACpB,UAAMC,IAAa,OAAO,WAAWJ,CAAK;AAG1C,IAAAE,EAAWE,EAAW,OAAO;AAG7B,UAAMC,IAAU,CAACC,MAA+B;AAC9C,MAAAJ,EAAWI,EAAM,OAAO;AAAA,IAC1B;AAGA,WAAAF,EAAW,iBAAiB,UAAUC,CAAO,GAGtC,MAAMD,EAAW,oBAAoB,UAAUC,CAAO;AAAA,EAC/D,GAAG,CAACL,CAAK,CAAC,GAEHC;AACT;"}
1
+ {"version":3,"file":"use_media_query.js","sources":["../../../src/utils/hooks/use_media_query.ts"],"sourcesContent":["import { useLayoutEffect, useState } from 'react';\nimport { useResizeObserver } from './use_resize_observer.js';\n\nexport interface ViewportSize {\n width: number;\n height: number;\n}\n\nexport function useMediaQuery(): ViewportSize {\n const [size, setSize] = useState<ViewportSize>({ width: 0, height: 0 });\n const resizeRef = useResizeObserver((width, height) => {\n setSize({ width, height });\n });\n\n useLayoutEffect(() => {\n const body = document.body;\n resizeRef(body);\n }, [resizeRef]);\n\n return size;\n}\n"],"names":["useMediaQuery","size","setSize","useState","resizeRef","useResizeObserver","width","height","useLayoutEffect","body"],"mappings":";;AAQO,SAASA,IAA8B;AAC5C,QAAM,CAACC,GAAMC,CAAO,IAAIC,EAAuB,EAAE,OAAO,GAAG,QAAQ,GAAG,GAChEC,IAAYC,EAAkB,CAACC,GAAOC,MAAW;AACrD,IAAAL,EAAQ,EAAE,OAAAI,GAAO,QAAAC,GAAQ;AAAA,EAC3B,CAAC;AAED,SAAAC,EAAgB,MAAM;AACpB,UAAMC,IAAO,SAAS;AACtB,IAAAL,EAAUK,CAAI;AAAA,EAChB,GAAG,CAACL,CAAS,CAAC,GAEPH;AACT;"}
@@ -4,8 +4,8 @@ export * from './scroll_away_listener.js';
4
4
  export * from './dnd/hooks/use_draggable.js';
5
5
  export * from './hooks/make_context_hook.js';
6
6
  export * from './hooks/use_fork_ref.js';
7
- export * from './hooks/use_media_query.js';
8
7
  export * from './hooks/use_resize_observer.js';
8
+ export * from './hooks/use_media_query.js';
9
9
  export * from './default_value.js';
10
10
  export * from './calendar/calendar_date.js';
11
11
  export * from './calendar/calendar_dates_generator.js';
@@ -14,7 +14,6 @@ export * from './calendar/get_months_of_year.js';
14
14
  export * from './calendar/month.js';
15
15
  export * from './types/dimensions.js';
16
16
  export * from './types/variations.js';
17
- export * from './responsive/responsive_renderer.js';
18
17
  export * from './dnd/draggable/draggable.js';
19
18
  export * from './dnd/handle.js';
20
19
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAE1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,oBAAoB,CAAC;AAEnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AAEpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,qCAAqC,CAAC;AAEpD,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,0BAA0B,CAAC;AACzC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAE1C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,8BAA8B,CAAC;AAC7C,cAAc,yBAAyB,CAAC;AACxC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,4BAA4B,CAAC;AAE3C,cAAc,oBAAoB,CAAC;AAEnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wCAAwC,CAAC;AACvD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,qBAAqB,CAAC;AAEpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAEtC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,iBAAiB,CAAC"}
@@ -1,37 +1,35 @@
1
1
  import { ClickAwayListener as o, isEventWithinElement as t } from "./click_away_listener.js";
2
2
  import { FocusRedirect as a } from "./focus_redirect.js";
3
- import { ScrollAwayListener as p } from "./scroll_away_listener.js";
3
+ import { ScrollAwayListener as x } from "./scroll_away_listener.js";
4
4
  import { useDraggable as s } from "./dnd/hooks/use_draggable.js";
5
5
  import { makeContextHook as i } from "./hooks/make_context_hook.js";
6
6
  import { useForkRef as l } from "./hooks/use_fork_ref.js";
7
- import { useMediaQuery as d } from "./hooks/use_media_query.js";
8
- import { TriggerConfig as D, useResizeObserver as R } from "./hooks/use_resize_observer.js";
9
- import { defaultValue as y } from "./default_value.js";
10
- import { CalendarDatesGenerator as b } from "./calendar/calendar_dates_generator.js";
11
- import { getDaysOfWeek as v } from "./calendar/get_days_of_week.js";
12
- import { getMonthsOfYear as O } from "./calendar/get_months_of_year.js";
7
+ import { TriggerConfig as d, useResizeObserver as k } from "./hooks/use_resize_observer.js";
8
+ import { useMediaQuery as c } from "./hooks/use_media_query.js";
9
+ import { defaultValue as C } from "./default_value.js";
10
+ import { CalendarDatesGenerator as h } from "./calendar/calendar_dates_generator.js";
11
+ import { getDaysOfWeek as O } from "./calendar/get_days_of_week.js";
12
+ import { getMonthsOfYear as v } from "./calendar/get_months_of_year.js";
13
13
  import { Month as A } from "./calendar/month.js";
14
- import { ResponsiveRenderer as F } from "./responsive/responsive_renderer.js";
15
- import { Draggable as L } from "./dnd/draggable/draggable.js";
16
- import { DragHandle as z } from "./dnd/handle.js";
14
+ import { Draggable as F } from "./dnd/draggable/draggable.js";
15
+ import { DragHandle as L } from "./dnd/handle.js";
17
16
  export {
18
- b as CalendarDatesGenerator,
17
+ h as CalendarDatesGenerator,
19
18
  o as ClickAwayListener,
20
- z as DragHandle,
21
- L as Draggable,
19
+ L as DragHandle,
20
+ F as Draggable,
22
21
  a as FocusRedirect,
23
22
  A as Month,
24
- F as ResponsiveRenderer,
25
- p as ScrollAwayListener,
26
- D as TriggerConfig,
27
- y as defaultValue,
28
- v as getDaysOfWeek,
29
- O as getMonthsOfYear,
23
+ x as ScrollAwayListener,
24
+ d as TriggerConfig,
25
+ C as defaultValue,
26
+ O as getDaysOfWeek,
27
+ v as getMonthsOfYear,
30
28
  t as isEventWithinElement,
31
29
  i as makeContextHook,
32
30
  s as useDraggable,
33
31
  l as useForkRef,
34
- d as useMediaQuery,
35
- R as useResizeObserver
32
+ c as useMediaQuery,
33
+ k as useResizeObserver
36
34
  };
37
35
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tcn/ui",
3
- "version": "0.8.1",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "description": "",
6
6
  "author": "TCN",
@@ -15,6 +15,8 @@ export { UtilityBar, type UtilityBarProps } from './utility_bar/utility_bar.js';
15
15
  export { Row } from './row/row.js';
16
16
  export { Section } from './section/section.js';
17
17
  export { Heading, type HeadingOwnProps } from './section/heading.js';
18
+ export { Responsive, type ResponsiveProps } from './responsive/responsive.js';
19
+ export { Breakpoint, type BreakpointProps } from './responsive/breakpoint.js';
18
20
 
19
21
  export { TTable, THead, TBody, TFoot, TR, TH, TD } from './table/table.js';
20
22
 
@@ -0,0 +1,29 @@
1
+ export interface BreakpointProps {
2
+ from?: number | string;
3
+ to?: number | string;
4
+ children: React.ReactNode;
5
+ }
6
+
7
+ export interface InternalBreakpointProps extends BreakpointProps {
8
+ width: number;
9
+ }
10
+
11
+ function toNumber(value: number | string) {
12
+ if (typeof value === 'number') {
13
+ return value;
14
+ }
15
+
16
+ return parseFloat(value);
17
+ }
18
+
19
+ export function Breakpoint(_: BreakpointProps) {
20
+ return null;
21
+ }
22
+
23
+ export function InternalBreakpoint(props: InternalBreakpointProps) {
24
+ const from = toNumber(props.from ?? 0);
25
+ const to = toNumber(props.to ?? Infinity);
26
+ const isWithinRange = props.width >= from && props.width < to;
27
+
28
+ return isWithinRange ? props.children : null;
29
+ }
@@ -0,0 +1,37 @@
1
+ import { HStack } from '../../stacks/h_stack.js';
2
+ import { Breakpoint } from './breakpoint.js';
3
+ import { Responsive } from './responsive.js';
4
+
5
+ export default {
6
+ title: 'Layouts/Responsive',
7
+ component: Responsive,
8
+ tags: ['autodocs'],
9
+ };
10
+
11
+ export function Container() {
12
+ return (
13
+ <HStack width="100%" hAlign="center">
14
+ <Responsive>
15
+ <Breakpoint to={200}>Small</Breakpoint>
16
+ <Breakpoint from={200} to={800}>
17
+ Medium
18
+ </Breakpoint>
19
+ <Breakpoint from={800}>Large</Breakpoint>
20
+ </Responsive>
21
+ </HStack>
22
+ );
23
+ }
24
+
25
+ export function Viewport() {
26
+ return (
27
+ <HStack width="100%" hAlign="center">
28
+ <Responsive on="viewport">
29
+ <Breakpoint to={200}>Small</Breakpoint>
30
+ <Breakpoint from={200} to={800}>
31
+ Medium
32
+ </Breakpoint>
33
+ <Breakpoint from={800}>Large</Breakpoint>
34
+ </Responsive>
35
+ </HStack>
36
+ );
37
+ }
@@ -0,0 +1,18 @@
1
+ import type { BreakpointProps } from './breakpoint.js';
2
+ import { ResponsiveContainer } from './responsive_container.js';
3
+ import { ResponsiveViewport } from './responsive_viewport.js';
4
+
5
+ export interface ResponsiveProps {
6
+ on?: 'viewport' | 'container';
7
+ children?: React.ReactElement<BreakpointProps>[] | React.ReactElement<BreakpointProps>;
8
+ }
9
+
10
+ export function Responsive(props: ResponsiveProps) {
11
+ const { on = 'container', children } = props;
12
+
13
+ if (on === 'viewport') {
14
+ return <ResponsiveViewport>{children}</ResponsiveViewport>;
15
+ }
16
+
17
+ return <ResponsiveContainer>{children}</ResponsiveContainer>;
18
+ }
@@ -0,0 +1,51 @@
1
+ import React, { useLayoutEffect, useState } from 'react';
2
+ import { useForkRef } from '../../utils/hooks/use_fork_ref.js';
3
+ import { useResizeObserver } from '../../utils/hooks/use_resize_observer.js';
4
+ import { InternalBreakpoint, BreakpointProps } from './breakpoint.js';
5
+
6
+ export interface ResponsiveContainerProps {
7
+ children?: React.ReactElement<BreakpointProps>[] | React.ReactElement<BreakpointProps>;
8
+ }
9
+
10
+ export function ResponsiveContainer(props: ResponsiveContainerProps) {
11
+ const [parent, setParent] = useState<Element | null>(null);
12
+ const [width, setWidth] = useState(0);
13
+
14
+ const resizeRef = useResizeObserver(width => {
15
+ setWidth(width);
16
+ });
17
+
18
+ const forkedRef = useForkRef((element: any) => {
19
+ if (element == null || element.parentElement == null) {
20
+ return;
21
+ }
22
+ resizeRef(element.parentElement);
23
+ setParent(element.parentElement);
24
+ });
25
+
26
+ const hiddenChild = (
27
+ <div
28
+ ref={forkedRef}
29
+ style={{
30
+ display: 'none',
31
+ }}
32
+ ></div>
33
+ );
34
+
35
+ const internalBreakpoints = React.Children.toArray(props.children).map((child: any) => {
36
+ return <InternalBreakpoint key={child.key} {...child.props} width={width} />;
37
+ });
38
+
39
+ useLayoutEffect(() => {
40
+ return () => {
41
+ setParent(null);
42
+ };
43
+ }, []);
44
+
45
+ return (
46
+ <>
47
+ {parent == null ? hiddenChild : null}
48
+ {internalBreakpoints}
49
+ </>
50
+ );
51
+ }
@@ -0,0 +1,17 @@
1
+ import React from 'react';
2
+ import { InternalBreakpoint, BreakpointProps } from './breakpoint.js';
3
+ import { useMediaQuery } from '../../utils/hooks/use_media_query.js';
4
+
5
+ export interface ResponsiveViewportProps {
6
+ children?: React.ReactElement<BreakpointProps>[] | React.ReactElement<BreakpointProps>;
7
+ }
8
+
9
+ export function ResponsiveViewport(props: ResponsiveViewportProps) {
10
+ const { width } = useMediaQuery();
11
+
12
+ const internalBreakpoints = React.Children.toArray(props.children).map((child: any) => {
13
+ return <InternalBreakpoint key={child.key} {...child.props} width={width} />;
14
+ });
15
+
16
+ return <>{internalBreakpoints}</>;
17
+ }
@@ -20,22 +20,25 @@ export interface BodyTextOwnProps {
20
20
 
21
21
  export type BodyTextProps = WithDetailedHTMLProps<BodyTextOwnProps, 'div'>;
22
22
 
23
- export function BodyText({
24
- size = 'md',
25
- emphasis = 'normal',
26
- hierarchy = 'primary',
27
- color,
28
- children,
29
- className,
30
- style = {},
31
- padStart,
32
- padEnd,
33
- padBottom,
34
- padTop,
35
- pad,
36
- selectable = true,
37
- breakWords = false,
38
- }: BodyTextProps) {
23
+ export const BodyText = React.forwardRef<HTMLDivElement, BodyTextProps>(function (
24
+ {
25
+ size = 'md',
26
+ emphasis = 'normal',
27
+ hierarchy = 'primary',
28
+ color,
29
+ children,
30
+ className,
31
+ style = {},
32
+ padStart,
33
+ padEnd,
34
+ padBottom,
35
+ padTop,
36
+ pad,
37
+ selectable = true,
38
+ breakWords = false,
39
+ }: BodyTextProps,
40
+ ref
41
+ ) {
39
42
  if (pad) {
40
43
  style.padding = pad;
41
44
  }
@@ -62,6 +65,7 @@ export function BodyText({
62
65
 
63
66
  return (
64
67
  <div
68
+ ref={ref}
65
69
  data-hierarchy={hierarchy}
66
70
  data-emphasis={emphasis}
67
71
  data-selectable={selectable}
@@ -73,4 +77,4 @@ export function BodyText({
73
77
  {children}
74
78
  </div>
75
79
  );
76
- }
80
+ });