@fluidattacks/design 9.1.1 → 9.2.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.
@@ -1,121 +1,125 @@
1
- import { jsx as d, jsxs as E } from "react/jsx-runtime";
2
- import { useRef as G, useMemo as h, useCallback as k } from "react";
3
- import { useOption as H } from "../../../../../node_modules/react-aria/dist/private/listbox/useOption.js";
4
- import { useTheme as J } from "styled-components";
5
- import { StyledOption as Q } from "../styles.js";
6
- import { describeSelection as W } from "../utils.js";
7
- import { Checkbox as T } from "../../../../checkbox/index.js";
8
- import { Icon as X } from "../../../../icon/index.js";
9
- import { Link as Y } from "../../../../link/index.js";
10
- import { Tag as Z } from "../../../../tag/index.js";
1
+ import { jsx as l, jsxs as G } from "react/jsx-runtime";
2
+ import { useRef as H, useMemo as f, useCallback as k } from "react";
3
+ import { useOption as J } from "../../../../../node_modules/react-aria/dist/private/listbox/useOption.js";
4
+ import { useTheme as Q } from "styled-components";
5
+ import { StyledOption as W } from "../styles.js";
6
+ import { describeSelection as X, toSelection as j } from "../utils.js";
7
+ import { Checkbox as u } from "../../../../checkbox/index.js";
8
+ import { Icon as Y } from "../../../../icon/index.js";
9
+ import { Link as Z } from "../../../../link/index.js";
10
+ import { Tag as _ } from "../../../../tag/index.js";
11
11
  import "../../../../typography/heading/index.js";
12
12
  import "../../../../typography/span/index.js";
