@clubmed/trident-ui 1.0.0-alpha.43 → 1.0.0-alpha.45
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +14 -0
- package/assets/style.css +1 -1
- package/atoms/Icons/Icon.js +6 -6
- package/fonts/Actions/tui-actions.css +6 -6
- package/fonts/Actions/tui-actions.eot +0 -0
- package/fonts/Actions/tui-actions.less +6 -6
- package/fonts/Actions/tui-actions.module.less +6 -6
- package/fonts/Actions/tui-actions.scss +6 -6
- package/fonts/Actions/tui-actions.styl +6 -6
- package/fonts/Actions/tui-actions.ttf +0 -0
- package/fonts/Actions/tui-actions.woff +0 -0
- package/fonts/Actions/tui-actions.woff2 +0 -0
- package/fonts/Activities/tui-activities.css +6 -6
- package/fonts/Activities/tui-activities.eot +0 -0
- package/fonts/Activities/tui-activities.less +6 -6
- package/fonts/Activities/tui-activities.module.less +6 -6
- package/fonts/Activities/tui-activities.scss +6 -6
- package/fonts/Activities/tui-activities.styl +6 -6
- package/fonts/Activities/tui-activities.ttf +0 -0
- package/fonts/Activities/tui-activities.woff +0 -0
- package/fonts/Activities/tui-activities.woff2 +0 -0
- package/fonts/Brand/tui-brand.css +6 -6
- package/fonts/Brand/tui-brand.eot +0 -0
- package/fonts/Brand/tui-brand.less +6 -6
- package/fonts/Brand/tui-brand.module.less +6 -6
- package/fonts/Brand/tui-brand.scss +6 -6
- package/fonts/Brand/tui-brand.styl +6 -6
- package/fonts/Brand/tui-brand.ttf +0 -0
- package/fonts/Brand/tui-brand.woff +0 -0
- package/fonts/Brand/tui-brand.woff2 +0 -0
- package/fonts/Covid/tui-covid.css +6 -6
- package/fonts/Covid/tui-covid.eot +0 -0
- package/fonts/Covid/tui-covid.less +6 -6
- package/fonts/Covid/tui-covid.module.less +6 -6
- package/fonts/Covid/tui-covid.scss +6 -6
- package/fonts/Covid/tui-covid.styl +6 -6
- package/fonts/Covid/tui-covid.ttf +0 -0
- package/fonts/Covid/tui-covid.woff +0 -0
- package/fonts/Covid/tui-covid.woff2 +0 -0
- package/fonts/Food/tui-food.css +6 -6
- package/fonts/Food/tui-food.eot +0 -0
- package/fonts/Food/tui-food.less +6 -6
- package/fonts/Food/tui-food.module.less +6 -6
- package/fonts/Food/tui-food.scss +6 -6
- package/fonts/Food/tui-food.styl +6 -6
- package/fonts/Food/tui-food.ttf +0 -0
- package/fonts/Food/tui-food.woff +0 -0
- package/fonts/Food/tui-food.woff2 +0 -0
- package/fonts/HappyToCare/tui-happy-to-care.css +6 -6
- package/fonts/HappyToCare/tui-happy-to-care.eot +0 -0
- package/fonts/HappyToCare/tui-happy-to-care.less +6 -6
- package/fonts/HappyToCare/tui-happy-to-care.module.less +6 -6
- package/fonts/HappyToCare/tui-happy-to-care.scss +6 -6
- package/fonts/HappyToCare/tui-happy-to-care.styl +6 -6
- package/fonts/HappyToCare/tui-happy-to-care.ttf +0 -0
- package/fonts/HappyToCare/tui-happy-to-care.woff +0 -0
- package/fonts/HappyToCare/tui-happy-to-care.woff2 +0 -0
- package/fonts/Places/tui-places.css +6 -6
- package/fonts/Places/tui-places.eot +0 -0
- package/fonts/Places/tui-places.less +6 -6
- package/fonts/Places/tui-places.module.less +6 -6
- package/fonts/Places/tui-places.scss +6 -6
- package/fonts/Places/tui-places.styl +6 -6
- package/fonts/Places/tui-places.ttf +0 -0
- package/fonts/Places/tui-places.woff +0 -0
- package/fonts/Places/tui-places.woff2 +0 -0
- package/fonts/Room/tui-room.css +6 -6
- package/fonts/Room/tui-room.eot +0 -0
- package/fonts/Room/tui-room.less +6 -6
- package/fonts/Room/tui-room.module.less +6 -6
- package/fonts/Room/tui-room.scss +6 -6
- package/fonts/Room/tui-room.styl +6 -6
- package/fonts/Room/tui-room.ttf +0 -0
- package/fonts/Room/tui-room.woff +0 -0
- package/fonts/Room/tui-room.woff2 +0 -0
- package/fonts/Services/tui-services.css +6 -6
- package/fonts/Services/tui-services.eot +0 -0
- package/fonts/Services/tui-services.less +6 -6
- package/fonts/Services/tui-services.module.less +6 -6
- package/fonts/Services/tui-services.scss +6 -6
- package/fonts/Services/tui-services.styl +6 -6
- package/fonts/Services/tui-services.ttf +0 -0
- package/fonts/Services/tui-services.woff +0 -0
- package/fonts/Services/tui-services.woff2 +0 -0
- package/fonts/Socials/tui-socials.css +6 -6
- package/fonts/Socials/tui-socials.eot +0 -0
- package/fonts/Socials/tui-socials.less +6 -6
- package/fonts/Socials/tui-socials.module.less +6 -6
- package/fonts/Socials/tui-socials.scss +6 -6
- package/fonts/Socials/tui-socials.styl +6 -6
- package/fonts/Socials/tui-socials.ttf +0 -0
- package/fonts/Socials/tui-socials.woff +0 -0
- package/fonts/Socials/tui-socials.woff2 +0 -0
- package/fonts/Transports/tui-transports.css +6 -6
- package/fonts/Transports/tui-transports.eot +0 -0
- package/fonts/Transports/tui-transports.less +6 -6
- package/fonts/Transports/tui-transports.module.less +6 -6
- package/fonts/Transports/tui-transports.scss +6 -6
- package/fonts/Transports/tui-transports.styl +6 -6
- package/fonts/Transports/tui-transports.ttf +0 -0
- package/fonts/Transports/tui-transports.woff +0 -0
- package/fonts/Transports/tui-transports.woff2 +0 -0
- package/fonts/Utilities/tui-utilities.css +6 -6
- package/fonts/Utilities/tui-utilities.eot +0 -0
- package/fonts/Utilities/tui-utilities.less +6 -6
- package/fonts/Utilities/tui-utilities.module.less +6 -6
- package/fonts/Utilities/tui-utilities.scss +6 -6
- package/fonts/Utilities/tui-utilities.styl +6 -6
- package/fonts/Utilities/tui-utilities.ttf +0 -0
- package/fonts/Utilities/tui-utilities.woff +0 -0
- package/fonts/Utilities/tui-utilities.woff2 +0 -0
- package/hooks/__mocks__/useSafeBoop.d.ts +4 -0
- package/hooks/__mocks__/useSafeBoop.js +10 -0
- package/hooks/keyboard.constants.d.ts +38 -0
- package/hooks/keyboard.constants.js +6 -0
- package/hooks/useKeyboardControls.d.ts +12 -0
- package/hooks/useKeyboardControls.js +29 -0
- package/hooks/useSafeBoop.d.ts +5 -0
- package/hooks/useSafeBoop.js +67 -0
- package/molecules/Tabs/Body.d.ts +6 -0
- package/molecules/Tabs/Body.js +6 -0
- package/molecules/Tabs/Header.d.ts +10 -0
- package/molecules/Tabs/Header.js +60 -0
- package/molecules/Tabs/Heading.d.ts +33 -0
- package/molecules/Tabs/Heading.js +100 -0
- package/molecules/Tabs/Panel.d.ts +17 -0
- package/molecules/Tabs/Panel.js +58 -0
- package/molecules/Tabs/Tabs.d.ts +12 -0
- package/molecules/Tabs/Tabs.js +21 -0
- package/molecules/Tabs/context/TabControl.d.ts +50 -0
- package/molecules/Tabs/context/TabControl.js +82 -0
- package/molecules/Tabs/hooks/tabControl.d.ts +33 -0
- package/molecules/Tabs/hooks/tabControl.js +30 -0
- package/molecules/Tabs/theme.d.ts +10 -0
- package/molecules/Tabs/theme.js +23 -0
- package/package.json +1 -1
@@ -0,0 +1,58 @@
|
|
1
|
+
import { jsx as p } from "react/jsx-runtime";
|
2
|
+
import { c as d } from "../../index-Cu0xwYjD.js";
|
3
|
+
import { useRef as f, useEffect as l } from "react";
|
4
|
+
import { a as b, b as u } from "../../react-spring_web.modern-BPtZcx1z.js";
|
5
|
+
import { useActiveTab as y } from "./hooks/tabControl.js";
|
6
|
+
const r = {
|
7
|
+
opacity: 0,
|
8
|
+
pointerEvents: "none",
|
9
|
+
display: "none"
|
10
|
+
}, n = {
|
11
|
+
opacity: 1,
|
12
|
+
pointerEvents: "auto",
|
13
|
+
display: "block"
|
14
|
+
}, R = ({
|
15
|
+
value: a,
|
16
|
+
className: i,
|
17
|
+
onSelect: s,
|
18
|
+
children: c
|
19
|
+
}) => {
|
20
|
+
const o = f(!1), t = y() === a, [m, e] = b(() => ({
|
21
|
+
from: t ? n : r
|
22
|
+
}));
|
23
|
+
return l(() => {
|
24
|
+
if (!o.current) {
|
25
|
+
o.current = !0;
|
26
|
+
return;
|
27
|
+
}
|
28
|
+
e.start({
|
29
|
+
to: {
|
30
|
+
...t ? n : r,
|
31
|
+
display: "block"
|
32
|
+
},
|
33
|
+
onRest: () => {
|
34
|
+
e.start({
|
35
|
+
to: { display: t ? "block" : "none" },
|
36
|
+
immediate: !0
|
37
|
+
});
|
38
|
+
}
|
39
|
+
}), t && (s == null || s({ value: a }));
|
40
|
+
}, [t, e, a, s]), /* @__PURE__ */ p(
|
41
|
+
u.div,
|
42
|
+
{
|
43
|
+
"data-name": "Tab",
|
44
|
+
style: m,
|
45
|
+
role: "tabpanel",
|
46
|
+
"aria-hidden": !t,
|
47
|
+
tabIndex: t ? 0 : -1,
|
48
|
+
className: d("col-start-1 col-end-1 row-start-1 row-end-1", i, {
|
49
|
+
"z-0": !t,
|
50
|
+
"z-1": t
|
51
|
+
}),
|
52
|
+
children: c
|
53
|
+
}
|
54
|
+
);
|
55
|
+
};
|
56
|
+
export {
|
57
|
+
R as TabsPanel
|
58
|
+
};
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { ComponentProps, FunctionComponent, PropsWithChildren } from 'react';
|
2
|
+
import { TabsProvider } from './context/TabControl';
|
3
|
+
type ProviderProps = ComponentProps<typeof TabsProvider>;
|
4
|
+
interface Props extends ProviderProps {
|
5
|
+
className?: string;
|
6
|
+
/**
|
7
|
+
* Shrink the spacing between tabs and panels
|
8
|
+
*/
|
9
|
+
compacted?: boolean;
|
10
|
+
}
|
11
|
+
export declare const Tabs: FunctionComponent<PropsWithChildren<Props>>;
|
12
|
+
export {};
|
@@ -0,0 +1,21 @@
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
2
|
+
import { c as t } from "../../index-Cu0xwYjD.js";
|
3
|
+
import { TabsProvider as c } from "./context/TabControl.js";
|
4
|
+
const p = ({
|
5
|
+
className: s,
|
6
|
+
compacted: r = !1,
|
7
|
+
selected: e,
|
8
|
+
min: m,
|
9
|
+
max: o,
|
10
|
+
children: l
|
11
|
+
}) => /* @__PURE__ */ a(
|
12
|
+
"div",
|
13
|
+
{
|
14
|
+
className: t("flex flex-col", s, { "sm:gap-y-20": !r }),
|
15
|
+
"data-name": "Tabs",
|
16
|
+
children: /* @__PURE__ */ a(c, { selected: e, min: m, max: o, children: l })
|
17
|
+
}
|
18
|
+
);
|
19
|
+
export {
|
20
|
+
p as Tabs
|
21
|
+
};
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import { Dispatch, type FunctionComponent, type PropsWithChildren, type RefObject } from 'react';
|
2
|
+
type TabsAction = {
|
3
|
+
type: 'update';
|
4
|
+
payload: number;
|
5
|
+
} | {
|
6
|
+
type: 'next';
|
7
|
+
} | {
|
8
|
+
type: 'previous';
|
9
|
+
} | {
|
10
|
+
type: 'start';
|
11
|
+
} | {
|
12
|
+
type: 'end';
|
13
|
+
};
|
14
|
+
type ControlAction<T extends HTMLElement = HTMLElement> = {
|
15
|
+
type: 'register';
|
16
|
+
payload: {
|
17
|
+
value: number;
|
18
|
+
ref: RefObject<T>;
|
19
|
+
};
|
20
|
+
} | {
|
21
|
+
type: 'unregister';
|
22
|
+
payload: {
|
23
|
+
value: number;
|
24
|
+
};
|
25
|
+
};
|
26
|
+
interface ActiveTab {
|
27
|
+
value: number;
|
28
|
+
}
|
29
|
+
export declare const ActiveTabContext: import("react").Context<ActiveTab>;
|
30
|
+
interface TabRefs<T extends HTMLElement = HTMLElement> {
|
31
|
+
refs: Map<number, RefObject<T>>;
|
32
|
+
}
|
33
|
+
export declare const TabRefsContext: import("react").Context<TabRefs<HTMLElement>>;
|
34
|
+
interface TabControl<T extends HTMLElement = HTMLElement> {
|
35
|
+
dispatch: Dispatch<TabsAction>;
|
36
|
+
register: (value: Extract<ControlAction<T>, {
|
37
|
+
type: 'register';
|
38
|
+
}>['payload']['value'], ref: Extract<ControlAction<T>, {
|
39
|
+
type: 'register';
|
40
|
+
}>['payload']['ref']) => void;
|
41
|
+
unregister: (value: number) => void;
|
42
|
+
}
|
43
|
+
export declare const TabControlContext: import("react").Context<TabControl<HTMLElement>>;
|
44
|
+
interface ProviderProps {
|
45
|
+
selected?: number;
|
46
|
+
min?: number;
|
47
|
+
max: number;
|
48
|
+
}
|
49
|
+
export declare const TabsProvider: FunctionComponent<PropsWithChildren<ProviderProps>>;
|
50
|
+
export {};
|
@@ -0,0 +1,82 @@
|
|
1
|
+
import { jsx as l } from "react/jsx-runtime";
|
2
|
+
import { createContext as c, useReducer as v, useMemo as u, useCallback as x } from "react";
|
3
|
+
const C = (e) => {
|
4
|
+
const r = Math.max(Math.min(e.min, e.max), 0), t = Math.max(Math.min(e.max, 1 / 0), r);
|
5
|
+
return {
|
6
|
+
min: r,
|
7
|
+
max: t,
|
8
|
+
clamp: (n) => Math.max(Math.min(n, t), r)
|
9
|
+
};
|
10
|
+
}, g = (e) => {
|
11
|
+
const { clamp: r } = C(e);
|
12
|
+
return r(e.value);
|
13
|
+
}, P = (e) => {
|
14
|
+
const { min: r, max: t, clamp: n } = C(e);
|
15
|
+
return (a, o) => {
|
16
|
+
switch (o.type) {
|
17
|
+
case "update":
|
18
|
+
return n(o.payload);
|
19
|
+
case "next":
|
20
|
+
return a + 1 <= t ? a + 1 : r;
|
21
|
+
case "previous":
|
22
|
+
return a - 1 >= r ? a - 1 : t;
|
23
|
+
case "start":
|
24
|
+
return r;
|
25
|
+
case "end":
|
26
|
+
return t;
|
27
|
+
}
|
28
|
+
};
|
29
|
+
}, R = (e, r) => {
|
30
|
+
switch (r.type) {
|
31
|
+
case "register":
|
32
|
+
return new Map(e.set(r.payload.value, r.payload.ref));
|
33
|
+
case "unregister":
|
34
|
+
return e.delete(r.payload.value) ? new Map(e) : e;
|
35
|
+
}
|
36
|
+
}, h = c({ value: 0 });
|
37
|
+
h.displayName = "ActiveTabContext";
|
38
|
+
const y = c({
|
39
|
+
refs: /* @__PURE__ */ new Map()
|
40
|
+
});
|
41
|
+
y.displayName = "TabRefsContext";
|
42
|
+
const b = c({
|
43
|
+
dispatch: () => {
|
44
|
+
console.warn("Tab Controller Context dispatch used outside of Provider");
|
45
|
+
},
|
46
|
+
register: () => {
|
47
|
+
console.warn("Tab Controller Context register used outside of Provider");
|
48
|
+
},
|
49
|
+
unregister: () => {
|
50
|
+
console.warn("Tab Controller Context unregister used outside of Provider");
|
51
|
+
}
|
52
|
+
});
|
53
|
+
b.displayName = "TabControlContext";
|
54
|
+
const A = ({
|
55
|
+
min: e = 0,
|
56
|
+
max: r,
|
57
|
+
selected: t = e,
|
58
|
+
children: n
|
59
|
+
}) => {
|
60
|
+
const [a, o] = v(
|
61
|
+
P({ min: e, max: r }),
|
62
|
+
{ value: t, min: e, max: r },
|
63
|
+
g
|
64
|
+
), [i, d] = v(R, /* @__PURE__ */ new Map()), M = u(() => ({ value: a }), [a]), f = u(() => ({ refs: i }), [i]), p = x(
|
65
|
+
(s, w) => {
|
66
|
+
d({ type: "register", payload: { value: s, ref: w } });
|
67
|
+
},
|
68
|
+
[]
|
69
|
+
), m = x(
|
70
|
+
(s) => {
|
71
|
+
d({ type: "unregister", payload: { value: s } });
|
72
|
+
},
|
73
|
+
[]
|
74
|
+
), T = u(() => ({ dispatch: o, register: p, unregister: m }), [p, m]);
|
75
|
+
return /* @__PURE__ */ l(h.Provider, { value: M, children: /* @__PURE__ */ l(y.Provider, { value: f, children: /* @__PURE__ */ l(b.Provider, { value: T, children: n }) }) });
|
76
|
+
};
|
77
|
+
export {
|
78
|
+
h as ActiveTabContext,
|
79
|
+
b as TabControlContext,
|
80
|
+
y as TabRefsContext,
|
81
|
+
A as TabsProvider
|
82
|
+
};
|
@@ -0,0 +1,33 @@
|
|
1
|
+
import { type RefObject } from 'react';
|
2
|
+
export declare const useActiveTab: () => number;
|
3
|
+
export declare const useTabDispatch: () => import("react").Dispatch<{
|
4
|
+
type: "update";
|
5
|
+
payload: number;
|
6
|
+
} | {
|
7
|
+
type: "next";
|
8
|
+
} | {
|
9
|
+
type: "previous";
|
10
|
+
} | {
|
11
|
+
type: "start";
|
12
|
+
} | {
|
13
|
+
type: "end";
|
14
|
+
}>;
|
15
|
+
interface Props<T extends HTMLElement> {
|
16
|
+
value: number;
|
17
|
+
ref: RefObject<T>;
|
18
|
+
}
|
19
|
+
export declare const useRegisterTabControl: <T extends HTMLElement>({ value, ref }: Props<T>) => import("react").Dispatch<{
|
20
|
+
type: "update";
|
21
|
+
payload: number;
|
22
|
+
} | {
|
23
|
+
type: "next";
|
24
|
+
} | {
|
25
|
+
type: "previous";
|
26
|
+
} | {
|
27
|
+
type: "start";
|
28
|
+
} | {
|
29
|
+
type: "end";
|
30
|
+
}>;
|
31
|
+
export declare const useTabControl: () => Map<number, RefObject<HTMLElement>>;
|
32
|
+
export declare const useActiveTabControl: () => readonly [number, RefObject<HTMLElement> | undefined];
|
33
|
+
export {};
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import { useContext as e, useEffect as a } from "react";
|
2
|
+
import { ActiveTabContext as s, TabControlContext as c, TabRefsContext as u } from "../context/TabControl.js";
|
3
|
+
const T = () => {
|
4
|
+
const { value: t } = e(s);
|
5
|
+
return t;
|
6
|
+
}, f = () => {
|
7
|
+
const { dispatch: t } = e(c);
|
8
|
+
return t;
|
9
|
+
}, l = ({ value: t, ref: r }) => {
|
10
|
+
const { dispatch: i, register: n, unregister: o } = e(c);
|
11
|
+
return a(() => {
|
12
|
+
if (r.current != null)
|
13
|
+
return n(t, r), () => {
|
14
|
+
o(t);
|
15
|
+
};
|
16
|
+
}, [t, r, n, o]), i;
|
17
|
+
}, p = () => {
|
18
|
+
const { refs: t } = e(u);
|
19
|
+
return t;
|
20
|
+
}, x = () => {
|
21
|
+
const { value: t } = e(s), { refs: r } = e(u);
|
22
|
+
return [t, r.get(t)];
|
23
|
+
};
|
24
|
+
export {
|
25
|
+
T as useActiveTab,
|
26
|
+
x as useActiveTabControl,
|
27
|
+
l as useRegisterTabControl,
|
28
|
+
p as useTabControl,
|
29
|
+
f as useTabDispatch
|
30
|
+
};
|
@@ -0,0 +1,10 @@
|
|
1
|
+
export type Theme = 'yellow' | 'black';
|
2
|
+
export declare const getTheme: (theme: Theme) => {
|
3
|
+
readonly bgColor: "bg-saffron";
|
4
|
+
readonly textColor: "text-black";
|
5
|
+
readonly textColorActive: "text-black";
|
6
|
+
} | {
|
7
|
+
readonly bgColor: "bg-black";
|
8
|
+
readonly textColor: "text-black";
|
9
|
+
readonly textColorActive: "text-white";
|
10
|
+
};
|
@@ -0,0 +1,23 @@
|
|
1
|
+
const t = {
|
2
|
+
YELLOW: {
|
3
|
+
bgColor: "bg-saffron",
|
4
|
+
textColor: "text-black",
|
5
|
+
textColorActive: "text-black"
|
6
|
+
},
|
7
|
+
BLACK: {
|
8
|
+
bgColor: "bg-black",
|
9
|
+
textColor: "text-black",
|
10
|
+
textColorActive: "text-white"
|
11
|
+
}
|
12
|
+
}, o = (e) => {
|
13
|
+
switch (e) {
|
14
|
+
case "black":
|
15
|
+
return t.BLACK;
|
16
|
+
case "yellow":
|
17
|
+
default:
|
18
|
+
return t.YELLOW;
|
19
|
+
}
|
20
|
+
};
|
21
|
+
export {
|
22
|
+
o as getTheme
|
23
|
+
};
|