@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.
- package/dist/feedback/progress/progress_bar.js +13 -13
- package/dist/form/field/common/field_description.js +7 -8
- package/dist/form/field/common/field_description.js.map +1 -1
- package/dist/form/field/common/field_error.js +6 -6
- package/dist/form/field/common/field_label.js +7 -8
- package/dist/form/field/common/field_label.js.map +1 -1
- package/dist/form/field_set/field_set.js +7 -7
- package/dist/inputs/date_picker/date_picker_date.js +6 -6
- package/dist/inputs/date_picker/date_picker_day.js +6 -6
- package/dist/inputs/date_picker/date_picker_time_selector.js +5 -5
- package/dist/inputs/date_picker/date_picker_year_selector.js +5 -5
- package/dist/inputs/suggestions/suggestion_list.js +6 -6
- package/dist/layouts/index.d.ts +2 -0
- package/dist/layouts/index.d.ts.map +1 -1
- package/dist/layouts/index.js +46 -42
- package/dist/layouts/index.js.map +1 -1
- package/dist/layouts/responsive/breakpoint.d.ts +11 -0
- package/dist/layouts/responsive/breakpoint.d.ts.map +1 -0
- package/dist/layouts/responsive/breakpoint.js +15 -0
- package/dist/layouts/responsive/breakpoint.js.map +1 -0
- package/dist/layouts/responsive/responsive.d.ts +7 -0
- package/dist/layouts/responsive/responsive.d.ts.map +1 -0
- package/dist/layouts/responsive/responsive.js +11 -0
- package/dist/layouts/responsive/responsive.js.map +1 -0
- package/dist/layouts/responsive/responsive_container.d.ts +7 -0
- package/dist/layouts/responsive/responsive_container.d.ts.map +1 -0
- package/dist/layouts/responsive/responsive_container.js +30 -0
- package/dist/layouts/responsive/responsive_container.js.map +1 -0
- package/dist/layouts/responsive/responsive_viewport.d.ts +7 -0
- package/dist/layouts/responsive/responsive_viewport.d.ts.map +1 -0
- package/dist/layouts/responsive/responsive_viewport.js +12 -0
- package/dist/layouts/responsive/responsive_viewport.js.map +1 -0
- package/dist/surfaces/confirm/confirm.js +5 -5
- package/dist/surfaces/pop_confirm/pop_confirm.js +3 -2
- package/dist/surfaces/pop_confirm/pop_confirm.js.map +1 -1
- package/dist/typography/body_text/body_text.d.ts +2 -1
- package/dist/typography/body_text/body_text.d.ts.map +1 -1
- package/dist/typography/body_text/body_text.js +24 -23
- package/dist/typography/body_text/body_text.js.map +1 -1
- package/dist/typography/callout/callout.d.ts +2 -1
- package/dist/typography/callout/callout.d.ts.map +1 -1
- package/dist/typography/callout/callout.js +28 -27
- package/dist/typography/callout/callout.js.map +1 -1
- package/dist/typography/caption/caption.d.ts +2 -1
- package/dist/typography/caption/caption.d.ts.map +1 -1
- package/dist/typography/caption/caption.js +18 -17
- package/dist/typography/caption/caption.js.map +1 -1
- package/dist/typography/footnote/footnote.d.ts +2 -1
- package/dist/typography/footnote/footnote.d.ts.map +1 -1
- package/dist/typography/footnote/footnote.js +25 -24
- package/dist/typography/footnote/footnote.js.map +1 -1
- package/dist/typography/headline/headline.d.ts +2 -1
- package/dist/typography/headline/headline.d.ts.map +1 -1
- package/dist/typography/headline/headline.js +36 -33
- package/dist/typography/headline/headline.js.map +1 -1
- package/dist/typography/subheadline/subheadline.d.ts +2 -1
- package/dist/typography/subheadline/subheadline.d.ts.map +1 -1
- package/dist/typography/subheadline/subheadline.js +35 -32
- package/dist/typography/subheadline/subheadline.js.map +1 -1
- package/dist/utils/dnd/context.d.ts.map +1 -1
- package/dist/utils/dnd/context.js +9 -7
- package/dist/utils/dnd/context.js.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.d.ts.map +1 -1
- package/dist/utils/dnd/hooks/use_drag_container.js +29 -15
- package/dist/utils/dnd/hooks/use_drag_container.js.map +1 -1
- package/dist/utils/dnd/types.d.ts +3 -4
- package/dist/utils/dnd/types.d.ts.map +1 -1
- package/dist/utils/hooks/use_media_query.d.ts +5 -8
- package/dist/utils/hooks/use_media_query.d.ts.map +1 -1
- package/dist/utils/hooks/use_media_query.js +10 -11
- package/dist/utils/hooks/use_media_query.js.map +1 -1
- package/dist/utils/index.d.ts +1 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +19 -21
- package/dist/utils/index.js.map +1 -1
- package/package.json +1 -1
- package/src/layouts/index.ts +2 -0
- package/src/layouts/responsive/breakpoint.tsx +29 -0
- package/src/layouts/responsive/responsive.stories.tsx +37 -0
- package/src/layouts/responsive/responsive.tsx +18 -0
- package/src/layouts/responsive/responsive_container.tsx +51 -0
- package/src/layouts/responsive/responsive_viewport.tsx +17 -0
- package/src/typography/body_text/body_text.tsx +21 -17
- package/src/typography/callout/callout.tsx +20 -16
- package/src/typography/caption/caption.tsx +20 -16
- package/src/typography/footnote/footnote.tsx +20 -16
- package/src/typography/headline/headline.tsx +60 -54
- package/src/typography/subheadline/subheadline.tsx +60 -54
- package/src/utils/dnd/__stories__/draggable.stories.tsx +34 -0
- package/src/utils/dnd/context.ts +1 -0
- package/src/utils/dnd/hooks/use_drag_container.ts +18 -1
- package/src/utils/dnd/types.ts +4 -1
- package/src/utils/hooks/use_media_query.ts +16 -27
- package/src/utils/index.ts +1 -3
- package/dist/body_text.module-h4XQE2pC.js +0 -5
- package/dist/body_text.module-h4XQE2pC.js.map +0 -1
- package/dist/callout.module-D8ECmxpO.js +0 -5
- package/dist/callout.module-D8ECmxpO.js.map +0 -1
- package/dist/caption.module-DDq0H4xZ.js +0 -5
- package/dist/caption.module-DDq0H4xZ.js.map +0 -1
- package/dist/footnote.module-DEyFuqOr.js +0 -5
- package/dist/footnote.module-DEyFuqOr.js.map +0 -1
- package/dist/headline.module-BiwHBtGf.js +0 -5
- package/dist/headline.module-BiwHBtGf.js.map +0 -1
- package/dist/subheadline.module-C-v7zMkQ.js +0 -5
- package/dist/subheadline.module-C-v7zMkQ.js.map +0 -1
- package/dist/utils/responsive/responsive_renderer.d.ts +0 -21
- package/dist/utils/responsive/responsive_renderer.d.ts.map +0 -1
- package/dist/utils/responsive/responsive_renderer.js +0 -12
- package/dist/utils/responsive/responsive_renderer.js.map +0 -1
- package/src/utils/responsive/responsive_renderer.stories.tsx +0 -77
- package/src/utils/responsive/responsive_renderer.tsx +0 -31
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as b } from "react/jsx-runtime";
|
|
2
|
+
import g from "react";
|
|
2
3
|
import { clsx as p } from "clsx";
|
|
3
|
-
import {
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
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
|
|
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;
|
|
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
|
|
2
|
-
const
|
|
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
|
-
|
|
8
|
+
position: { x: 0, y: 0 },
|
|
9
|
+
setPosition: () => {
|
|
10
|
+
}
|
|
11
|
+
}, r = n(t);
|
|
10
12
|
function i() {
|
|
11
|
-
const e = r
|
|
12
|
-
return e ===
|
|
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
|
-
|
|
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;
|
|
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,
|
|
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
|
|
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(
|
|
4
|
-
const [
|
|
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:
|
|
6
|
+
handles: u,
|
|
7
7
|
startDragCallback: () => {
|
|
8
|
-
|
|
8
|
+
l(!0);
|
|
9
9
|
},
|
|
10
|
-
dragCallback: (
|
|
11
|
-
|
|
12
|
-
x:
|
|
13
|
-
y:
|
|
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
|
-
|
|
17
|
+
l(!1), n.current = i;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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 {
|
|
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 {
|
|
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
|
-
|
|
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;
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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":"
|
|
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
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
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
|
|
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;"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -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,
|
|
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"}
|
package/dist/utils/index.js
CHANGED
|
@@ -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
|
|
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 {
|
|
8
|
-
import {
|
|
9
|
-
import { defaultValue as
|
|
10
|
-
import { CalendarDatesGenerator as
|
|
11
|
-
import { getDaysOfWeek as
|
|
12
|
-
import { getMonthsOfYear as
|
|
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 {
|
|
15
|
-
import {
|
|
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
|
-
|
|
17
|
+
h as CalendarDatesGenerator,
|
|
19
18
|
o as ClickAwayListener,
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
L as DragHandle,
|
|
20
|
+
F as Draggable,
|
|
22
21
|
a as FocusRedirect,
|
|
23
22
|
A as Month,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
v as
|
|
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
|
-
|
|
35
|
-
|
|
32
|
+
c as useMediaQuery,
|
|
33
|
+
k as useResizeObserver
|
|
36
34
|
};
|
|
37
35
|
//# sourceMappingURL=index.js.map
|
package/dist/utils/index.js.map
CHANGED
|
@@ -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
package/src/layouts/index.ts
CHANGED
|
@@ -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
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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
|
+
});
|