@cfx-dev/ui-components 2.0.0 → 2.0.1
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/assets/Accordion.css +1 -0
- package/dist/assets/global.css +1 -1
- package/dist/components/Accordion/Accordion.d.ts +26 -0
- package/dist/components/Accordion/Accordion.js +120 -0
- package/dist/components/Accordion/AccordionShowcase.d.ts +5 -0
- package/dist/components/Accordion/AccordionShowcase.js +60 -0
- package/dist/components/Accordion/index.d.ts +0 -0
- package/dist/components/Accordion/index.js +1 -0
- package/dist/styles-scss/global.scss +1 -0
- package/dist/styles-scss/tokens.scss +5 -0
- package/package.json +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
import { IconName } from '../Icon';
|
|
3
|
+
|
|
4
|
+
export interface AccordionContextProps {
|
|
5
|
+
openItems: Set<string>;
|
|
6
|
+
toggleItem: (id: string) => void;
|
|
7
|
+
}
|
|
8
|
+
export interface AccordionProps {
|
|
9
|
+
className?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const Accordion: React.FC<PropsWithChildren<AccordionProps>>;
|
|
12
|
+
export declare const AccordionItem: React.FC<React.PropsWithChildren<{
|
|
13
|
+
id: string;
|
|
14
|
+
}>>;
|
|
15
|
+
export declare const AccordionHeader: React.FC<React.PropsWithChildren>;
|
|
16
|
+
interface AccordionTriggerProps {
|
|
17
|
+
id: string;
|
|
18
|
+
text: string;
|
|
19
|
+
iconLeft?: IconName;
|
|
20
|
+
}
|
|
21
|
+
export declare const AccordionTrigger: React.FC<AccordionTriggerProps>;
|
|
22
|
+
interface AccordionContentProps {
|
|
23
|
+
id: string;
|
|
24
|
+
}
|
|
25
|
+
export declare const AccordionContent: React.FC<React.PropsWithChildren<AccordionContentProps>>;
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { jsx as e, jsxs as f } from "react/jsx-runtime";
|
|
2
|
+
import w, { createContext as D, useState as p, useContext as A, useEffect as U } from "react";
|
|
3
|
+
import { Icon as C } from "../Icon/Icon.js";
|
|
4
|
+
import { Flex as x } from "../Layout/Flex/Flex.js";
|
|
5
|
+
import { Text as I } from "../Text/Text.js";
|
|
6
|
+
import { clsx as u } from "../../utils/clsx.js";
|
|
7
|
+
import '../../assets/Accordion.css';const b = "_root_44hi4_1", S = "_item_44hi4_5", F = "_header_44hi4_5", N = "_triggerContainer_44hi4_10", y = "_iconFlip_44hi4_23", T = "_iconUp_44hi4_26", R = "_iconDown_44hi4_29", $ = "_iconLeft_44hi4_32", k = "_iconRight_44hi4_36", E = "_content_44hi4_49", L = "_open_44hi4_56", O = "_iconSlideUp_44hi4_1", j = "_iconSlideDown_44hi4_1", o = {
|
|
8
|
+
root: b,
|
|
9
|
+
item: S,
|
|
10
|
+
header: F,
|
|
11
|
+
triggerContainer: N,
|
|
12
|
+
iconFlip: y,
|
|
13
|
+
iconUp: T,
|
|
14
|
+
iconDown: R,
|
|
15
|
+
iconLeft: $,
|
|
16
|
+
iconRight: k,
|
|
17
|
+
content: E,
|
|
18
|
+
open: L,
|
|
19
|
+
iconSlideUp: O,
|
|
20
|
+
iconSlideDown: j
|
|
21
|
+
}, g = D(void 0), q = function({
|
|
22
|
+
children: t,
|
|
23
|
+
className: n
|
|
24
|
+
}) {
|
|
25
|
+
const [c, s] = p(/* @__PURE__ */ new Set()), a = w.useCallback((i) => {
|
|
26
|
+
s((m) => {
|
|
27
|
+
const r = new Set(m);
|
|
28
|
+
return r.has(i) ? r.delete(i) : r.add(i), r;
|
|
29
|
+
});
|
|
30
|
+
}, []), h = w.useMemo(() => ({
|
|
31
|
+
openItems: c,
|
|
32
|
+
toggleItem: a
|
|
33
|
+
}), [c, a]);
|
|
34
|
+
return /* @__PURE__ */ e(g.Provider, { value: h, children: /* @__PURE__ */ e("div", { className: u(o.root, n), role: "presentation", children: t }) });
|
|
35
|
+
}, B = function({
|
|
36
|
+
children: t,
|
|
37
|
+
id: n
|
|
38
|
+
}) {
|
|
39
|
+
return /* @__PURE__ */ e("div", { className: o.item, id: n, role: "region", "aria-labelledby": `${n}-header`, children: t });
|
|
40
|
+
}, G = function({
|
|
41
|
+
children: t
|
|
42
|
+
}) {
|
|
43
|
+
return /* @__PURE__ */ e("div", { className: o.header, children: t });
|
|
44
|
+
}, J = function({
|
|
45
|
+
text: t,
|
|
46
|
+
id: n,
|
|
47
|
+
iconLeft: c
|
|
48
|
+
}) {
|
|
49
|
+
const s = A(g);
|
|
50
|
+
if (!s)
|
|
51
|
+
throw new Error("AccordionTrigger must be used within an Accordion");
|
|
52
|
+
const {
|
|
53
|
+
toggleItem: a,
|
|
54
|
+
openItems: h
|
|
55
|
+
} = s, i = h.has(n), [m, r] = p(!1), [_, v] = p(i ? "UpChevron" : "DownChevron");
|
|
56
|
+
return U(() => {
|
|
57
|
+
const d = setTimeout(() => {
|
|
58
|
+
v(i ? "UpChevron" : "DownChevron"), r(!1);
|
|
59
|
+
}, 300);
|
|
60
|
+
return r(!0), () => clearTimeout(d);
|
|
61
|
+
}, [i]), /* @__PURE__ */ f(
|
|
62
|
+
"div",
|
|
63
|
+
{
|
|
64
|
+
className: o.triggerContainer,
|
|
65
|
+
onClick: () => a(n),
|
|
66
|
+
onKeyDown: (d) => {
|
|
67
|
+
(d.key === "Enter" || d.key === " ") && a(n);
|
|
68
|
+
},
|
|
69
|
+
role: "button",
|
|
70
|
+
tabIndex: 0,
|
|
71
|
+
"aria-expanded": i,
|
|
72
|
+
"aria-controls": `${n}-content`,
|
|
73
|
+
id: `${n}-header`,
|
|
74
|
+
children: [
|
|
75
|
+
/* @__PURE__ */ f(x, { centered: !0, children: [
|
|
76
|
+
c && /* @__PURE__ */ e(C, { name: c, className: o.iconLeft }),
|
|
77
|
+
/* @__PURE__ */ e(I, { size: "xxsmall", children: t })
|
|
78
|
+
] }),
|
|
79
|
+
/* @__PURE__ */ e(x, { centered: !0, children: /* @__PURE__ */ e(
|
|
80
|
+
C,
|
|
81
|
+
{
|
|
82
|
+
className: u(o.iconRight, {
|
|
83
|
+
[o.iconFlip]: m,
|
|
84
|
+
[o.iconUp]: _ === "UpChevron",
|
|
85
|
+
[o.iconDown]: _ === "DownChevron"
|
|
86
|
+
}),
|
|
87
|
+
name: _
|
|
88
|
+
}
|
|
89
|
+
) })
|
|
90
|
+
]
|
|
91
|
+
}
|
|
92
|
+
);
|
|
93
|
+
}, Q = function({
|
|
94
|
+
children: t,
|
|
95
|
+
id: n
|
|
96
|
+
}) {
|
|
97
|
+
const c = A(g);
|
|
98
|
+
if (!c)
|
|
99
|
+
throw new Error("AccordionContent must be used within an Accordion");
|
|
100
|
+
const {
|
|
101
|
+
openItems: s
|
|
102
|
+
} = c;
|
|
103
|
+
return /* @__PURE__ */ e(
|
|
104
|
+
"div",
|
|
105
|
+
{
|
|
106
|
+
className: u(o.content, { [o.open]: s.has(n) }),
|
|
107
|
+
id: `${n}-content`,
|
|
108
|
+
role: "region",
|
|
109
|
+
"aria-labelledby": `${n}-header`,
|
|
110
|
+
children: /* @__PURE__ */ e(I, { color: "secondary", size: "xxsmall", children: t })
|
|
111
|
+
}
|
|
112
|
+
);
|
|
113
|
+
};
|
|
114
|
+
export {
|
|
115
|
+
q as Accordion,
|
|
116
|
+
Q as AccordionContent,
|
|
117
|
+
G as AccordionHeader,
|
|
118
|
+
B as AccordionItem,
|
|
119
|
+
J as AccordionTrigger
|
|
120
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { jsx as e, jsxs as t } from "react/jsx-runtime";
|
|
2
|
+
import a from "react";
|
|
3
|
+
import { Flex as c } from "../Layout/Flex/Flex.js";
|
|
4
|
+
import { Text as d } from "../Text/Text.js";
|
|
5
|
+
import { Accordion as l, AccordionItem as i, AccordionHeader as o, AccordionTrigger as n, AccordionContent as r } from "./Accordion.js";
|
|
6
|
+
function h() {
|
|
7
|
+
return /* @__PURE__ */ e(c, { fullWidth: !0, vertical: !0, children: /* @__PURE__ */ t(c, { fullWidth: !0, vertical: !0, children: [
|
|
8
|
+
/* @__PURE__ */ e(d, { size: "large", children: "Accordion" }),
|
|
9
|
+
/* @__PURE__ */ t(l, { children: [
|
|
10
|
+
/* @__PURE__ */ t(i, { id: "item1", children: [
|
|
11
|
+
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(
|
|
12
|
+
n,
|
|
13
|
+
{
|
|
14
|
+
id: "item1",
|
|
15
|
+
text: "Will I get banned from GTA:O?",
|
|
16
|
+
iconLeft: "MoreInfo"
|
|
17
|
+
}
|
|
18
|
+
) }),
|
|
19
|
+
/* @__PURE__ */ e(r, { id: "item1", children: "Nope! FiveM does not interact with the Rockstar Online Services other than to validate your game copy the first time you launch it. Nope! FiveM does not interact with the Rockstar Online Services other than to validate your game copy the first time you launch it. Nope! FiveM does not interact with the Rockstar Online Services other than to validate your game copy the first time you launch it. Nope! FiveM does not interact with the Rockstar Online Services other than to validate your game copy the first time you launch it." })
|
|
20
|
+
] }),
|
|
21
|
+
/* @__PURE__ */ t(i, { id: "item2", children: [
|
|
22
|
+
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(
|
|
23
|
+
n,
|
|
24
|
+
{
|
|
25
|
+
id: "item2",
|
|
26
|
+
text: "Can I cheat on FiveM?",
|
|
27
|
+
iconLeft: "MoreInfo"
|
|
28
|
+
}
|
|
29
|
+
) }),
|
|
30
|
+
/* @__PURE__ */ e(r, { id: "item2", children: "Dont be a cheater, you will get banned! Dont be a cheater, you will get banned! Dont be a cheater, you will get banned! Dont be a cheater, you will get banned! Dont be a cheater, you will get banned! Dont be a cheater, you will get banned! Dont be a cheater, you will get banned!" })
|
|
31
|
+
] }),
|
|
32
|
+
/* @__PURE__ */ t(i, { id: "item3", children: [
|
|
33
|
+
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(
|
|
34
|
+
n,
|
|
35
|
+
{
|
|
36
|
+
id: "item3",
|
|
37
|
+
text: "Is this accordion any good?",
|
|
38
|
+
iconLeft: "MoreInfo"
|
|
39
|
+
}
|
|
40
|
+
) }),
|
|
41
|
+
/* @__PURE__ */ e(r, { id: "item3", children: "Obviously!" })
|
|
42
|
+
] }),
|
|
43
|
+
/* @__PURE__ */ t(i, { id: "item4", children: [
|
|
44
|
+
/* @__PURE__ */ e(o, { children: /* @__PURE__ */ e(
|
|
45
|
+
n,
|
|
46
|
+
{
|
|
47
|
+
id: "item4",
|
|
48
|
+
text: "Who said?",
|
|
49
|
+
iconLeft: "MoreInfo"
|
|
50
|
+
}
|
|
51
|
+
) }),
|
|
52
|
+
/* @__PURE__ */ e(r, { id: "item4", children: "Me!" })
|
|
53
|
+
] })
|
|
54
|
+
] })
|
|
55
|
+
] }) });
|
|
56
|
+
}
|
|
57
|
+
const b = a.memo(h);
|
|
58
|
+
export {
|
|
59
|
+
b as default
|
|
60
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -117,6 +117,11 @@ $control-heights: (
|
|
|
117
117
|
@include ui.define-color-token('input-disabled-border', ui.color('bg-light'));
|
|
118
118
|
}
|
|
119
119
|
|
|
120
|
+
@mixin accordion-tokens() {
|
|
121
|
+
@include ui.define-color-token('accordion-border-color', ui.color('secondary', 'pure', .1));
|
|
122
|
+
@include ui.define-color-token('accordion-background', ui.color('bg'));
|
|
123
|
+
}
|
|
124
|
+
|
|
120
125
|
@mixin select-tokens() {
|
|
121
126
|
@include ui.define-color-token('interactive-list-background', ui.color('bg-light'));
|
|
122
127
|
@include ui.define-color-token('interactive-list-item-background', transparent);
|