@strapi/design-system 1.7.5 → 1.7.7
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/BaseButton/BaseButton.cjs +3 -3
- package/dist/BaseButton/BaseButton.js +5 -5
- package/dist/CarouselInput/Carousel.cjs +6 -7
- package/dist/CarouselInput/Carousel.js +25 -79
- package/dist/CarouselInput/CarouselActions.cjs +1 -1
- package/dist/CarouselInput/CarouselActions.js +1 -14
- package/dist/CarouselInput/CarouselImage.cjs +3 -4
- package/dist/CarouselInput/CarouselImage.js +13 -23
- package/dist/CarouselInput/CarouselInput.cjs +1 -1
- package/dist/CarouselInput/CarouselInput.js +12 -75
- package/dist/CarouselInput/CarouselSlide.cjs +1 -3
- package/dist/CarouselInput/CarouselSlide.js +4 -29
- package/dist/Checkbox/Checkbox.cjs +3 -3
- package/dist/Checkbox/Checkbox.js +18 -40
- package/dist/Dialog/Dialog.cjs +5 -5
- package/dist/Dialog/Dialog.js +21 -49
- package/dist/Dialog/DialogBody.cjs +2 -2
- package/dist/Dialog/DialogBody.js +6 -19
- package/dist/Dialog/DialogFooter.cjs +2 -2
- package/dist/Dialog/DialogFooter.js +7 -21
- package/dist/EmptyStateLayout/story-assets/Illo.cjs +1 -1
- package/dist/EmptyStateLayout/story-assets/Illo.js +2 -70
- package/dist/ModalLayout/ModalBody.cjs +2 -2
- package/dist/ModalLayout/ModalBody.js +4 -5
- package/dist/ModalLayout/ModalContext.cjs +1 -1
- package/dist/ModalLayout/ModalContext.js +2 -1
- package/dist/ModalLayout/ModalFooter.cjs +2 -6
- package/dist/ModalLayout/ModalFooter.js +9 -26
- package/dist/ModalLayout/ModalHeader.cjs +2 -2
- package/dist/ModalLayout/ModalHeader.js +10 -22
- package/dist/ModalLayout/ModalLayout.cjs +3 -5
- package/dist/ModalLayout/ModalLayout.js +10 -30
- package/dist/NumberInput/NumberInput.cjs +2 -2
- package/dist/NumberInput/NumberInput.js +68 -168
- package/dist/Pagination/Pagination.cjs +1 -5
- package/dist/Pagination/Pagination.js +7 -21
- package/dist/Pagination/components.cjs +7 -10
- package/dist/Pagination/components.js +34 -81
- package/dist/Popover/Popover.cjs +3 -3
- package/dist/Popover/Popover.js +93 -48
- package/dist/ProgressBar/ProgressBar.cjs +5 -5
- package/dist/ProgressBar/ProgressBar.js +6 -37
- package/dist/Radio/Radio.cjs +1 -4
- package/dist/Radio/Radio.js +5 -18
- package/dist/Searchbar/SearchForm.cjs +1 -1
- package/dist/Searchbar/SearchForm.js +2 -3
- package/dist/Searchbar/Searchbar.cjs +10 -11
- package/dist/Searchbar/Searchbar.js +25 -54
- package/dist/Status/Status.cjs +6 -6
- package/dist/Status/Status.js +8 -46
- package/dist/Switch/Switch.cjs +5 -5
- package/dist/Switch/Switch.js +16 -52
- package/dist/Tabs/TabGroup.cjs +1 -1
- package/dist/Tabs/TabGroup.js +13 -37
- package/dist/Tabs/TabPanels.cjs +1 -1
- package/dist/Tabs/TabPanels.js +11 -22
- package/dist/Tabs/Tabs.cjs +2 -2
- package/dist/Tabs/Tabs.js +55 -110
- package/dist/Tabs/TabsContext.cjs +1 -1
- package/dist/Tabs/TabsContext.js +11 -4
- package/dist/Textarea/Textarea.cjs +14 -12
- package/dist/Textarea/Textarea.js +33 -55
- package/dist/ToggleCheckbox/ToggleCheckbox.cjs +8 -8
- package/dist/ToggleCheckbox/ToggleCheckbox.js +25 -121
- package/dist/ToggleInput/ToggleInput.cjs +3 -3
- package/dist/ToggleInput/ToggleInput.js +17 -70
- package/dist/Typography/Typography.cjs +1 -1
- package/dist/Typography/Typography.js +6 -6
- package/dist/hooks/useControllableState.cjs +1 -1
- package/dist/hooks/useControllableState.js +6 -6
- package/dist/themes/utils.cjs +2 -2
- package/dist/themes/utils.js +1 -1
- package/package.json +8 -5
- package/dist/Tabs/useTabsFocus.cjs +0 -1
- package/dist/Tabs/useTabsFocus.js +0 -17
- package/dist/Textarea/TextareaInput.cjs +0 -30
- package/dist/Textarea/TextareaInput.js +0 -65
package/dist/Switch/Switch.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { Flex as h } from "../Flex/Flex.js";
|
|
1
|
+
import { jsx as e, jsxs as s } from "react/jsx-runtime";
|
|
2
|
+
import h from "react";
|
|
3
|
+
import c from "styled-components";
|
|
4
|
+
import { Flex as u } from "../Flex/Flex.js";
|
|
6
5
|
import { Box as m } from "../Box/Box.js";
|
|
7
|
-
const
|
|
8
|
-
background: ${({ theme:
|
|
6
|
+
const t = c.div`
|
|
7
|
+
background: ${({ theme: r }) => r.colors.danger500};
|
|
9
8
|
border: none;
|
|
10
9
|
border-radius: 16px;
|
|
11
10
|
position: relative;
|
|
@@ -13,19 +12,19 @@ const n = l.div`
|
|
|
13
12
|
width: ${40 / 16}rem;
|
|
14
13
|
|
|
15
14
|
& span {
|
|
16
|
-
font-size: ${({ visibleLabels:
|
|
15
|
+
font-size: ${({ visibleLabels: r }) => r ? "1rem" : 0};
|
|
17
16
|
}
|
|
18
17
|
|
|
19
18
|
&:before {
|
|
20
19
|
content: '';
|
|
21
|
-
background: ${({ theme:
|
|
20
|
+
background: ${({ theme: r }) => r.colors.neutral0};
|
|
22
21
|
width: 1rem;
|
|
23
22
|
height: 1rem;
|
|
24
23
|
border-radius: 50%;
|
|
25
24
|
position: absolute;
|
|
26
25
|
transition: all 0.5s;
|
|
27
|
-
left: ${({ theme:
|
|
28
|
-
top: ${({ theme:
|
|
26
|
+
left: ${({ theme: r }) => r.spaces[1]};
|
|
27
|
+
top: ${({ theme: r }) => r.spaces[1]};
|
|
29
28
|
}
|
|
30
29
|
|
|
31
30
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -33,54 +32,19 @@ const n = l.div`
|
|
|
33
32
|
transition: none;
|
|
34
33
|
}
|
|
35
34
|
}
|
|
36
|
-
`,
|
|
35
|
+
`, f = c.button`
|
|
37
36
|
background: transparent;
|
|
38
37
|
padding: 0;
|
|
39
38
|
border: none;
|
|
40
39
|
|
|
41
|
-
&[aria-checked='true'] ${
|
|
42
|
-
background: ${({ theme:
|
|
40
|
+
&[aria-checked='true'] ${t} {
|
|
41
|
+
background: ${({ theme: r }) => r.colors.success500};
|
|
43
42
|
}
|
|
44
43
|
|
|
45
|
-
&[aria-checked='true'] ${
|
|
44
|
+
&[aria-checked='true'] ${t}:before {
|
|
46
45
|
transform: translateX(1rem);
|
|
47
46
|
}
|
|
48
|
-
`,
|
|
49
|
-
({ label: e, onChange: p, onLabel: a, offLabel: s, selected: t, visibleLabels: d, ...u }, f) => /* @__PURE__ */ o(
|
|
50
|
-
g,
|
|
51
|
-
{
|
|
52
|
-
ref: f,
|
|
53
|
-
role: "switch",
|
|
54
|
-
"aria-checked": t,
|
|
55
|
-
"aria-label": e,
|
|
56
|
-
onClick: p,
|
|
57
|
-
visibleLabels: d,
|
|
58
|
-
type: "button",
|
|
59
|
-
...u,
|
|
60
|
-
children: /* @__PURE__ */ c(h, { children: [
|
|
61
|
-
/* @__PURE__ */ c(n, { children: [
|
|
62
|
-
/* @__PURE__ */ o("span", { children: a }),
|
|
63
|
-
/* @__PURE__ */ o("span", { children: s })
|
|
64
|
-
] }),
|
|
65
|
-
d && /* @__PURE__ */ o(m, { as: "span", "aria-hidden": !0, paddingLeft: 2, color: t ? "success600" : "danger600", children: t ? a : s })
|
|
66
|
-
] })
|
|
67
|
-
}
|
|
68
|
-
)
|
|
69
|
-
);
|
|
70
|
-
i.defaultProps = {
|
|
71
|
-
onLabel: "On",
|
|
72
|
-
offLabel: "Off",
|
|
73
|
-
visibleLabels: !1
|
|
74
|
-
};
|
|
75
|
-
i.propTypes = {
|
|
76
|
-
label: r.string.isRequired,
|
|
77
|
-
offLabel: r.string,
|
|
78
|
-
onChange: r.func.isRequired,
|
|
79
|
-
onLabel: r.string,
|
|
80
|
-
selected: r.bool.isRequired,
|
|
81
|
-
visibleLabels: r.bool
|
|
82
|
-
};
|
|
83
|
-
i.displayName = "Switch";
|
|
47
|
+
`, x = h.forwardRef(({ label: r, onChange: d, onLabel: n = "On", offLabel: i = "Off", selected: o, visibleLabels: a = !1, ...l }, p) => e(f, { ref: p, role: "switch", "aria-checked": o, "aria-label": r, onClick: d, visibleLabels: a, type: "button", ...l, children: s(u, { children: [s(t, { children: [e("span", { children: n }), e("span", { children: i })] }), a && e(m, { as: "span", "aria-hidden": !0, paddingLeft: 2, color: o ? "success600" : "danger600", children: o ? n : i })] }) }));
|
|
84
48
|
export {
|
|
85
|
-
|
|
49
|
+
x as Switch
|
|
86
50
|
};
|
package/dist/Tabs/TabGroup.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),p=require("react"),m=require("./TabsContext.cjs"),x=require("../hooks/useId.cjs");function T(e){if(e&&e.__esModule)return e;const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:()=>e[t]})}}return r.default=e,Object.freeze(r)}const o=T(p),i=o.forwardRef(({id:e,initialSelectedTabIndex:r=0,label:t,onTabChange:n,variant:s,...l},b)=>{const c=x.useId(e),[u,a]=o.useState(r);o.useImperativeHandle(b,()=>({_handlers:{setSelectedTabIndex:a}}));const f=o.useMemo(()=>({id:c,selectedTabIndex:u,selectTabIndex:a,label:t,variant:s,onTabChange:n}),[t,n,u,c,s]);return d.jsx(m.TabsContext.Provider,{value:f,children:d.jsx("div",{...l})})});i.displayName="TabGroup";exports.TabGroup=i;
|
package/dist/Tabs/TabGroup.js
CHANGED
|
@@ -1,40 +1,16 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import * as
|
|
3
|
-
import e from "prop-types";
|
|
1
|
+
import { jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import * as e from "react";
|
|
4
3
|
import { TabsContext as x } from "./TabsContext.js";
|
|
5
|
-
import { useId as
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const v = r.useMemo(
|
|
16
|
-
() => ({ id: l, selectedTabIndex: m, selectTabIndex: b, label: n, variant: a, onTabChange: s }),
|
|
17
|
-
[n, s, m, l, a]
|
|
18
|
-
);
|
|
19
|
-
return /* @__PURE__ */ f(x.Provider, { value: v, children: /* @__PURE__ */ f("div", { ...p }) });
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
t.displayName = "TabGroup";
|
|
23
|
-
t.defaultProps = {
|
|
24
|
-
id: void 0,
|
|
25
|
-
initialSelectedTabIndex: void 0,
|
|
26
|
-
onTabChange() {
|
|
27
|
-
},
|
|
28
|
-
variant: void 0
|
|
29
|
-
};
|
|
30
|
-
t.propTypes = {
|
|
31
|
-
children: e.node.isRequired,
|
|
32
|
-
id: e.string,
|
|
33
|
-
initialSelectedTabIndex: e.number,
|
|
34
|
-
label: e.string.isRequired,
|
|
35
|
-
onTabChange: e.func,
|
|
36
|
-
variant: e.oneOf(["simple"])
|
|
37
|
-
};
|
|
4
|
+
import { useId as f } from "../hooks/useId.js";
|
|
5
|
+
const l = e.forwardRef(({ id: c, initialSelectedTabIndex: n = 0, label: t, onTabChange: o, variant: r, ...i }, p) => {
|
|
6
|
+
const s = f(c), [d, a] = e.useState(n);
|
|
7
|
+
e.useImperativeHandle(p, () => ({
|
|
8
|
+
_handlers: { setSelectedTabIndex: a }
|
|
9
|
+
}));
|
|
10
|
+
const u = e.useMemo(() => ({ id: s, selectedTabIndex: d, selectTabIndex: a, label: t, variant: r, onTabChange: o }), [t, o, d, s, r]);
|
|
11
|
+
return m(x.Provider, { value: u, children: m("div", { ...i }) });
|
|
12
|
+
});
|
|
13
|
+
l.displayName = "TabGroup";
|
|
38
14
|
export {
|
|
39
|
-
|
|
15
|
+
l as TabGroup
|
|
40
16
|
};
|
package/dist/Tabs/TabPanels.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const b=require("react/jsx-runtime"),s=require("react"),c=require("./TabsContext.cjs"),i=({children:e,...t})=>{const{id:a,selectedTabIndex:n}=c.useTabs(),o=s.Children.toArray(e).map((l,r)=>s.cloneElement(l,{id:`${a}-${r}`})).filter((l,r)=>r===n);return b.jsx("div",{...t,children:o})},d=({id:e,...t})=>{const a=`${e}-tab`,n=`${e}-tabpanel`;return b.jsx("div",{id:n,role:"tabpanel",tabIndex:0,"aria-labelledby":a,...t})};exports.TabPanel=d;exports.TabPanels=i;
|
package/dist/Tabs/TabPanels.js
CHANGED
|
@@ -1,25 +1,14 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Children as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
children: i.node.isRequired
|
|
11
|
-
};
|
|
12
|
-
const l = ({ id: e, ...r }) => {
|
|
13
|
-
const t = `${e}-tab`, o = `${e}-tabpanel`;
|
|
14
|
-
return /* @__PURE__ */ d("div", { id: o, role: "tabpanel", tabIndex: 0, "aria-labelledby": t, ...r });
|
|
15
|
-
};
|
|
16
|
-
l.defaultProps = {
|
|
17
|
-
id: void 0
|
|
18
|
-
};
|
|
19
|
-
l.propTypes = {
|
|
20
|
-
id: i.string
|
|
1
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
+
import { Children as b, cloneElement as i } from "react";
|
|
3
|
+
import { useTabs as s } from "./TabsContext.js";
|
|
4
|
+
const f = ({ children: e, ...t }) => {
|
|
5
|
+
const { id: a, selectedTabIndex: r } = s(), d = b.toArray(e).map((l, n) => i(l, { id: `${a}-${n}` })).filter((l, n) => n === r);
|
|
6
|
+
return o("div", { ...t, children: d });
|
|
7
|
+
}, x = ({ id: e, ...t }) => {
|
|
8
|
+
const a = `${e}-tab`, r = `${e}-tabpanel`;
|
|
9
|
+
return o("div", { id: r, role: "tabpanel", tabIndex: 0, "aria-labelledby": a, ...t });
|
|
21
10
|
};
|
|
22
11
|
export {
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
x as TabPanel,
|
|
13
|
+
f as TabPanels
|
|
25
14
|
};
|
package/dist/Tabs/Tabs.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react/jsx-runtime"),x=require("react"),I=require("@strapi/ui-primitives"),K=require("styled-components"),m=require("./components.cjs"),R=require("./TabsContext.cjs"),T=require("../helpers/keyboardKeys.cjs"),C=require("../Typography/Typography.cjs"),k=n=>n&&n.__esModule?n:{default:n},j=k(K),q=(n,u)=>{const i=x.useRef(null),l=x.useRef(!1),a=I.useCallbackRef(u);return x.useEffect(()=>{if(i.current){if(l.current){const d=i.current.querySelector('[tabindex="0"]');d&&(d.focus(),a(n))}l.current||(l.current=!0)}},[n,a]),i},v=j.default.button`
|
|
2
2
|
&[aria-disabled='true'] {
|
|
3
3
|
cursor: not-allowed;
|
|
4
4
|
}
|
|
5
|
-
`,
|
|
5
|
+
`,w=({children:n,...u})=>{const{id:i,selectedTabIndex:l,selectTabIndex:a,label:d,variant:h,onTabChange:g}=R.useTabs(),y=q(l,g),r=x.Children.toArray(n).map((t,b)=>x.cloneElement(t,{id:`${i}-${b}`,index:b,selectedTabIndex:l,onTabClick:()=>a(b),variant:h})),p=t=>{if(!r.every(s=>s.props.disabled))switch(t.key){case T.KeyboardKeys.RIGHT:{const s=l+1,e=o=>r[o].props.disabled?o===r.length-1?e(0):e(o+1):o,f=e(s>=r.length?0:s);a(f);break}case T.KeyboardKeys.LEFT:{const s=l-1,e=o=>r[o].props.disabled?e(o===0?r.length-1:o-1):o,f=e(s<0?r.length-1:s);a(f);break}case T.KeyboardKeys.HOME:{const s=r.findIndex(e=>!e.props.disabled);a(s);break}case T.KeyboardKeys.END:{const e=r.map((f,o)=>({isDisabled:f.props.disabled,index:o})).reverse().find(({isDisabled:f})=>!f);e&&a(e.index);break}}};return h==="simple"?c.jsx("div",{ref:y,role:"tablist","aria-label":d,onKeyDown:p,...u,children:r}):c.jsx(m.DefaultTabsRow,{ref:y,role:"tablist",alignItems:"flex-end","aria-label":d,onKeyDown:p,...u,children:r})},B=({disabled:n=!1,id:u,children:i,variant:l,hasError:a=!1,index:d,selectedTabIndex:h,onTabClick:g,...y})=>{const r=`${u}-tab`,p=`${u}-tabpanel`,t=d===h,b=()=>{n||g&&g()};if(l==="simple"){let e;return a?e="danger600":t?e="primary600":e="neutral600",c.jsx(v,{id:r,role:"tab","aria-controls":t?p:void 0,tabIndex:t?0:-1,"aria-selected":t,type:"button",onClick:b,"aria-disabled":n,...y,children:c.jsx(m.SimpleTabBox,{padding:4,selected:t,hasError:a,children:c.jsx(C.Typography,{variant:"sigma",textColor:e,children:i})})})}a&&console.warn('The "hasError" prop is only available for the "simple" variant.');const s=h&&h-1===d;return c.jsx(m.DefaultTabButton,{id:r,role:"tab",type:"button","aria-controls":t?p:void 0,tabIndex:t?0:-1,"aria-selected":t,onClick:b,"aria-disabled":n,showRightBorder:!!s,...y,children:c.jsx(m.DefaultTabBox,{padding:t?4:3,background:t?"neutral0":"neutral100",selected:t,children:c.jsx(C.Typography,{fontWeight:"bold",textColor:t?"primary700":"neutral600",children:i})})})};exports.Tab=B;exports.Tabs=w;
|
package/dist/Tabs/Tabs.js
CHANGED
|
@@ -1,131 +1,76 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { Children as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import { DefaultTabsRow as
|
|
6
|
-
import { useTabs as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
const
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { Children as T, cloneElement as I, useRef as g, useEffect as k } from "react";
|
|
3
|
+
import { useCallbackRef as w } from "@strapi/ui-primitives";
|
|
4
|
+
import R from "styled-components";
|
|
5
|
+
import { DefaultTabsRow as v, SimpleTabBox as B, DefaultTabButton as E, DefaultTabBox as K } from "./components.js";
|
|
6
|
+
import { useTabs as A } from "./TabsContext.js";
|
|
7
|
+
import { KeyboardKeys as y } from "../helpers/keyboardKeys.js";
|
|
8
|
+
import { Typography as C } from "../Typography/Typography.js";
|
|
9
|
+
const N = (s, b) => {
|
|
10
|
+
const i = g(null), l = g(!1), r = w(b);
|
|
11
|
+
return k(() => {
|
|
12
|
+
if (i.current) {
|
|
13
|
+
if (l.current) {
|
|
14
|
+
const d = i.current.querySelector('[tabindex="0"]');
|
|
15
|
+
d && (d.focus(), r(s));
|
|
16
|
+
}
|
|
17
|
+
l.current || (l.current = !0);
|
|
18
|
+
}
|
|
19
|
+
}, [s, r]), i;
|
|
20
|
+
}, $ = R.button`
|
|
11
21
|
&[aria-disabled='true'] {
|
|
12
22
|
cursor: not-allowed;
|
|
13
23
|
}
|
|
14
|
-
`,
|
|
15
|
-
const { id:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const a = c + 1, e = (t) => r[t].props.disabled ? t === r.length - 1 ? e(0) : e(t + 1) : t, d = e(a >= r.length ? 0 : a);
|
|
28
|
-
i(d);
|
|
24
|
+
`, G = ({ children: s, ...b }) => {
|
|
25
|
+
const { id: i, selectedTabIndex: l, selectTabIndex: r, label: d, variant: h, onTabChange: x } = A(), p = N(l, x), n = T.toArray(s).map((t, u) => I(t, {
|
|
26
|
+
id: `${i}-${u}`,
|
|
27
|
+
index: u,
|
|
28
|
+
selectedTabIndex: l,
|
|
29
|
+
onTabClick: () => r(u),
|
|
30
|
+
variant: h
|
|
31
|
+
})), m = (t) => {
|
|
32
|
+
if (!n.every((a) => a.props.disabled))
|
|
33
|
+
switch (t.key) {
|
|
34
|
+
case y.RIGHT: {
|
|
35
|
+
const a = l + 1, e = (o) => n[o].props.disabled ? o === n.length - 1 ? e(0) : e(o + 1) : o, f = e(a >= n.length ? 0 : a);
|
|
36
|
+
r(f);
|
|
29
37
|
break;
|
|
30
38
|
}
|
|
31
|
-
case
|
|
32
|
-
const a =
|
|
33
|
-
|
|
39
|
+
case y.LEFT: {
|
|
40
|
+
const a = l - 1, e = (o) => n[o].props.disabled ? e(o === 0 ? n.length - 1 : o - 1) : o, f = e(a < 0 ? n.length - 1 : a);
|
|
41
|
+
r(f);
|
|
34
42
|
break;
|
|
35
43
|
}
|
|
36
|
-
case
|
|
37
|
-
const a =
|
|
38
|
-
|
|
44
|
+
case y.HOME: {
|
|
45
|
+
const a = n.findIndex((e) => !e.props.disabled);
|
|
46
|
+
r(a);
|
|
39
47
|
break;
|
|
40
48
|
}
|
|
41
|
-
case
|
|
42
|
-
const e =
|
|
43
|
-
e &&
|
|
49
|
+
case y.END: {
|
|
50
|
+
const e = n.map((f, o) => ({ isDisabled: f.props.disabled, index: o })).reverse().find(({ isDisabled: f }) => !f);
|
|
51
|
+
e && r(e.index);
|
|
44
52
|
break;
|
|
45
53
|
}
|
|
46
54
|
}
|
|
47
55
|
};
|
|
48
|
-
return
|
|
56
|
+
return h === "simple" ? (
|
|
49
57
|
// TODO: This needs to be reviewed how to handle correctly since it's supposed to have focus.
|
|
50
58
|
// eslint-disable-next-line jsx-a11y/interactive-supports-focus
|
|
51
|
-
|
|
52
|
-
) :
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
role: "tablist",
|
|
57
|
-
alignItems: "flex-end",
|
|
58
|
-
"aria-label": f,
|
|
59
|
-
onKeyDown: h,
|
|
60
|
-
...p,
|
|
61
|
-
children: r
|
|
62
|
-
}
|
|
63
|
-
);
|
|
64
|
-
};
|
|
65
|
-
N.propTypes = {
|
|
66
|
-
children: o.node.isRequired
|
|
67
|
-
};
|
|
68
|
-
const v = ({ disabled: b, id: p, children: x, variant: c, hasError: i, index: f, selectedTabIndex: u, onTabClick: y, ...m }) => {
|
|
69
|
-
const r = `${p}-tab`, h = `${p}-tabpanel`, n = f === u, s = () => {
|
|
70
|
-
b || y();
|
|
59
|
+
c("div", { ref: p, role: "tablist", "aria-label": d, onKeyDown: m, ...b, children: n })
|
|
60
|
+
) : c(v, { ref: p, role: "tablist", alignItems: "flex-end", "aria-label": d, onKeyDown: m, ...b, children: n });
|
|
61
|
+
}, L = ({ disabled: s = !1, id: b, children: i, variant: l, hasError: r = !1, index: d, selectedTabIndex: h, onTabClick: x, ...p }) => {
|
|
62
|
+
const n = `${b}-tab`, m = `${b}-tabpanel`, t = d === h, u = () => {
|
|
63
|
+
s || x && x();
|
|
71
64
|
};
|
|
72
|
-
if (
|
|
65
|
+
if (l === "simple") {
|
|
73
66
|
let e;
|
|
74
|
-
return
|
|
75
|
-
A,
|
|
76
|
-
{
|
|
77
|
-
id: r,
|
|
78
|
-
role: "tab",
|
|
79
|
-
"aria-controls": n ? h : void 0,
|
|
80
|
-
tabIndex: n ? 0 : -1,
|
|
81
|
-
"aria-selected": n,
|
|
82
|
-
type: "button",
|
|
83
|
-
onClick: s,
|
|
84
|
-
"aria-disabled": b,
|
|
85
|
-
...m,
|
|
86
|
-
children: /* @__PURE__ */ l(R, { padding: 4, selected: n, hasError: i, children: /* @__PURE__ */ l(I, { variant: "sigma", textColor: e, children: x }) })
|
|
87
|
-
}
|
|
88
|
-
);
|
|
67
|
+
return r ? e = "danger600" : t ? e = "primary600" : e = "neutral600", c($, { id: n, role: "tab", "aria-controls": t ? m : void 0, tabIndex: t ? 0 : -1, "aria-selected": t, type: "button", onClick: u, "aria-disabled": s, ...p, children: c(B, { padding: 4, selected: t, hasError: r, children: c(C, { variant: "sigma", textColor: e, children: i }) }) });
|
|
89
68
|
}
|
|
90
|
-
|
|
91
|
-
const a =
|
|
92
|
-
return
|
|
93
|
-
B,
|
|
94
|
-
{
|
|
95
|
-
id: r,
|
|
96
|
-
role: "tab",
|
|
97
|
-
type: "button",
|
|
98
|
-
"aria-controls": n ? h : void 0,
|
|
99
|
-
tabIndex: n ? 0 : -1,
|
|
100
|
-
"aria-selected": n,
|
|
101
|
-
onClick: s,
|
|
102
|
-
"aria-disabled": b,
|
|
103
|
-
showRightBorder: a,
|
|
104
|
-
...m,
|
|
105
|
-
children: /* @__PURE__ */ l(E, { padding: n ? 4 : 3, background: n ? "neutral0" : "neutral100", selected: n, children: /* @__PURE__ */ l(I, { fontWeight: "bold", textColor: n ? "primary700" : "neutral600", children: x }) })
|
|
106
|
-
}
|
|
107
|
-
);
|
|
108
|
-
};
|
|
109
|
-
v.defaultProps = {
|
|
110
|
-
disabled: !1,
|
|
111
|
-
hasError: !1,
|
|
112
|
-
id: void 0,
|
|
113
|
-
index: void 0,
|
|
114
|
-
onTabClick: void 0,
|
|
115
|
-
selectedTabIndex: void 0,
|
|
116
|
-
variant: void 0
|
|
117
|
-
};
|
|
118
|
-
v.propTypes = {
|
|
119
|
-
children: o.node.isRequired,
|
|
120
|
-
disabled: o.bool,
|
|
121
|
-
hasError: o.bool,
|
|
122
|
-
id: o.string,
|
|
123
|
-
index: o.number,
|
|
124
|
-
onTabClick: o.func,
|
|
125
|
-
selectedTabIndex: o.number,
|
|
126
|
-
variant: o.oneOf(["simple"])
|
|
69
|
+
r && console.warn('The "hasError" prop is only available for the "simple" variant.');
|
|
70
|
+
const a = h && h - 1 === d;
|
|
71
|
+
return c(E, { id: n, role: "tab", type: "button", "aria-controls": t ? m : void 0, tabIndex: t ? 0 : -1, "aria-selected": t, onClick: u, "aria-disabled": s, showRightBorder: !!a, ...p, children: c(K, { padding: t ? 4 : 3, background: t ? "neutral0" : "neutral100", selected: t, children: c(C, { fontWeight: "bold", textColor: t ? "primary700" : "neutral600", children: i }) }) });
|
|
127
72
|
};
|
|
128
73
|
export {
|
|
129
|
-
|
|
130
|
-
|
|
74
|
+
L as Tab,
|
|
75
|
+
G as Tabs
|
|
131
76
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=e.createContext(),s=()=>e.useContext(t);exports.TabsContext=t;exports.useTabs=s;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react"),t=e.createContext({id:"",label:"",selectedTabIndex:0,selectTabIndex(){throw new Error("TabsContext.selectTabIndex is not implemented.")}}),s=()=>e.useContext(t);exports.TabsContext=t;exports.useTabs=s;
|
package/dist/Tabs/TabsContext.js
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
|
-
import { createContext as
|
|
2
|
-
const
|
|
1
|
+
import { createContext as e, useContext as t } from "react";
|
|
2
|
+
const n = e({
|
|
3
|
+
id: "",
|
|
4
|
+
label: "",
|
|
5
|
+
selectedTabIndex: 0,
|
|
6
|
+
selectTabIndex() {
|
|
7
|
+
throw new Error("TabsContext.selectTabIndex is not implemented.");
|
|
8
|
+
}
|
|
9
|
+
}), s = () => t(n);
|
|
3
10
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
n as TabsContext,
|
|
12
|
+
s as useTabs
|
|
6
13
|
};
|
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),p=require("react"),g=require("styled-components"),j=require("../hooks/useId.cjs"),b=require("../themes/utils.cjs"),d=require("../Box/Box.cjs"),m=require("../Field/FieldContext.cjs"),y=require("../Field/Field.cjs"),R=require("../Flex/Flex.cjs"),_=require("../Field/FieldLabel.cjs"),$=require("../Field/FieldHint.cjs"),E=require("../Field/FieldError.cjs"),c=e=>e&&e.__esModule?e:{default:e},f=c(p),x=c(g),I=x.default(d.Box)`
|
|
2
|
+
${b.inputFocusStyle()}
|
|
3
|
+
`,S=x.default(d.Box)`
|
|
4
|
+
border: none;
|
|
5
|
+
resize: none;
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
font-size: ${
|
|
11
|
-
|
|
12
|
-
color: ${({theme:t})=>t.colors.neutral500};
|
|
7
|
+
::placeholder {
|
|
8
|
+
color: ${({theme:e})=>e.colors.neutral500};
|
|
9
|
+
font-size: ${({theme:e})=>e.fontSizes[2]};
|
|
10
|
+
color: ${({theme:e})=>e.colors.neutral500};
|
|
13
11
|
opacity: 1;
|
|
14
12
|
}
|
|
15
|
-
|
|
13
|
+
|
|
14
|
+
&:focus-within {
|
|
15
|
+
outline: none;
|
|
16
|
+
}
|
|
17
|
+
`,T=f.default.forwardRef(({disabled:e,...a},s)=>{const{id:t,error:i,hint:l,required:u}=m.useField(),n=!!i;let o=l?`${t}-hint`:void 0;return i&&(o=`${t}-error`),r.jsx(I,{borderColor:n?"danger600":"neutral200",hasError:n,hasRadius:!0,children:r.jsx(S,{"aria-describedby":o,"aria-invalid":n,"aria-required":u,as:"textarea",background:e?"neutral150":"neutral0",color:e?"neutral600":"neutral800",disabled:e,fontSize:2,hasRadius:!0,height:`${105/16}rem`,id:t,ref:s,lineHeight:4,padding:4,width:"100%",...a})})}),w=f.default.forwardRef(({name:e,hint:a,error:s,label:t,labelAction:i,id:l,required:u=!1,children:n,value:o,...h},q)=>{const F=j.useId(l);return r.jsx(y.Field,{name:e,hint:a,error:s,id:F,required:u,children:r.jsxs(R.Flex,{direction:"column",alignItems:"stretch",gap:1,children:[t&&r.jsx(_.FieldLabel,{action:i,children:t}),r.jsx(T,{ref:q,value:n??o,...h}),r.jsx($.FieldHint,{}),r.jsx(E.FieldError,{})]})})});exports.Textarea=w;
|
|
@@ -1,61 +1,39 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
1
|
+
import { jsx as e, jsxs as x } from "react/jsx-runtime";
|
|
2
|
+
import m from "react";
|
|
3
|
+
import c from "styled-components";
|
|
4
|
+
import { useId as g } from "../hooks/useId.js";
|
|
5
|
+
import { inputFocusStyle as F } from "../themes/utils.js";
|
|
6
|
+
import { Box as u } from "../Box/Box.js";
|
|
7
|
+
import { useField as $ } from "../Field/FieldContext.js";
|
|
8
|
+
import { Field as R } from "../Field/Field.js";
|
|
9
|
+
import { Flex as b } from "../Flex/Flex.js";
|
|
10
|
+
import { FieldLabel as w } from "../Field/FieldLabel.js";
|
|
11
|
+
import { FieldHint as y } from "../Field/FieldHint.js";
|
|
12
|
+
import { FieldError as z } from "../Field/FieldError.js";
|
|
13
|
+
const E = c(u)`
|
|
14
|
+
${F()}
|
|
15
|
+
`, I = c(u)`
|
|
16
|
+
border: none;
|
|
17
|
+
resize: none;
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
font-size: ${
|
|
22
|
-
|
|
23
|
-
color: ${({ theme: i }) => i.colors.neutral500};
|
|
19
|
+
::placeholder {
|
|
20
|
+
color: ${({ theme: r }) => r.colors.neutral500};
|
|
21
|
+
font-size: ${({ theme: r }) => r.fontSizes[2]};
|
|
22
|
+
color: ${({ theme: r }) => r.colors.neutral500};
|
|
24
23
|
opacity: 1;
|
|
25
24
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
return /* @__PURE__ */ r(I, { children: /* @__PURE__ */ r(b, { name: i, hint: l, error: n, id: f, required: p, children: /* @__PURE__ */ g(a, { direction: "column", alignItems: "stretch", gap: 1, children: [
|
|
30
|
-
o && /* @__PURE__ */ r(a, { children: /* @__PURE__ */ r(y, { action: m, children: o }) }),
|
|
31
|
-
/* @__PURE__ */ r(v, { ref: c, as: "textarea", value: d, ...h }),
|
|
32
|
-
/* @__PURE__ */ r(F, {}),
|
|
33
|
-
/* @__PURE__ */ r(w, {})
|
|
34
|
-
] }) }) });
|
|
25
|
+
|
|
26
|
+
&:focus-within {
|
|
27
|
+
outline: none;
|
|
35
28
|
}
|
|
36
|
-
)
|
|
37
|
-
t
|
|
38
|
-
|
|
39
|
-
"aria-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
error:
|
|
43
|
-
|
|
44
|
-
id: void 0,
|
|
45
|
-
children: "",
|
|
46
|
-
required: !1
|
|
47
|
-
};
|
|
48
|
-
t.propTypes = {
|
|
49
|
-
"aria-label": e.string,
|
|
50
|
-
children: e.string,
|
|
51
|
-
error: e.string,
|
|
52
|
-
hint: e.oneOfType([e.string, e.node, e.arrayOf(e.node)]),
|
|
53
|
-
id: e.string,
|
|
54
|
-
label: e.string,
|
|
55
|
-
labelAction: e.element,
|
|
56
|
-
name: e.string.isRequired,
|
|
57
|
-
required: e.bool
|
|
58
|
-
};
|
|
29
|
+
`, q = m.forwardRef(({ disabled: r, ...a }, d) => {
|
|
30
|
+
const { id: o, error: i, hint: l, required: s } = $(), t = !!i;
|
|
31
|
+
let n = l ? `${o}-hint` : void 0;
|
|
32
|
+
return i && (n = `${o}-error`), e(E, { borderColor: t ? "danger600" : "neutral200", hasError: t, hasRadius: !0, children: e(I, { "aria-describedby": n, "aria-invalid": t, "aria-required": s, as: "textarea", background: r ? "neutral150" : "neutral0", color: r ? "neutral600" : "neutral800", disabled: r, fontSize: 2, hasRadius: !0, height: `${105 / 16}rem`, id: o, ref: d, lineHeight: 4, padding: 4, width: "100%", ...a }) });
|
|
33
|
+
}), A = m.forwardRef(({ name: r, hint: a, error: d, label: o, labelAction: i, id: l, required: s = !1, children: t, value: n, ...f }, p) => {
|
|
34
|
+
const h = g(l);
|
|
35
|
+
return e(R, { name: r, hint: a, error: d, id: h, required: s, children: x(b, { direction: "column", alignItems: "stretch", gap: 1, children: [o && e(w, { action: i, children: o }), e(q, { ref: p, value: t ?? n, ...f }), e(y, {}), e(z, {})] }) });
|
|
36
|
+
});
|
|
59
37
|
export {
|
|
60
|
-
|
|
38
|
+
A as Textarea
|
|
61
39
|
};
|