bonkers-ui 2.0.9 → 2.0.11
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/UiNavigationSteps-N3juxg3H.js +103 -0
- package/UiNavigationSteps-N3juxg3H.js.map +1 -0
- package/assets/UiNavigationSteps.css +1 -0
- package/components/UiInput/_types.d.ts +2 -1
- package/components/UiInput/_types.js +1 -1
- package/components/UiInput/_types.js.map +1 -1
- package/components/UiNavigationSteps/UiNavigationStep.d.ts +3 -0
- package/components/UiNavigationSteps/UiNavigationStep.js +115 -0
- package/components/UiNavigationSteps/UiNavigationStep.js.map +1 -0
- package/components/UiNavigationSteps/UiNavigationSteps.d.ts +9 -0
- package/components/UiNavigationSteps/UiNavigationSteps.js +9 -0
- package/components/UiNavigationSteps/UiNavigationSteps.js.map +1 -0
- package/components/UiNavigationSteps/_types.d.ts +29 -0
- package/components/UiNavigationSteps/_types.js +5 -0
- package/components/UiNavigationSteps/_types.js.map +1 -0
- package/components/UiNavigationSteps/index.d.ts +3 -0
- package/components/UiNavigationSteps/index.js +9 -0
- package/components/UiNavigationSteps/index.js.map +1 -0
- package/components/UiSelect/UiSelect.d.ts +1 -0
- package/components/UiSelect/UiSelect.js +57 -62
- package/components/UiSelect/UiSelect.js.map +1 -1
- package/index.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import f, { createContext as z, useRef as g, useState as m, useEffect as U, useContext as j } from "react";
|
|
3
|
+
import A from "classnames";
|
|
4
|
+
import './assets/UiNavigationSteps.css';const D = "_navbar_3w204_1", O = "_active_3w204_18", R = {
|
|
5
|
+
navbar: D,
|
|
6
|
+
active: O
|
|
7
|
+
}, S = z(null), W = ({ initialStepId: o, children: w, className: h, complete: i = !1 }) => {
|
|
8
|
+
const l = g(0), [x, C] = m(0), [v, p] = m(/* @__PURE__ */ new Set()), n = g({
|
|
9
|
+
steps: /* @__PURE__ */ new Map(),
|
|
10
|
+
parentMap: /* @__PURE__ */ new Map()
|
|
11
|
+
}), E = (e, s) => {
|
|
12
|
+
n.current.steps.has(e) || (l.current += 1, n.current.steps.set(e, {
|
|
13
|
+
order: l.current,
|
|
14
|
+
hasSubsteps: s,
|
|
15
|
+
progress: s ? {
|
|
16
|
+
current: 0,
|
|
17
|
+
total: 0
|
|
18
|
+
} : void 0
|
|
19
|
+
}));
|
|
20
|
+
}, d = (e) => {
|
|
21
|
+
const { steps: s, parentMap: r } = n.current;
|
|
22
|
+
let t = null;
|
|
23
|
+
if (s.has(e))
|
|
24
|
+
t = s.get(e).order;
|
|
25
|
+
else if (r.has(e)) {
|
|
26
|
+
const a = r.get(e);
|
|
27
|
+
s.has(a) && (t = s.get(a).order);
|
|
28
|
+
}
|
|
29
|
+
t !== null && (t < x && N(t), P(t), C(t));
|
|
30
|
+
}, M = (e, s, r = []) => {
|
|
31
|
+
if (r.length > 0) {
|
|
32
|
+
r.forEach((c) => {
|
|
33
|
+
n.current.parentMap.set(c.id, e);
|
|
34
|
+
});
|
|
35
|
+
const t = r.findIndex((c) => c.id === s) + 1, a = r.length;
|
|
36
|
+
if (t > 0) {
|
|
37
|
+
const c = n.current.steps.get(e);
|
|
38
|
+
c && n.current.steps.set(e, {
|
|
39
|
+
...c,
|
|
40
|
+
progress: {
|
|
41
|
+
current: t,
|
|
42
|
+
total: a
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}, N = (e) => {
|
|
48
|
+
p((s) => {
|
|
49
|
+
const r = new Set(s);
|
|
50
|
+
return n.current.steps.forEach((t, a) => {
|
|
51
|
+
t.order > e && r.delete(a);
|
|
52
|
+
}), r;
|
|
53
|
+
});
|
|
54
|
+
}, P = (e) => {
|
|
55
|
+
p(i ? new Set(n.current.steps.keys()) : (s) => {
|
|
56
|
+
const r = new Set(s);
|
|
57
|
+
return n.current.steps.forEach((t, a) => {
|
|
58
|
+
t.order < e ? r.add(a) : t.order === e && r.delete(a);
|
|
59
|
+
}), r;
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
U(() => {
|
|
63
|
+
const { steps: e, parentMap: s } = n.current;
|
|
64
|
+
if (e.size > 0) {
|
|
65
|
+
let r = o;
|
|
66
|
+
if (s.has(o)) {
|
|
67
|
+
const t = s.get(o);
|
|
68
|
+
t && e.has(t) && (r = t);
|
|
69
|
+
}
|
|
70
|
+
p(i ? new Set(e.keys()) : /* @__PURE__ */ new Set()), e.has(r) && d(r);
|
|
71
|
+
}
|
|
72
|
+
}, [o, i]);
|
|
73
|
+
const _ = {
|
|
74
|
+
currentStepId: o,
|
|
75
|
+
registerStep: E,
|
|
76
|
+
navigateToStep: d,
|
|
77
|
+
updateSubstepProgress: M,
|
|
78
|
+
completedSteps: v
|
|
79
|
+
}, b = (e) => e === o || n.current.parentMap.get(o) === e, k = (e) => v.has(e), y = f.Children.map(w, (e, s) => {
|
|
80
|
+
if (f.isValidElement(e)) {
|
|
81
|
+
const r = n.current.steps.get(e.props.id), t = n.current.steps.size;
|
|
82
|
+
return f.cloneElement(e, {
|
|
83
|
+
order: r?.order || s + 1,
|
|
84
|
+
totalSteps: t,
|
|
85
|
+
isActive: b(e.props.id),
|
|
86
|
+
isComplete: k(e.props.id)
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return e;
|
|
90
|
+
});
|
|
91
|
+
return /* @__PURE__ */ u(S.Provider, { value: _, children: /* @__PURE__ */ u("nav", { "aria-label": "Progress", className: A("relative grid grid-cols-1 grid-rows-1 items-center", R.navbar, h), children: /* @__PURE__ */ u("div", { className: "z-10 flex items-center justify-between", children: y }) }) });
|
|
92
|
+
}, B = () => {
|
|
93
|
+
const o = j(S);
|
|
94
|
+
if (!o)
|
|
95
|
+
throw new Error("useStepNav must be used within a UiNavigationStepsProvider");
|
|
96
|
+
return o;
|
|
97
|
+
};
|
|
98
|
+
export {
|
|
99
|
+
W as U,
|
|
100
|
+
R as s,
|
|
101
|
+
B as u
|
|
102
|
+
};
|
|
103
|
+
//# sourceMappingURL=UiNavigationSteps-N3juxg3H.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiNavigationSteps-N3juxg3H.js","sources":["../src/components/UiNavigationSteps/UiNavigationSteps.tsx"],"sourcesContent":["import React, {\n\tcreateContext,\n\tuseContext,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n} from \"react\";\nimport { type INavStepProps, type INavigationStepContext, type INavSubStep } from \"./_types\";\nimport cx from \"classnames\";\nimport styles from \"./UiNavigationSteps.module.css\";\n\nconst NavigationStepContext = createContext<INavigationStepContext | null>(null);\n\ninterface INavigationStepData {\n\torder: number;\n\thasSubsteps: boolean;\n\tprogress?: {\n\t\tcurrent: number;\n\t\ttotal: number;\n\t};\n}\n\ninterface INavigationProviderState {\n\tsteps: Map<string, INavigationStepData>;\n\tparentMap: Map<string, string>;\n}\n\nexport const UiNavigationSteps: React.FC<{\n\tinitialStepId: string;\n\tchildren: React.ReactNode;\n\tclassName?: string;\n\tcomplete?: boolean\n}> = ({ initialStepId, children, className, complete = false }) => {\n\tconst orderCounter = useRef(0);\n\tconst [currentStepOrder, setCurrentStepOrder] = useState<number>(0);\n\tconst [completedSteps, setCompletedSteps] = useState<Set<string>>(new Set());\n\n\tconst navigationState = useRef<INavigationProviderState>({\n\t\tsteps: new Map(),\n\t\tparentMap: new Map(),\n\t});\n\n\tconst registerStep = (id: string, hasSubsteps: boolean) => {\n\t\tif (!navigationState.current.steps.has(id)) {\n\t\t\torderCounter.current += 1;\n\t\t\tnavigationState.current.steps.set(id, {\n\t\t\t\torder: orderCounter.current,\n\t\t\t\thasSubsteps,\n\t\t\t\tprogress: hasSubsteps\n\t\t\t\t\t? {\n\t\t\t\t\t\tcurrent: 0,\n\t\t\t\t\t\ttotal: 0\n\t\t\t\t\t}\n\t\t\t\t\t: undefined\n\t\t\t});\n\t\t}\n\t};\n\n\tconst navigateToStep = (id: string) => {\n\t\tconst { steps, parentMap } = navigationState.current;\n\t\tlet targetOrder: number | null = null;\n\n\t\tif (steps.has(id)) {\n\t\t\ttargetOrder = steps.get(id)!.order;\n\t\t} else if (parentMap.has(id)) {\n\t\t\tconst parentId = parentMap.get(id)!;\n\t\t\tif (steps.has(parentId)) {\n\t\t\t\ttargetOrder = steps.get(parentId)!.order;\n\t\t\t}\n\t\t}\n\n\t\tif (targetOrder !== null) {\n\t\t\tif (targetOrder < currentStepOrder) {\n\t\t\t\tmarkSubsequentStepsIncomplete(targetOrder);\n\t\t\t}\n\t\t\tmarkPreviousStepsComplete(targetOrder);\n\t\t\tsetCurrentStepOrder(targetOrder);\n\t\t}\n\t};\n\n\tconst updateSubstepProgress = (stepId: string, substepId: string, subSteps: INavSubStep[] = []) => {\n\t\tif (subSteps.length > 0) {\n\t\t\tsubSteps.forEach(sub => {\n\t\t\t\tnavigationState.current.parentMap.set(sub.id, stepId);\n\t\t\t});\n\n\t\t\tconst current = subSteps.findIndex(sub => sub.id === substepId) + 1;\n\t\t\tconst total = subSteps.length;\n\n\t\t\tif (current > 0) {\n\t\t\t\tconst stepData = navigationState.current.steps.get(stepId);\n\t\t\t\tif (stepData) {\n\t\t\t\t\tnavigationState.current.steps.set(stepId, {\n\t\t\t\t\t\t...stepData,\n\t\t\t\t\t\tprogress: {\n\t\t\t\t\t\t\tcurrent,\n\t\t\t\t\t\t\ttotal\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\n\tconst markSubsequentStepsIncomplete = (targetOrder: number) => {\n\t\tsetCompletedSteps(prev => {\n\t\t\tconst newSet = new Set(prev);\n\t\t\tnavigationState.current.steps.forEach((data, id) => {\n\t\t\t\tif (data.order > targetOrder) {\n\t\t\t\t\tnewSet.delete(id);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn newSet;\n\t\t});\n\t};\n\n\tconst markPreviousStepsComplete = (targetOrder: number) => {\n\t\tif (!complete) {\n\t\t\tsetCompletedSteps(prev => {\n\t\t\t\tconst newSet = new Set(prev);\n\t\t\t\tnavigationState.current.steps.forEach((data, id) => {\n\t\t\t\t\tif (data.order < targetOrder) {\n\t\t\t\t\t\tnewSet.add(id);\n\t\t\t\t\t} else if (data.order === targetOrder) {\n\t\t\t\t\t\tnewSet.delete(id);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\treturn newSet;\n\t\t\t});\n\t\t} else {\n\t\t\tsetCompletedSteps(new Set(navigationState.current.steps.keys()));\n\t\t}\n\t};\n\n\tuseEffect(() => {\n\t\tconst { steps, parentMap } = navigationState.current;\n\n\t\tif (steps.size > 0) {\n\t\t\tlet targetStepId = initialStepId;\n\n\t\t\tif (parentMap.has(initialStepId)) {\n\t\t\t\tconst parentId = parentMap.get(initialStepId);\n\t\t\t\tif (parentId && steps.has(parentId)) {\n\t\t\t\t\ttargetStepId = parentId;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (complete) {\n\t\t\t\tsetCompletedSteps(new Set(steps.keys()));\n\t\t\t} else {\n\t\t\t\tsetCompletedSteps(new Set());\n\t\t\t}\n\n\t\t\tif (steps.has(targetStepId)) {\n\t\t\t\tnavigateToStep(targetStepId);\n\t\t\t}\n\t\t}\n\t}, [initialStepId, complete]);\n\n\tconst contextValue: INavigationStepContext = {\n\t\tcurrentStepId: initialStepId,\n\t\tregisterStep,\n\t\tnavigateToStep,\n\t\tupdateSubstepProgress,\n\t\tcompletedSteps,\n\t};\n\n\tconst isStepActive = (id: string) => {\n\t\treturn id === initialStepId\n\t\t\t|| navigationState.current.parentMap.get(initialStepId) === id;\n\t};\n\n\tconst isStepComplete = (id: string) => {\n\t\treturn completedSteps.has(id);\n\t};\n\n\tconst childWithProps = React.Children.map(children, (child, index) => {\n\t\tif (React.isValidElement<INavStepProps>(child)) {\n\t\t\tconst stepData = navigationState.current.steps.get(child.props.id);\n\t\t\tconst totalSteps = navigationState.current.steps.size;\n\n\t\t\treturn React.cloneElement(child, {\n\t\t\t\torder: stepData?.order || index + 1,\n\t\t\t\ttotalSteps,\n\t\t\t\tisActive: isStepActive(child.props.id),\n\t\t\t\tisComplete: isStepComplete(child.props.id),\n\t\t\t});\n\t\t}\n\t\treturn child;\n\t});\n\n\treturn (\n\t\t<NavigationStepContext.Provider value={ contextValue }>\n\t\t\t<nav aria-label=\"Progress\" className={ cx(\"relative grid grid-cols-1 grid-rows-1 items-center\", styles.navbar, className) }>\n\t\t\t\t<div className=\"z-10 flex items-center justify-between\">\n\t\t\t\t\t{ childWithProps }\n\t\t\t\t</div>\n\t\t\t</nav>\n\t\t</NavigationStepContext.Provider>\n\t);\n};\n\nexport const useStepNav = () => {\n\tconst context = useContext(NavigationStepContext);\n\tif (!context) {\n\t\tthrow new Error(\"useStepNav must be used within a UiNavigationStepsProvider\");\n\t}\n\treturn context;\n};\n"],"names":["NavigationStepContext","createContext","UiNavigationSteps","initialStepId","children","className","complete","orderCounter","useRef","currentStepOrder","setCurrentStepOrder","useState","completedSteps","setCompletedSteps","navigationState","registerStep","id","hasSubsteps","navigateToStep","steps","parentMap","targetOrder","parentId","markSubsequentStepsIncomplete","markPreviousStepsComplete","updateSubstepProgress","stepId","substepId","subSteps","sub","current","total","stepData","prev","newSet","data","useEffect","targetStepId","contextValue","isStepActive","isStepComplete","childWithProps","React","child","index","totalSteps","jsx","cx","styles","useStepNav","context","useContext"],"mappings":";;;;;;GAWMA,IAAwBC,EAA6C,IAAI,GAgBlEC,IAKR,CAAC,EAAE,eAAAC,GAAe,UAAAC,GAAU,WAAAC,GAAW,UAAAC,IAAW,SAAY;AAC5D,QAAAC,IAAeC,EAAO,CAAC,GACvB,CAACC,GAAkBC,CAAmB,IAAIC,EAAiB,CAAC,GAC5D,CAACC,GAAgBC,CAAiB,IAAIF,EAAsB,oBAAI,KAAK,GAErEG,IAAkBN,EAAiC;AAAA,IACxD,2BAAW,IAAI;AAAA,IACf,+BAAe,IAAI;AAAA,EAAA,CACnB,GAEKO,IA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AA,IAC5C,eAAenC;AAAA,IACf,cAAAY;AAAA,IACA,gBAAAG;AAAA,IACA,uBAAAO;AAAA,IACA,gBAAAb;AAAA,EACD,GAEM2B,IAAe,CAACvB,MACdA,MAAOb,KACVW,EAAgB,QAAQ,UAAU,IAAIX,CAAa,MAAMa,GAGxDwB,IAAiB,CAACxB,MAChBJ,EAAe,IAAII,CAAE,GAGvByB,IAAiBC,EAAM,SAAS,IAAItC,GAAU,CAACuC,GAAOC,MAAU;AACjE,QAAAF,EAAM,eAA8BC,CAAK,GAAG;AAC/C,YAAMX,IAAWlB,EAAgB,QAAQ,MAAM,IAAI6B,EAAM,MAAM,EAAE,GAC3DE,IAAa/B,EAAgB,QAAQ,MAAM;AAE1C,aAAA4B,EAAM,aAAaC,GAAO;AAAA,QAChC,OAAOX,GAAU,SAASY,IAAQ;AAAA,QAClC,YAAAC;AAAA,QACA,UAAUN,EAAaI,EAAM,MAAM,EAAE;AAAA,QACrC,YAAYH,EAAeG,EAAM,MAAM,EAAE;AAAA,MAAA,CACzC;AAAA,IAAA;AAEK,WAAAA;AAAA,EAAA,CACP;AAGA,SAAA,gBAAAG,EAAC9C,EAAsB,UAAtB,EAA+B,OAAQsC,GACvC,UAAA,gBAAAQ,EAAC,OAAI,EAAA,cAAW,YAAW,WAAYC,EAAG,sDAAsDC,EAAO,QAAQ3C,CAAS,GACvH,UAAA,gBAAAyC,EAAC,SAAI,WAAU,0CACZ,UACHL,EAAA,CAAA,EAAA,CACD,EACD,CAAA;AAEF,GAEaQ,IAAa,MAAM;AACzB,QAAAC,IAAUC,EAAWnD,CAAqB;AAChD,MAAI,CAACkD;AACE,UAAA,IAAI,MAAM,4DAA4D;AAEtE,SAAAA;AACR;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._navbar_3w204_1:before{content:"";position:absolute;left:0;right:0;height:1px;top:15px;background-color:var(--color-secondary-alt-500);width:98%}@media (min-width: 768px){._navbar_3w204_1:before{top:20px}}._active_3w204_18:before{content:"";position:absolute;left:0;right:0;height:1px;top:15px;background-color:var(--color-secondary-400);width:var(--step-width, 0%);z-index:-1}@media screen and (min-width: 768px){._active_3w204_18:before{top:20px}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var S = /* @__PURE__ */ ((R) => (R.DEFAULT = "DEFAULT", R.ERROR = "ERROR", R.SUCCESS = "SUCCESS", R))(S || {});
|
|
1
|
+
var S = /* @__PURE__ */ ((R) => (R.DEFAULT = "DEFAULT", R.ERROR = "ERROR", R.SUCCESS = "SUCCESS", R.WARNING = "WARNING", R))(S || {});
|
|
2
2
|
export {
|
|
3
3
|
S as EInputKind
|
|
4
4
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_types.js","sources":["../../../src/components/UiInput/_types.ts"],"sourcesContent":["export enum EInputKind {\n\tDEFAULT = \"DEFAULT\",\n\tERROR = \"ERROR\",\n\tSUCCESS = \"SUCCESS\",\n}\n"],"names":["EInputKind"],"mappings":"AAAY,IAAAA,sBAAAA,OACXA,EAAA,UAAU,WACVA,EAAA,QAAQ,SACRA,EAAA,UAAU,
|
|
1
|
+
{"version":3,"file":"_types.js","sources":["../../../src/components/UiInput/_types.ts"],"sourcesContent":["export enum EInputKind {\n\tDEFAULT = \"DEFAULT\",\n\tERROR = \"ERROR\",\n\tSUCCESS = \"SUCCESS\",\n\tWARNING = \"WARNING\",\n}\n"],"names":["EInputKind"],"mappings":"AAAY,IAAAA,sBAAAA,OACXA,EAAA,UAAU,WACVA,EAAA,QAAQ,SACRA,EAAA,UAAU,WACVA,EAAA,UAAU,WAJCA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { jsx as m, jsxs as E } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect as w } from "react";
|
|
3
|
+
import n from "classnames";
|
|
4
|
+
import { ENavStepStatus as e } from "./_types.js";
|
|
5
|
+
import { UiTypography as g } from "../UiTypography/UiTypography.js";
|
|
6
|
+
import { ETypographySizes as h, ETextWeight as I } from "../UiTypography/_types.js";
|
|
7
|
+
import { u as $, s as S } from "../../UiNavigationSteps-N3juxg3H.js";
|
|
8
|
+
function z(r, a) {
|
|
9
|
+
return n(
|
|
10
|
+
`
|
|
11
|
+
flex
|
|
12
|
+
transform
|
|
13
|
+
items-center
|
|
14
|
+
justify-center
|
|
15
|
+
rounded-full
|
|
16
|
+
border
|
|
17
|
+
text-secondary-400
|
|
18
|
+
transition-all
|
|
19
|
+
duration-100
|
|
20
|
+
ease-in-out
|
|
21
|
+
md:h-xl
|
|
22
|
+
md:w-full
|
|
23
|
+
md:px-xs
|
|
24
|
+
md:py-xxs
|
|
25
|
+
lg:px-sm
|
|
26
|
+
`,
|
|
27
|
+
!a && "bg-secondary-400",
|
|
28
|
+
a && "cursor-pointer",
|
|
29
|
+
r === e.COMPLETE && "size-sm border-secondary-400 bg-secondary-400 p-xs text-white",
|
|
30
|
+
r === e.ACTIVE && "border-secondary-400 bg-secondary-alt-200 px-xs py-xxs text-secondary-400",
|
|
31
|
+
r === e.INACTIVE && "size-sm border-secondary-alt-500 bg-white p-xs text-secondary-alt-500"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
const R = ({
|
|
35
|
+
id: r,
|
|
36
|
+
name: a,
|
|
37
|
+
subSteps: s = [],
|
|
38
|
+
className: T = "",
|
|
39
|
+
onClick: y,
|
|
40
|
+
order: l = 1,
|
|
41
|
+
totalSteps: u = 1,
|
|
42
|
+
isActive: C = !1,
|
|
43
|
+
isComplete: c = !1,
|
|
44
|
+
icon: A
|
|
45
|
+
}) => {
|
|
46
|
+
const { currentStepId: i, updateSubstepProgress: p, registerStep: N } = $(), f = s.some((x) => x.id === i), o = s.length > 0;
|
|
47
|
+
w(() => {
|
|
48
|
+
N(r, o), o && p(r, i, s);
|
|
49
|
+
}, [r, o, s, i, p]);
|
|
50
|
+
const t = !c && (C || f) ? e.ACTIVE : c ? e.COMPLETE : e.INACTIVE, V = () => {
|
|
51
|
+
t !== e.INACTIVE && y?.();
|
|
52
|
+
}, b = () => l / u * 100, d = t !== e.INACTIVE, v = o ? c ? ` ${s.length}/${s.length}` : f ? ` ${s.findIndex((x) => x.id === i) + 1}/${s.length}` : ` ${l}/${s.length}` : null;
|
|
53
|
+
return /* @__PURE__ */ m(
|
|
54
|
+
"div",
|
|
55
|
+
{
|
|
56
|
+
style: t === e.ACTIVE ? {
|
|
57
|
+
"--step-width": `${b()}%`
|
|
58
|
+
} : {},
|
|
59
|
+
className: n(
|
|
60
|
+
"flex flex-col gap-xxs md:flex-row md:items-center",
|
|
61
|
+
{
|
|
62
|
+
[S.active]: t === e.ACTIVE
|
|
63
|
+
}
|
|
64
|
+
),
|
|
65
|
+
children: /* @__PURE__ */ m(
|
|
66
|
+
"button",
|
|
67
|
+
{
|
|
68
|
+
onClick: V,
|
|
69
|
+
"aria-current": t === e.ACTIVE ? "step" : void 0,
|
|
70
|
+
"aria-disabled": !d,
|
|
71
|
+
disabled: !d,
|
|
72
|
+
className: n(z(t, d), T),
|
|
73
|
+
children: /* @__PURE__ */ E(
|
|
74
|
+
g,
|
|
75
|
+
{
|
|
76
|
+
className: "flex place-items-center gap-xxs",
|
|
77
|
+
weight: t === e.ACTIVE ? I.SEMI_BOLD : I.REGULAR,
|
|
78
|
+
lineHeight: !0,
|
|
79
|
+
size: h.XS,
|
|
80
|
+
children: [
|
|
81
|
+
t === e.COMPLETE ? A : /* @__PURE__ */ m(
|
|
82
|
+
g,
|
|
83
|
+
{
|
|
84
|
+
className: n({
|
|
85
|
+
"font-semibold md:font-medium": t === e.INACTIVE
|
|
86
|
+
}),
|
|
87
|
+
tag: "span",
|
|
88
|
+
size: h.SM,
|
|
89
|
+
children: l
|
|
90
|
+
}
|
|
91
|
+
),
|
|
92
|
+
/* @__PURE__ */ E(
|
|
93
|
+
"span",
|
|
94
|
+
{
|
|
95
|
+
className: n("text-xxs text-nowrap md:text-xs", {
|
|
96
|
+
"hidden md:inline": t !== e.ACTIVE
|
|
97
|
+
}),
|
|
98
|
+
children: [
|
|
99
|
+
a,
|
|
100
|
+
v
|
|
101
|
+
]
|
|
102
|
+
}
|
|
103
|
+
)
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
)
|
|
107
|
+
}
|
|
108
|
+
)
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
export {
|
|
113
|
+
R as UiNavigationStep
|
|
114
|
+
};
|
|
115
|
+
//# sourceMappingURL=UiNavigationStep.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiNavigationStep.js","sources":["../../../src/components/UiNavigationSteps/UiNavigationStep.tsx"],"sourcesContent":["import React, { useEffect } from \"react\";\nimport cx from \"classnames\";\nimport { ENavStepStatus, type INavStepProps } from \"./_types\";\nimport { ETextWeight, ETypographySizes, UiTypography } from \"../UiTypography\";\nimport { useStepNav } from \"./UiNavigationSteps\";\nimport styles from \"./UiNavigationSteps.module.css\";\n\nfunction getStepClasses(status: ENavStepStatus, isClickable: boolean) {\n\treturn cx(\n\t\t`\n\t\t\tflex\n\t\t\ttransform\n\t\t\titems-center\n\t\t\tjustify-center\n\t\t\trounded-full\n\t\t\tborder\n\t\t\ttext-secondary-400\n\t\t\ttransition-all\n\t\t\tduration-100\n\t\t\tease-in-out\n\t\t\tmd:h-xl\n\t\t\tmd:w-full\n\t\t\tmd:px-xs\n\t\t\tmd:py-xxs\n\t\t\tlg:px-sm\n\t\t`,\n\t\t!isClickable && \"bg-secondary-400\",\n\t\tisClickable && \"cursor-pointer\",\n\t\tstatus === ENavStepStatus.COMPLETE\n\t\t&& \"size-sm border-secondary-400 bg-secondary-400 p-xs text-white\",\n\t\tstatus === ENavStepStatus.ACTIVE\n\t\t&& \"border-secondary-400 bg-secondary-alt-200 px-xs py-xxs text-secondary-400\",\n\t\tstatus === ENavStepStatus.INACTIVE\n\t\t&& \"size-sm border-secondary-alt-500 bg-white p-xs text-secondary-alt-500\",\n\t);\n}\n\nexport const UiNavigationStep: React.FC<INavStepProps> = ({\n\tid,\n\tname,\n\tsubSteps = [],\n\tclassName = \"\",\n\tonClick,\n\torder = 1,\n\ttotalSteps = 1,\n\tisActive = false,\n\tisComplete = false,\n\ticon\n}) => {\n\tconst { currentStepId, updateSubstepProgress, registerStep } = useStepNav();\n\tconst isSubstepActive = subSteps.some((subStep) => subStep.id === currentStepId);\n\tconst hasSubsteps = subSteps.length > 0;\n\n\tuseEffect(() => {\n\t\tregisterStep(id, hasSubsteps);\n\n\t\tif (hasSubsteps) {\n\t\t\tupdateSubstepProgress(id, currentStepId, subSteps);\n\t\t}\n\t}, [id, hasSubsteps, subSteps, currentStepId, updateSubstepProgress]);\n\n\tconst status = !isComplete && (isActive || isSubstepActive)\n\t\t? ENavStepStatus.ACTIVE\n\t\t: isComplete\n\t\t\t? ENavStepStatus.COMPLETE\n\t\t\t: ENavStepStatus.INACTIVE;\n\n\tconst handleClick = () => {\n\t\tif (status !== ENavStepStatus.INACTIVE) {\n\t\t\tonClick?.();\n\t\t}\n\t};\n\n\tconst calculateWidth = () => (order / totalSteps) * 100;\n\n\tconst isClickable = status !== ENavStepStatus.INACTIVE;\n\n\tconst progressText = hasSubsteps\n\t\t? isComplete\n\t\t\t? ` ${subSteps.length}/${subSteps.length}`\n\t\t\t: isSubstepActive\n\t\t\t\t? ` ${subSteps.findIndex((step) => step.id === currentStepId) + 1}/${subSteps.length}`\n\t\t\t\t: ` ${order}/${subSteps.length}`\n\t\t: null;\n\n\treturn (\n\t\t<div\n\t\t\tstyle={ status === ENavStepStatus.ACTIVE\n\t\t\t\t? ({\n\t\t\t\t\t\"--step-width\": `${calculateWidth()}%`\n\t\t\t\t} as React.CSSProperties)\n\t\t\t\t: {} }\n\t\t\tclassName={ cx(\"flex flex-col gap-xxs md:flex-row md:items-center\", {\n\t\t\t\t[styles.active]: status === ENavStepStatus.ACTIVE,\n\t\t\t},\n\t\t\t) }\n\t\t>\n\t\t\t<button\n\t\t\t\tonClick={ handleClick }\n\t\t\t\taria-current={ status === ENavStepStatus.ACTIVE\n\t\t\t\t\t? \"step\"\n\t\t\t\t\t: undefined }\n\t\t\t\taria-disabled={ !isClickable }\n\t\t\t\tdisabled={ !isClickable }\n\t\t\t\tclassName={ cx(getStepClasses(status, isClickable), className) }\n\t\t\t>\n\t\t\t\t<UiTypography\n\t\t\t\t\tclassName=\"flex place-items-center gap-xxs\"\n\t\t\t\t\tweight={ status === ENavStepStatus.ACTIVE\n\t\t\t\t\t\t? ETextWeight.SEMI_BOLD\n\t\t\t\t\t\t: ETextWeight.REGULAR }\n\t\t\t\t\tlineHeight\n\t\t\t\t\tsize={ ETypographySizes.XS }\n\t\t\t\t>\n\t\t\t\t\t{ status === ENavStepStatus.COMPLETE\n\t\t\t\t\t\t? icon\n\t\t\t\t\t\t: (\n\t\t\t\t\t\t\t<UiTypography\n\t\t\t\t\t\t\t\tclassName={ cx({\n\t\t\t\t\t\t\t\t\t\"font-semibold md:font-medium\": status === ENavStepStatus.INACTIVE,\n\t\t\t\t\t\t\t\t}) }\n\t\t\t\t\t\t\t\ttag=\"span\"\n\t\t\t\t\t\t\t\tsize={ ETypographySizes.SM }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ order }\n\t\t\t\t\t\t\t</UiTypography>\n\t\t\t\t\t\t) }\n\t\t\t\t\t{\n\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName={ cx(\"text-xxs text-nowrap md:text-xs\", {\n\t\t\t\t\t\t\t\t\"hidden md:inline\": status !== ENavStepStatus.ACTIVE,\n\t\t\t\t\t\t\t}) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ name }\n\t\t\t\t\t\t\t{ progressText }\n\t\t\t\t\t\t</span>\n\n\t\t\t\t\t}\n\t\t\t\t</UiTypography>\n\n\t\t\t</button>\n\t\t</div>\n\t);\n};\n"],"names":["getStepClasses","status","isClickable","cx","ENavStepStatus","UiNavigationStep","id","name","subSteps","className","onClick","order","totalSteps","isActive","isComplete","icon","currentStepId","updateSubstepProgress","registerStep","useStepNav","isSubstepActive","subStep","hasSubsteps","useEffect","handleClick","calculateWidth","progressText","step","jsx","styles","jsxs","UiTypography","ETextWeight","ETypographySizes"],"mappings":";;;;;;;AAOA,SAASA,EAAeC,GAAwBC,GAAsB;AAC9D,SAAAC;AAAA,IACN;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IAiBA,CAACD,KAAe;AAAA,IAChBA,KAAe;AAAA,IACfD,MAAWG,EAAe,YACvB;AAAA,IACHH,MAAWG,EAAe,UACvB;AAAA,IACHH,MAAWG,EAAe,YACvB;AAAA,EACJ;AACD;AAEO,MAAMC,IAA4C,CAAC;AAAA,EACzD,IAAAC;AAAA,EACA,MAAAC;AAAA,EACA,UAAAC,IAAW,CAAC;AAAA,EACZ,WAAAC,IAAY;AAAA,EACZ,SAAAC;AAAA,EACA,OAAAC,IAAQ;AAAA,EACR,YAAAC,IAAa;AAAA,EACb,UAAAC,IAAW;AAAA,EACX,YAAAC,IAAa;AAAA,EACb,MAAAC;AACD,MAAM;AACL,QAAM,EAAE,eAAAC,GAAe,uBAAAC,GAAuB,cAAAC,EAAA,IAAiBC,EAAW,GACpEC,IAAkBZ,EAAS,KAAK,CAACa,MAAYA,EAAQ,OAAOL,CAAa,GACzEM,IAAcd,EAAS,SAAS;AAEtC,EAAAe,EAAU,MAAM;AACf,IAAAL,EAAaZ,GAAIgB,CAAW,GAExBA,KACmBL,EAAAX,GAAIU,GAAeR,CAAQ;AAAA,EAClD,GACE,CAACF,GAAIgB,GAAad,GAAUQ,GAAeC,CAAqB,CAAC;AAE9D,QAAAhB,IAAS,CAACa,MAAeD,KAAYO,KACxChB,EAAe,SACfU,IACCV,EAAe,WACfA,EAAe,UAEboB,IAAc,MAAM;AACrB,IAAAvB,MAAWG,EAAe,YACnBM,IAAA;AAAA,EAEZ,GAE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B;AAAA,kBAAC;AAAA,kBAAA;AAAA,oBACA,WAAY3B,EAAG,mCAAmC;AAAA,sBACjD,oBAAoBF,MAAWG,EAAe;AAAA,oBAAA,CAC9C;AAAA,oBAEC,UAAA;AAAA,sBAAAG;AAAA,sBACAmB;AAAA,oBAAA;AAAA,kBAAA;AAAA,gBAAA;AAAA,cACH;AAAA,YAAA;AAAA,UAAA;AAAA,QAGF;AAAA,MAAA;AAAA,IAED;AAAA,EACD;AAEF;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { INavigationStepContext } from './_types';
|
|
3
|
+
export declare const UiNavigationSteps: React.FC<{
|
|
4
|
+
initialStepId: string;
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
className?: string;
|
|
7
|
+
complete?: boolean;
|
|
8
|
+
}>;
|
|
9
|
+
export declare const useStepNav: () => INavigationStepContext;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"UiNavigationSteps.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export declare enum ENavStepStatus {
|
|
3
|
+
COMPLETE = "complete",
|
|
4
|
+
ACTIVE = "active",
|
|
5
|
+
INACTIVE = "inactive"
|
|
6
|
+
}
|
|
7
|
+
export interface INavSubStep {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}
|
|
11
|
+
export interface INavigationStepContext {
|
|
12
|
+
currentStepId: string;
|
|
13
|
+
completedSteps: Set<string>;
|
|
14
|
+
navigateToStep: (id: string) => void;
|
|
15
|
+
registerStep: (id: string, hasSubsteps: boolean) => void;
|
|
16
|
+
updateSubstepProgress: (stepId: string, substepId: string, subSteps: INavSubStep[]) => void;
|
|
17
|
+
}
|
|
18
|
+
export interface INavStepProps {
|
|
19
|
+
id: string;
|
|
20
|
+
name: string;
|
|
21
|
+
subSteps?: INavSubStep[];
|
|
22
|
+
className?: string;
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
order?: number;
|
|
26
|
+
totalSteps?: number;
|
|
27
|
+
isActive?: boolean;
|
|
28
|
+
isComplete?: boolean;
|
|
29
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"_types.js","sources":["../../../src/components/UiNavigationSteps/_types.ts"],"sourcesContent":["import type { ReactNode } from \"react\";\n\nexport enum ENavStepStatus {\n\tCOMPLETE = \"complete\",\n\tACTIVE = \"active\",\n\tINACTIVE = \"inactive\",\n}\n\nexport interface INavSubStep {\n\tid: string;\n\tname: string;\n}\n\nexport interface INavigationStepContext {\n\tcurrentStepId: string;\n\tcompletedSteps: Set<string>;\n\tnavigateToStep: (id: string) => void;\n\tregisterStep: (id: string, hasSubsteps: boolean) => void;\n\tupdateSubstepProgress: (stepId: string, substepId: string, subSteps: INavSubStep[]) => void;\n}\n\nexport interface INavStepProps {\n\tid: string;\n\tname: string;\n\tsubSteps?: INavSubStep[];\n\tclassName?: string;\n\tonClick?: () => void;\n\ticon?: ReactNode;\n\torder?: number;\n\ttotalSteps?: number;\n\tisActive?: boolean;\n\tisComplete?: boolean;\n}\n"],"names":["ENavStepStatus"],"mappings":"AAEY,IAAAA,sBAAAA,OACXA,EAAA,WAAW,YACXA,EAAA,SAAS,UACTA,EAAA,WAAW,YAHAA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { U as a } from "../../UiNavigationSteps-N3juxg3H.js";
|
|
2
|
+
import { UiNavigationStep as i } from "./UiNavigationStep.js";
|
|
3
|
+
import { ENavStepStatus as r } from "./_types.js";
|
|
4
|
+
export {
|
|
5
|
+
r as ENavStepStatus,
|
|
6
|
+
i as UiNavigationStep,
|
|
7
|
+
a as UiNavigationSteps
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}
|
|
@@ -1,79 +1,74 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as i, jsx as e } from "react/jsx-runtime";
|
|
2
2
|
import y from "react";
|
|
3
|
-
import
|
|
4
|
-
import { UiTypography as
|
|
5
|
-
import { ETypographySizes as
|
|
6
|
-
import { EColors as
|
|
3
|
+
import l from "classnames";
|
|
4
|
+
import { UiTypography as c } from "../UiTypography/UiTypography.js";
|
|
5
|
+
import { ETypographySizes as d } from "../UiTypography/_types.js";
|
|
6
|
+
import { EColors as a } from "../../_types/colors.js";
|
|
7
7
|
import { EInputKind as r } from "../UiInput/_types.js";
|
|
8
|
-
import '../../assets/UiSelect.css';const
|
|
9
|
-
UiSelect:
|
|
8
|
+
import '../../assets/UiSelect.css';const S = "_UiSelect_1fbno_1", w = {
|
|
9
|
+
UiSelect: S
|
|
10
10
|
}, E = {
|
|
11
11
|
[r.DEFAULT]: "border-secondary-alt-600",
|
|
12
12
|
[r.ERROR]: "border-error",
|
|
13
|
-
[r.SUCCESS]: "border-primary-600"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
13
|
+
[r.SUCCESS]: "border-primary-600",
|
|
14
|
+
[r.WARNING]: "border-warning-600"
|
|
15
|
+
}, D = ({
|
|
16
|
+
children: N,
|
|
17
|
+
heading: m,
|
|
18
|
+
subLabel: u,
|
|
19
|
+
disabled: p,
|
|
20
|
+
onChange: h,
|
|
21
|
+
className: C,
|
|
22
|
+
placeholder: x,
|
|
23
|
+
prefixIcon: o,
|
|
24
|
+
postfixIcon: R,
|
|
25
|
+
statusMessage: s,
|
|
26
|
+
kind: t,
|
|
25
27
|
...n
|
|
26
28
|
}) => {
|
|
27
|
-
const [
|
|
29
|
+
const [b, f] = y.useState(n.value || n.defaultValue || ""), g = y.useCallback(
|
|
28
30
|
(v) => {
|
|
29
|
-
|
|
31
|
+
f(v.target.value), h?.(v);
|
|
30
32
|
},
|
|
31
|
-
[
|
|
33
|
+
[h]
|
|
32
34
|
);
|
|
33
|
-
return /* @__PURE__ */
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
return /* @__PURE__ */ i("div", { className: l("ui-select", C), children: [
|
|
36
|
+
m ? /* @__PURE__ */ e(
|
|
37
|
+
c,
|
|
36
38
|
{
|
|
37
|
-
size:
|
|
39
|
+
size: d.MD,
|
|
38
40
|
className: "mb-xxs",
|
|
39
|
-
children:
|
|
41
|
+
children: m
|
|
40
42
|
}
|
|
41
43
|
) : null,
|
|
42
|
-
/* @__PURE__ */
|
|
44
|
+
/* @__PURE__ */ i("div", { className: l(
|
|
43
45
|
w.UiSelect,
|
|
46
|
+
"flex items-center gap-sm",
|
|
44
47
|
"relative",
|
|
45
48
|
"rounded-xl",
|
|
46
49
|
"border",
|
|
47
50
|
"hover:border-secondary-alt-600",
|
|
48
|
-
|
|
51
|
+
p ? ["pointer-events-none", "border-secondary-alt-300", "bg-secondary-alt-200"] : [t && E[t], "bg-white"]
|
|
49
52
|
), children: [
|
|
50
|
-
/* @__PURE__ */ o
|
|
53
|
+
o ? /* @__PURE__ */ e("div", { className: "flex items-center pl-sm", children: o }) : null,
|
|
54
|
+
/* @__PURE__ */ i(
|
|
51
55
|
"select",
|
|
52
56
|
{
|
|
53
57
|
...n,
|
|
54
|
-
className:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
p-sm
|
|
62
|
-
pr-xl
|
|
63
|
-
leading-[20px]
|
|
64
|
-
text-secondary-alt
|
|
65
|
-
outline-0
|
|
66
|
-
`,
|
|
67
|
-
disabled: u,
|
|
68
|
-
value: R,
|
|
69
|
-
onChange: b,
|
|
58
|
+
className: l(
|
|
59
|
+
"m-0 w-full cursor-pointer appearance-none border-0 bg-transparent text-secondary-alt outline-0",
|
|
60
|
+
o ? "p-0 py-sm pr-xl" : "p-sm pr-xl"
|
|
61
|
+
),
|
|
62
|
+
disabled: p,
|
|
63
|
+
value: b,
|
|
64
|
+
onChange: g,
|
|
70
65
|
children: [
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
x ? /* @__PURE__ */ e("option", { value: "", disabled: !0, hidden: !0, children: x }) : null,
|
|
67
|
+
N
|
|
73
68
|
]
|
|
74
69
|
}
|
|
75
70
|
),
|
|
76
|
-
/* @__PURE__ */ e("div", { className: "pointer-events-none absolute top-1/2 right-sm -translate-y-1/2", children:
|
|
71
|
+
/* @__PURE__ */ e("div", { className: "pointer-events-none absolute top-1/2 right-sm -translate-y-1/2", children: R || /* @__PURE__ */ e(
|
|
77
72
|
"svg",
|
|
78
73
|
{
|
|
79
74
|
width: "16",
|
|
@@ -91,33 +86,33 @@ import '../../assets/UiSelect.css';const g = "_UiSelect_1fbno_1", w = {
|
|
|
91
86
|
}
|
|
92
87
|
) })
|
|
93
88
|
] }),
|
|
94
|
-
|
|
95
|
-
|
|
89
|
+
u ? /* @__PURE__ */ e(
|
|
90
|
+
c,
|
|
96
91
|
{
|
|
97
|
-
size:
|
|
98
|
-
color:
|
|
92
|
+
size: d.SM,
|
|
93
|
+
color: a.SECONDARY_ALT,
|
|
99
94
|
className: "mt-xxs",
|
|
100
|
-
children:
|
|
95
|
+
children: u
|
|
101
96
|
}
|
|
102
97
|
) : null,
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
s ? /* @__PURE__ */ e(
|
|
99
|
+
c,
|
|
105
100
|
{
|
|
106
|
-
className:
|
|
101
|
+
className: l(
|
|
107
102
|
"transition-all duration-300 ease-in-out",
|
|
108
103
|
"mt-xxs max-h-0 gap-xxs overflow-hidden opacity-0",
|
|
109
104
|
"data-[status=true]:max-h-full data-[status=true]:opacity-100"
|
|
110
105
|
),
|
|
111
106
|
lineHeight: !0,
|
|
112
|
-
color:
|
|
113
|
-
size:
|
|
114
|
-
"data-status": !!
|
|
115
|
-
children:
|
|
107
|
+
color: t === r.ERROR ? a.ERROR : t === r.WARNING ? a.WARNING_500 : a.PRIMARY,
|
|
108
|
+
size: d.SM,
|
|
109
|
+
"data-status": !!s,
|
|
110
|
+
children: s
|
|
116
111
|
}
|
|
117
112
|
) : null
|
|
118
113
|
] });
|
|
119
114
|
};
|
|
120
115
|
export {
|
|
121
|
-
|
|
116
|
+
D as UiSelect
|
|
122
117
|
};
|
|
123
118
|
//# sourceMappingURL=UiSelect.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UiSelect.js","sources":["../../../src/components/UiSelect/UiSelect.tsx"],"sourcesContent":["import React from \"react\";\nimport cx from \"classnames\";\nimport { UiTypography, ETypographySizes, EColors } from \"../UiTypography\";\nimport styles from \"./UiSelect.module.css\";\nimport { EInputKind } from \"../UiInput\";\n\ntype TSelectProps = {\n\theading?: string\n\tsubLabel?: string;\n\tdisabled?: boolean;\n\tvalue?: string | number | readonly string[];\n\tplaceholder?: string;\n\tpostfixIcon?: React.ReactNode;\n\tclassName?: string;\n\tkind?: EInputKind;\n\tstatusMessage?: string | React.ReactElement;\n\tonChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;\n} & React.SelectHTMLAttributes<HTMLSelectElement>\n\nconst stateClasses = {\n\t[EInputKind.DEFAULT]: \"border-secondary-alt-600\",\n\t[EInputKind.ERROR]: \"border-error\",\n\t[EInputKind.SUCCESS]: \"border-primary-600\",\n};\n\nexport const UiSelect: React.FC<TSelectProps> = ({\n\tchildren,\n\theading,\n\tsubLabel,\n\tdisabled,\n\tonChange,\n\tclassName,\n\tplaceholder,\n\tpostfixIcon,\n\tstatusMessage,\n\tkind,\n\t...rest\n}) => {\n\tconst [value, setValue] = React.useState(rest.value || rest.defaultValue || \"\");\n\tconst handleChange = React.useCallback(\n\t\t(event: React.ChangeEvent<HTMLSelectElement>) => {\n\t\t\tsetValue(event.target.value);\n\t\t\tonChange?.(event);\n\t\t},\n\t\t[onChange],\n\t);\n\treturn (\n\t\t<div className={ cx(\"ui-select\", className) }>\n\t\t\t{ heading\n\t\t\t\t? <UiTypography\n\t\t\t\t\tsize={ ETypographySizes.MD }\n\t\t\t\t\tclassName=\"mb-xxs\">\n\t\t\t\t\t{ heading }\n\t\t\t\t</UiTypography>\n\t\t\t\t: null\n\t\t\t}\n\t\t\t<div className={ cx(styles.UiSelect,\n\t\t\t\t\"relative\",\n\t\t\t\t\"rounded-xl\",\n\t\t\t\t\"border\",\n\t\t\t\t\"hover:border-secondary-alt-600\",\n\t\t\t\tdisabled\n\t\t\t\t\t? [\"pointer-events-none\", \"border-secondary-alt-300\", \"bg-secondary-alt-200\"]\n\t\t\t\t\t: [kind && stateClasses[kind], \"bg-white\"]\n\t\t\t) }>\n\t\t\t\t
|
|
1
|
+
{"version":3,"file":"UiSelect.js","sources":["../../../src/components/UiSelect/UiSelect.tsx"],"sourcesContent":["import React from \"react\";\nimport cx from \"classnames\";\nimport { UiTypography, ETypographySizes, EColors } from \"../UiTypography\";\nimport styles from \"./UiSelect.module.css\";\nimport { EInputKind } from \"../UiInput\";\n\ntype TSelectProps = {\n\theading?: string\n\tsubLabel?: string;\n\tdisabled?: boolean;\n\tvalue?: string | number | readonly string[];\n\tplaceholder?: string;\n\tprefixIcon?: React.ReactNode;\n\tpostfixIcon?: React.ReactNode;\n\tclassName?: string;\n\tkind?: EInputKind;\n\tstatusMessage?: string | React.ReactElement;\n\tonChange?: (event: React.ChangeEvent<HTMLSelectElement>) => void;\n} & React.SelectHTMLAttributes<HTMLSelectElement>\n\nconst stateClasses = {\n\t[EInputKind.DEFAULT]: \"border-secondary-alt-600\",\n\t[EInputKind.ERROR]: \"border-error\",\n\t[EInputKind.SUCCESS]: \"border-primary-600\",\n\t[EInputKind.WARNING]: \"border-warning-600\",\n};\n\nexport const UiSelect: React.FC<TSelectProps> = ({\n\tchildren,\n\theading,\n\tsubLabel,\n\tdisabled,\n\tonChange,\n\tclassName,\n\tplaceholder,\n\tprefixIcon,\n\tpostfixIcon,\n\tstatusMessage,\n\tkind,\n\t...rest\n}) => {\n\tconst [value, setValue] = React.useState(rest.value || rest.defaultValue || \"\");\n\tconst handleChange = React.useCallback(\n\t\t(event: React.ChangeEvent<HTMLSelectElement>) => {\n\t\t\tsetValue(event.target.value);\n\t\t\tonChange?.(event);\n\t\t},\n\t\t[onChange],\n\t);\n\treturn (\n\t\t<div className={ cx(\"ui-select\", className) }>\n\t\t\t{ heading\n\t\t\t\t? <UiTypography\n\t\t\t\t\tsize={ ETypographySizes.MD }\n\t\t\t\t\tclassName=\"mb-xxs\">\n\t\t\t\t\t{ heading }\n\t\t\t\t</UiTypography>\n\t\t\t\t: null\n\t\t\t}\n\t\t\t<div className={ cx(styles.UiSelect,\n\t\t\t\t\"flex items-center gap-sm\",\n\t\t\t\t\"relative\",\n\t\t\t\t\"rounded-xl\",\n\t\t\t\t\"border\",\n\t\t\t\t\"hover:border-secondary-alt-600\",\n\t\t\t\tdisabled\n\t\t\t\t\t? [\"pointer-events-none\", \"border-secondary-alt-300\", \"bg-secondary-alt-200\"]\n\t\t\t\t\t: [kind && stateClasses[kind], \"bg-white\"]\n\t\t\t) }>\n\t\t\t\t{ prefixIcon\n\t\t\t\t\t? <div className=\"flex items-center pl-sm\">{ prefixIcon }</div>\n\t\t\t\t\t: null }\n\t\t\t\t<select\n\t\t\t\t\t{ ...rest }\n\t\t\t\t\tclassName={ cx(\n\t\t\t\t\t\t\"m-0 w-full cursor-pointer appearance-none border-0 bg-transparent text-secondary-alt outline-0\",\n\t\t\t\t\t\tprefixIcon\n\t\t\t\t\t\t\t? \"p-0 py-sm pr-xl\"\n\t\t\t\t\t\t\t: \"p-sm pr-xl\"\n\t\t\t\t\t) }\n\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\tvalue={ value }\n\t\t\t\t\tonChange={ handleChange }\n\t\t\t\t>\n\t\t\t\t\t{ placeholder\n\t\t\t\t\t\t? <option value={ \"\" } disabled hidden>{ placeholder }</option>\n\t\t\t\t\t\t: null }\n\t\t\t\t\t{ children }\n\t\t\t\t</select>\n\t\t\t\t<div className=\"pointer-events-none absolute top-1/2 right-sm -translate-y-1/2\">\n\t\t\t\t\t{ postfixIcon\n\t\t\t\t\t\t? postfixIcon\n\t\t\t\t\t\t: (<svg\n\t\t\t\t\t\t\twidth=\"16\"\n\t\t\t\t\t\t\theight=\"16\"\n\t\t\t\t\t\t\tviewBox=\"0 0 16 16\"\n\t\t\t\t\t\t\tfill=\"none\"\n\t\t\t\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<path\n\t\t\t\t\t\t\t\td=\"M13.25 6.8125L8.5 11.2812C8.34375 11.4375 8.15625 11.5 8 11.5C7.8125 11.5 7.625 11.4375 7.46875 11.3125L2.71875 6.8125C2.40625 6.53125 2.40625 6.0625 2.6875 5.75C2.96875 5.4375 3.4375 5.4375 3.75 5.71875L8 9.71875L12.2188 5.71875C12.5312 5.4375 13 5.4375 13.2812 5.75C13.5625 6.0625 13.5625 6.53125 13.25 6.8125Z\"\n\t\t\t\t\t\t\t\tfill=\"currentColor\"\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</svg>)\n\t\t\t\t\t}\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t\t{ subLabel\n\t\t\t\t? (<UiTypography\n\t\t\t\t\tsize={ ETypographySizes.SM }\n\t\t\t\t\tcolor={ EColors.SECONDARY_ALT }\n\t\t\t\t\tclassName=\"mt-xxs\"\n\t\t\t\t>\n\t\t\t\t\t{ subLabel }\n\t\t\t\t</UiTypography>)\n\t\t\t\t: null\n\t\t\t}\n\n\t\t\t{ statusMessage\n\t\t\t\t? (\n\t\t\t\t\t<UiTypography\n\t\t\t\t\t\tclassName={ cx(\n\t\t\t\t\t\t\t\"transition-all duration-300 ease-in-out\",\n\t\t\t\t\t\t\t\"mt-xxs max-h-0 gap-xxs overflow-hidden opacity-0\",\n\t\t\t\t\t\t\t\"data-[status=true]:max-h-full data-[status=true]:opacity-100\"\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tlineHeight\n\t\t\t\t\t\tcolor={\n\t\t\t\t\t\t\tkind === EInputKind.ERROR\n\t\t\t\t\t\t\t\t? EColors.ERROR\n\t\t\t\t\t\t\t\t: kind === EInputKind.WARNING\n\t\t\t\t\t\t\t\t\t? EColors.WARNING_500\n\t\t\t\t\t\t\t\t\t: EColors.PRIMARY\n\t\t\t\t\t\t}\n\t\t\t\t\t\tsize={ ETypographySizes.SM }\n\t\t\t\t\t\tdata-status={ !!statusMessage }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ statusMessage }\n\t\t\t\t\t</UiTypography>\n\t\t\t\t)\n\t\t\t\t: null }\n\t\t</div>\n\t);\n};\n"],"names":["stateClasses","EInputKind","UiSelect","children","heading","subLabel","disabled","onChange","className","placeholder","prefixIcon","postfixIcon","statusMessage","kind","rest","value","setValue","React","handleChange","event","cx","jsx","UiTypography","ETypographySizes","jsxs","styles","EColors"],"mappings":";;;;;;;;;GAoBMA,IAAe;AAAA,EACpB,CAACC,EAAW,OAAO,GAAG;AAAA,EACtB,CAACA,EAAW,KAAK,GAAG;AAAA,EACpB,CAACA,EAAW,OAAO,GAAG;AAAA,EACtB,CAACA,EAAW,OAAO,GAAG;AACvB,GAEaC,IAAmC,CAAC;AAAA,EAChD,UAAAC;AAAA,EACA,SAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,aAAAC;AAAA,EACA,YAAAC;AAAA,EACA,aAAAC;AAAA,EACA,eAAAC;AAAA,EACA,MAAAC;AAAA,EACA,GAAGC;AACJ,MAAM;AACC,QAAA,CAACC,GAAOC,CAAQ,IAAIC,EAAM,SAASH,EAAK,SAASA,EAAK,gBAAgB,EAAE,GACxEI,IAAeD,EAAM;AAAA,IAC1B,CAAC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