13
- import { Text as _ } from "../../../../typography/text/index.js";
14
- import { useClickOutside as I } from "../../../../../hooks/use-click-outside.js";
15
- import { openUrl as V } from "../../../../../utils/open-url.js";
16
- const yo = ({
17
- allItemKeys: g,
18
- containerRef: j,
13
+ import { Text as I } from "../../../../typography/text/index.js";
14
+ import { useClickOutside as V } from "../../../../../hooks/use-click-outside.js";
15
+ import { openUrl as oo } from "../../../../../utils/open-url.js";
16
+ const Co = ({
17
+ allItemKeys: a,
18
+ containerRef: D,
19
19
  item: o,
20
- multiSelection: p,
21
- name: r,
22
- popoverRef: D,
23
- setInputValue: t,
20
+ multiSelection: s,
21
+ name: e,
22
+ popoverRef: w,
23
+ setInputValue: i,
24
24
  setValue: n,
25
25
  state: c,
26
- watch: f
26
+ tag: C,
27
+ watch: h
27
28
  }) => {
28
- const w = J(), O = G(null), a = o.props.hrefLang, y = c.disabledKeys, C = g.filter(
29
- (e) => !Array.from(y).includes(e) && e !== "All"
30
- ), { optionProps: z, isSelected: $, isFocused: F, isDisabled: A } = H(
29
+ const z = Q(), y = H(null), d = o.props.hrefLang, g = c.disabledKeys, A = a.filter(
30
+ (r) => !Array.from(g).includes(r) && r !== "All"
31
+ ), { optionProps: F, isSelected: $, isFocused: q, isDisabled: O } = J(
31
32
  { key: o.key },
32
33
  c,
33
- O
34
- ), b = h(() => c.collection.getItem("All")?.rendered?.toString(), [c.collection]), q = [
34
+ y
35
+ ), m = f(() => c.collection.getItem("All")?.rendered?.toString(), [c.collection]), B = [
35
36
  $ ? "selected" : "",
36
- F ? "focused" : "",
37
- A ? "disabled" : ""
38
- ].join(" "), S = k(
39
- (e) => {
40
- const { allSelected: s, text: i } = W(
41
- e,
37
+ q ? "focused" : "",
38
+ O ? "disabled" : ""
39
+ ].join(" "), b = k(
40
+ (r) => {
41
+ const { allSelected: t, text: p } = X(
42
+ r,
43
+ a,
42
44
  g,
43
- y,
44
- b
45
+ m
45
46
  );
46
- n?.(`${r}CheckAll`, s ? i : ""), t(i);
47
+ n?.(`${e}CheckAll`, t ? p : ""), i(p);
47
48
  },
48
- [g, b, y, r, t, n]
49
- ), B = k(
50
- (e) => {
51
- if (e.target.checked) {
52
- const s = [...C].sort();
53
- n?.(`${r}Options`, s), n?.(`${r}CheckAll`, e.target.value), t(e.target.value);
49
+ [a, m, g, e, i, n]
50
+ ), K = k(
51
+ (r) => {
52
+ if (r.target.checked) {
53
+ const t = [...A].sort();
54
+ n?.(`${e}Options`, t), n?.(`${e}CheckAll`, r.target.value), i(r.target.value);
54
55
  } else
55
- n?.(`${r}Options`, []), n?.(`${r}CheckAll`, ""), t("");
56
+ n?.(`${e}Options`, []), n?.(`${e}CheckAll`, ""), i("");
56
57
  },
57
- [C, r, t, n]
58
- ), K = k(
59
- (e) => {
60
- const s = e.target.value, i = f?.(`${r}Options`) ?? [], v = Array.isArray(i) ? i : i ? [i] : [], L = e.target.checked ? [...v, s] : v.filter((U) => U !== s);
61
- n?.(`${r}Options`, L), S(L);
58
+ [A, e, i, n]
59
+ ), M = k(
60
+ (r) => {
61
+ const t = r.target.value, p = j(h?.(`${e}Options`)), T = r.target.checked ? [...p, t] : p.filter((E) => E !== t);
62
+ n?.(`${e}Options`, T), b(T);
62
63
  },
63
- [r, n, f, S]
64
- ), l = f?.(`${r}Options`), m = h(() => Array.isArray(l) ? l : typeof l == "string" && l ? [l] : [], [l]), M = h(
65
- () => m.includes(o.key.toString()),
66
- [m, o.key]
67
- ), x = f?.(`${r}CheckAll`), N = h(() => !!x, [x]), P = o.key === "All" ? /* @__PURE__ */ d(
68
- T,
64
+ [e, n, h, b]
65
+ ), S = h?.(`${e}Options`), v = f(
66
+ () => j(S),
67
+ [S]
68
+ ), N = f(
69
+ () => v.includes(o.key.toString()),
70
+ [v, o.key]
71
+ ), x = h?.(`${e}CheckAll`), P = f(() => !!x, [x]), R = o.key === "All" ? /* @__PURE__ */ l(
72
+ u,
69
73
  {
70
- checked: N,
74
+ checked: P,
71
75
  label: o.rendered?.toString(),
72
- name: `${r}CheckAll`,
73
- onChange: B,
76
+ name: `${e}CheckAll`,
77
+ onChange: K,
74
78
  value: o.rendered?.toString()
75
79
  }
76
- ) : /* @__PURE__ */ d(
77
- T,
80
+ ) : /* @__PURE__ */ l(
81
+ u,
78
82
  {
79
- checked: M,
83
+ checked: N,
80
84
  label: o.rendered?.toString(),
81
- name: `${r}Options`,
82
- onChange: K,
85
+ name: `${e}Options`,
86
+ onChange: M,
83
87
  value: o.key.toString()
84
88
  }
85
- ), u = p && !A ? P : /* @__PURE__ */ d(
86
- _,
89
+ ), L = s && !O ? R : /* @__PURE__ */ l(
90
+ I,
87
91
  {
88
- color: w.palette.gray[800],
92
+ color: z.palette.gray[800],
89
93
  size: "md",
90
94
  textOverflow: "ellipsis",
91
95
  whiteSpace: "nowrap",
92
96
  children: o.rendered
93
97
  }
94
- ), R = k(
95
- (e) => {
96
- e.preventDefault(), t(o.rendered?.toString() ?? ""), c.setSelectedKey(o.key), requestAnimationFrame(() => {
98
+ ), U = k(
99
+ (r) => {
100
+ r.preventDefault(), i(o.rendered?.toString() ?? ""), c.setSelectedKey(o.key), requestAnimationFrame(() => {
97
101
  c.setOpen(!1);
98
- }), V(a);
102
+ }), oo(d);
99
103
  },
100
- [a, o.key, o.rendered, c, t]
104
+ [d, o.key, o.rendered, c, i]
101
105
  );
102
- return I(D, () => {
103
- p && c.close();
104
- }, [j]), /* @__PURE__ */ E(
105
- Q,
106
+ return V(w, () => {
107
+ s && c.close();
108
+ }, [D]), /* @__PURE__ */ G(
109
+ W,
106
110
  {
107
- ...!p && !a ? z : {},
108
- $multiSelection: p,
109
- className: q,
110
- ref: O,
111
+ ...!s && !d ? F : {},
112
+ $multiSelection: s,
113
+ className: B,
114
+ ref: y,
111
115
  children: [
112
- a ? /* @__PURE__ */ d(Y, { href: a, onClick: R, children: u }) : u,
113
- $ && !A && !p ? /* @__PURE__ */ d(X, { icon: "check", iconSize: "sm", iconType: "fa-light" }) : void 0,
114
- o.rendered === o.textValue ? void 0 : /* @__PURE__ */ d(Z, { tagLabel: o.textValue, variant: "inactive" })
116
+ d ? /* @__PURE__ */ l(Z, { href: d, onClick: U, children: L }) : L,
117
+ $ && !O && !s ? /* @__PURE__ */ l(Y, { icon: "check", iconSize: "sm", iconType: "fa-light" }) : void 0,
118
+ C === void 0 ? void 0 : /* @__PURE__ */ l(_, { tagLabel: C, variant: "inactive" })
115
119
  ]
116
120
  }
117
121
  );
118
122
  };
119
123
  export {
120
- yo as Option
124
+ Co as Option
121
125
  };
@@ -28,6 +28,7 @@ interface IItem {
28
28
  * @property { string } name - The name of the Select.
29
29
  * @property { MutableRefObject } popoverRef - The ref of the options popover.
30
30
  * @property { ComboBoxState<T> } state - The state of the ComboBox.
31
+ * @property { string } [tag] - Optional tag shown next to the option.
31
32
  */
32
33
  interface IOptionProps<T> {
33
34
  allItemKeys: string[];
@@ -39,6 +40,7 @@ interface IOptionProps<T> {
39
40
  setInputValue: React.Dispatch<React.SetStateAction<string>>;
40
41
  state: ComboBoxState<T>;
41
42
  setValue?: UseFormSetValue<any>;
43
+ tag?: string;
42
44
  watch?: UseFormWatch<any>;
43
45
  }
44
46
  /**
@@ -0,0 +1,4 @@
1
+ import { IStepperProps, IStepperStep } from './types';
2
+ declare const Stepper: ({ completedLabel, currentStep, steps, }: Readonly<IStepperProps>) => JSX.Element;
3
+ export { Stepper };
4
+ export type { IStepperProps, IStepperStep };
@@ -0,0 +1,50 @@
1
+ import { jsxs as m, jsx as t } from "react/jsx-runtime";
2
+ import { Fragment as d } from "react";
3
+ import { VisuallyHidden as a } from "../../node_modules/react-aria/dist/private/visually-hidden/VisuallyHidden.js";
4
+ import { useTheme as s } from "styled-components";
5
+ import { StyledStepRow as h, StyledStepItem as u, StyledStepIndicator as f, StyledStepConnector as g } from "./styles.js";
6
+ import { Icon as S } from "../icon/index.js";
7
+ import "../typography/heading/index.js";
8
+ import "../typography/span/index.js";
9
+ import { Text as y } from "../typography/text/index.js";
10
+ const $ = (n, e) => n < e ? "completed" : n === e ? "current" : "upcoming", C = ({
11
+ completedLabel: n = "completed",
12
+ currentStep: e,
13
+ steps: c
14
+ }) => {
15
+ const l = s();
16
+ return /* @__PURE__ */ m(d, { children: [
17
+ /* @__PURE__ */ t(h, { children: c.map((r, o) => {
18
+ const i = $(o, e), p = i === "upcoming";
19
+ return /* @__PURE__ */ m(
20
+ u,
21
+ {
22
+ "aria-current": i === "current" ? "step" : void 0,
23
+ children: [
24
+ /* @__PURE__ */ t(f, { $status: i, children: i === "completed" ? /* @__PURE__ */ t(S, { icon: "check", iconSize: "sm", iconType: "fa-solid" }) : o + 1 }),
25
+ /* @__PURE__ */ m(
26
+ y,
27
+ {
28
+ color: p ? l.palette.gray[400] : l.palette.gray[800],
29
+ display: "inline",
30
+ fontWeight: p ? "regular" : "bold",
31
+ size: "md",
32
+ whiteSpace: "nowrap",
33
+ children: [
34
+ r.title,
35
+ i === "completed" && /* @__PURE__ */ t(a, { children: ` (${n})` })
36
+ ]
37
+ }
38
+ ),
39
+ o < c.length - 1 && /* @__PURE__ */ t(g, { "aria-hidden": !0 })
40
+ ]
41
+ },
42
+ r.title
43
+ );
44
+ }) }),
45
+ c.map((r, o) => /* @__PURE__ */ t("div", { hidden: o !== e, children: r.content }, r.title))
46
+ ] });
47
+ };
48
+ export {
49
+ C as Stepper
50
+ };
@@ -0,0 +1,6 @@
1
+ import { Meta } from '@storybook/react-vite';
2
+ import { IStepperProps } from './types';
3
+ declare const config: Meta;
4
+ declare const Default: import('storybook/internal/csf').AnnotatedStoryFn<import('@storybook/react').ReactRenderer, IStepperProps>;
5
+ export { Default };
6
+ export default config;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { TStepperStatus } from './types';
2
+ declare const StyledStepRow: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').OlHTMLAttributes<HTMLOListElement>, HTMLOListElement>, never>>> & string;
3
+ declare const StyledStepItem: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').LiHTMLAttributes<HTMLLIElement>, HTMLLIElement>, never>>> & string;
4
+ declare const StyledStepIndicator: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "$status"> & {
5
+ $status: TStepperStatus;
6
+ }, never> & Partial<Pick<import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, "$status"> & {
7
+ $status: TStepperStatus;
8
+ }, never>>> & string;
9
+ declare const StyledStepConnector: import('styled-components/dist/types').IStyledComponentBase<"web", import('styled-components').FastOmit<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never> & Partial<Pick<import('react').DetailedHTMLProps<import('react').HTMLAttributes<HTMLSpanElement>, HTMLSpanElement>, never>>> & string;
10
+ export { StyledStepConnector, StyledStepIndicator, StyledStepItem, StyledStepRow, };
@@ -0,0 +1,65 @@
1
+ import { styled as i } from "styled-components";
2
+ import { variantBuilder as a } from "../@core/variants/utils.js";
3
+ const { getVariant: n } = a(
4
+ (t) => ({
5
+ completed: `
6
+ background-color: ${t.palette.success[500]};
7
+ color: ${t.palette.white};
8
+ `,
9
+ current: `
10
+ background-color: ${t.palette.gray[800]};
11
+ color: ${t.palette.white};
12
+ `,
13
+ upcoming: `
14
+ background-color: ${t.palette.white};
15
+ border: 1px solid ${t.palette.gray[400]};
16
+ color: ${t.palette.gray[400]};
17
+ `
18
+ })
19
+ ), r = i.ol`
20
+ align-items: center;
21
+ display: flex;
22
+ gap: ${({ theme: t }) => t.spacing[0.75]};
23
+ list-style: none;
24
+ margin: 0;
25
+ margin-bottom: ${({ theme: t }) => t.spacing[1.5]};
26
+ padding: 0;
27
+ `, p = i.li`
28
+ align-items: center;
29
+ display: flex;
30
+ flex: 1 1 0;
31
+ gap: ${({ theme: t }) => t.spacing[0.75]};
32
+ min-width: 0;
33
+
34
+ &:last-child {
35
+ flex: 0 0 auto;
36
+ }
37
+ `, c = i.span`
38
+ ${({ theme: t, $status: o }) => `
39
+ align-items: center;
40
+ border-radius: 50%;
41
+ box-sizing: border-box;
42
+ display: inline-flex;
43
+ flex-shrink: 0;
44
+ font-family: ${t.typography.type.primary};
45
+ font-size: ${t.typography.text.md};
46
+ font-weight: ${t.typography.weight.bold};
47
+ line-height: ${t.spacing[1.25]};
48
+ height: ${t.spacing[1.5]};
49
+ justify-content: center;
50
+ width: ${t.spacing[1.5]};
51
+
52
+ ${n(t, o)}
53
+ `}
54
+ `, g = i.span`
55
+ background-color: ${({ theme: t }) => t.palette.gray[300]};
56
+ flex: 1 1 auto;
57
+ height: 1px;
58
+ min-width: ${({ theme: t }) => t.spacing[1]};
59
+ `;
60
+ export {
61
+ g as StyledStepConnector,
62
+ c as StyledStepIndicator,
63
+ p as StyledStepItem,
64
+ r as StyledStepRow
65
+ };
@@ -0,0 +1,25 @@
1
+ import { ReactNode } from 'react';
2
+ type TStepperStatus = "completed" | "current" | "upcoming";
3
+ /**
4
+ * Stepper step props.
5
+ * @interface IStepperStep
6
+ * @property { ReactNode } content - The step's panel. It stays mounted while other steps are current, so form fields keep their registration and values.
7
+ * @property { string } title - The step's label in the progress row; must be unique among the steps.
8
+ */
9
+ interface IStepperStep {
10
+ content: ReactNode;
11
+ title: string;
12
+ }
13
+ /**
14
+ * Stepper component props.
15
+ * @interface IStepperProps
16
+ * @property { string } [completedLabel] - Screen-reader suffix announced after each completed step's title. Defaults to "completed".
17
+ * @property { number } currentStep - Zero-based index of the current step, owned by the consumer: steps before it render as completed, steps after it as upcoming.
18
+ * @property { IStepperStep[] } steps - The steps, in order.
19
+ */
20
+ interface IStepperProps {
21
+ completedLabel?: string;
22
+ currentStep: number;
23
+ steps: IStepperStep[];
24
+ }
25
+ export type { IStepperProps, IStepperStep, TStepperStatus };
package/dist/index.d.ts CHANGED
@@ -72,6 +72,7 @@ export * from './components/show-on-hover';
72
72
  export * from './components/slide-out-menu';
73
73
  export * from './components/slider';
74
74
  export * from './components/step-lapse';
75
+ export * from './components/stepper';
75
76
  export * from './components/summary-card';
76
77
  export * from './components/table';
77
78
  export * from './components/table-button';