@f0rbit/ui 0.1.2 → 0.1.6
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/components.css +4 -0
- package/dist/index.d.ts +80 -5
- package/dist/index.js +103 -80
- package/dist/index.jsx +80 -61
- package/dist/server.js +41 -61
- package/dist/server.jsx +80 -61
- package/dist/styles.css +4 -0
- package/package.json +3 -2
- package/src/components/Stepper.tsx +11 -3
- package/src/components/Tabs.tsx +155 -69
- package/src/styles/components.css +4 -0
package/dist/components.css
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -150,30 +150,105 @@ interface StepProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
|
150
150
|
description?: string;
|
|
151
151
|
icon?: JSX.Element;
|
|
152
152
|
status?: StepStatus;
|
|
153
|
+
children?: JSX.Element;
|
|
154
|
+
/** Explicit step number (optional, auto-increments if not provided) */
|
|
155
|
+
number?: number;
|
|
156
|
+
/** Explicit orientation (optional, uses context if not provided) */
|
|
157
|
+
orientation?: "horizontal" | "vertical";
|
|
153
158
|
}
|
|
154
159
|
declare function Step(props: StepProps): JSX.Element;
|
|
155
160
|
declare function Stepper(props: StepperProps): JSX.Element;
|
|
156
161
|
|
|
162
|
+
/**
|
|
163
|
+
* A tab container component that manages tab selection and panel visibility.
|
|
164
|
+
*
|
|
165
|
+
* Uses DOM-based discovery via data attributes, making it compatible with
|
|
166
|
+
* Astro's island architecture where each child component hydrates independently.
|
|
167
|
+
*
|
|
168
|
+
* @example Basic usage in SolidJS
|
|
169
|
+
* ```tsx
|
|
170
|
+
* <Tabs defaultValue="tab1">
|
|
171
|
+
* <TabList>
|
|
172
|
+
* <Tab value="tab1">First Tab</Tab>
|
|
173
|
+
* <Tab value="tab2">Second Tab</Tab>
|
|
174
|
+
* </TabList>
|
|
175
|
+
* <TabPanel value="tab1">First panel content</TabPanel>
|
|
176
|
+
* <TabPanel value="tab2">Second panel content</TabPanel>
|
|
177
|
+
* </Tabs>
|
|
178
|
+
* ```
|
|
179
|
+
*
|
|
180
|
+
* @example Usage in Astro MDX (each component needs client:load)
|
|
181
|
+
* ```mdx
|
|
182
|
+
* <Tabs defaultValue="tab1" client:load>
|
|
183
|
+
* <TabList client:load>
|
|
184
|
+
* <Tab value="tab1" client:load>First Tab</Tab>
|
|
185
|
+
* <Tab value="tab2" client:load>Second Tab</Tab>
|
|
186
|
+
* </TabList>
|
|
187
|
+
* <TabPanel value="tab1" client:load>First panel content</TabPanel>
|
|
188
|
+
* <TabPanel value="tab2" client:load>Second panel content</TabPanel>
|
|
189
|
+
* </Tabs>
|
|
190
|
+
* ```
|
|
191
|
+
*
|
|
192
|
+
* @example Creating a wrapper to avoid multiple client:load directives
|
|
193
|
+
* ```tsx
|
|
194
|
+
* // MyTabs.tsx - your custom wrapper
|
|
195
|
+
* import { Tabs, TabList, Tab, TabPanel } from '@f0rbit/ui';
|
|
196
|
+
*
|
|
197
|
+
* export function MyTabs() {
|
|
198
|
+
* return (
|
|
199
|
+
* <Tabs defaultValue="tab1">
|
|
200
|
+
* <TabList>
|
|
201
|
+
* <Tab value="tab1">First</Tab>
|
|
202
|
+
* <Tab value="tab2">Second</Tab>
|
|
203
|
+
* </TabList>
|
|
204
|
+
* <TabPanel value="tab1">Content 1</TabPanel>
|
|
205
|
+
* <TabPanel value="tab2">Content 2</TabPanel>
|
|
206
|
+
* </Tabs>
|
|
207
|
+
* );
|
|
208
|
+
* }
|
|
209
|
+
*
|
|
210
|
+
* // Then in Astro: <MyTabs client:load />
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
157
213
|
interface TabsProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
214
|
+
/** The value of the initially selected tab */
|
|
158
215
|
defaultValue?: string;
|
|
159
|
-
value?: string;
|
|
160
|
-
onValueChange?: (value: string) => void;
|
|
161
216
|
children: JSX.Element;
|
|
162
217
|
}
|
|
218
|
+
declare function Tabs(props: TabsProps): JSX.Element;
|
|
219
|
+
/**
|
|
220
|
+
* Container for Tab buttons. Provides the tablist role for accessibility.
|
|
221
|
+
*
|
|
222
|
+
* In Astro, requires `client:load` directive.
|
|
223
|
+
*/
|
|
163
224
|
interface TabListProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
164
225
|
children: JSX.Element;
|
|
165
226
|
}
|
|
227
|
+
declare function TabList(props: TabListProps): JSX.Element;
|
|
228
|
+
/**
|
|
229
|
+
* A tab button that switches the active panel when clicked.
|
|
230
|
+
*
|
|
231
|
+
* The `value` prop must match a corresponding `TabPanel` value.
|
|
232
|
+
* In Astro, requires `client:load` directive.
|
|
233
|
+
*/
|
|
166
234
|
interface TabProps extends JSX.ButtonHTMLAttributes<HTMLButtonElement> {
|
|
235
|
+
/** Unique identifier that links this tab to its panel */
|
|
167
236
|
value: string;
|
|
168
237
|
children: JSX.Element;
|
|
169
238
|
}
|
|
239
|
+
declare function Tab(props: TabProps): JSX.Element;
|
|
240
|
+
/**
|
|
241
|
+
* Content panel that is shown when its corresponding Tab is active.
|
|
242
|
+
*
|
|
243
|
+
* The `value` prop must match a corresponding `Tab` value.
|
|
244
|
+
* Panels are hidden by default and shown when their tab is selected.
|
|
245
|
+
* In Astro, requires `client:load` directive.
|
|
246
|
+
*/
|
|
170
247
|
interface TabPanelProps extends JSX.HTMLAttributes<HTMLDivElement> {
|
|
248
|
+
/** Unique identifier that links this panel to its tab */
|
|
171
249
|
value: string;
|
|
172
250
|
children: JSX.Element;
|
|
173
251
|
}
|
|
174
|
-
declare function Tabs(props: TabsProps): JSX.Element;
|
|
175
|
-
declare function TabList(props: TabListProps): JSX.Element;
|
|
176
|
-
declare function Tab(props: TabProps): JSX.Element;
|
|
177
252
|
declare function TabPanel(props: TabPanelProps): JSX.Element;
|
|
178
253
|
|
|
179
254
|
interface CheckboxProps extends Omit<JSX.InputHTMLAttributes<HTMLInputElement>, "type"> {
|
package/dist/index.js
CHANGED
|
@@ -683,8 +683,9 @@ function Collapsible(props) {
|
|
|
683
683
|
delegateEvents(["click"]);
|
|
684
684
|
var _tmpl$15 = /* @__PURE__ */ template(`<svg width=16 height=16 viewBox="0 0 16 16"fill=none stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round><polyline points="13 4 6 12 3 9">`);
|
|
685
685
|
var _tmpl$29 = /* @__PURE__ */ template(`<div class=step-description>`);
|
|
686
|
-
var _tmpl$37 = /* @__PURE__ */ template(`<div
|
|
687
|
-
var _tmpl$45 = /* @__PURE__ */ template(`<div>`);
|
|
686
|
+
var _tmpl$37 = /* @__PURE__ */ template(`<div class=step-body>`);
|
|
687
|
+
var _tmpl$45 = /* @__PURE__ */ template(`<div><div></div><div><div class=step-title></div></div><div>`);
|
|
688
|
+
var _tmpl$53 = /* @__PURE__ */ template(`<div>`);
|
|
688
689
|
var StepperContext = createContext();
|
|
689
690
|
var statusClasses = {
|
|
690
691
|
completed: "step-completed",
|
|
@@ -696,11 +697,11 @@ function CheckIcon() {
|
|
|
696
697
|
}
|
|
697
698
|
var StepContext = createContext();
|
|
698
699
|
function Step(props) {
|
|
699
|
-
const [local, rest] = splitProps(props, ["title", "description", "icon", "status", "class"]);
|
|
700
|
+
const [local, rest] = splitProps(props, ["title", "description", "icon", "status", "class", "children", "number", "orientation"]);
|
|
700
701
|
const stepperCtx = useContext(StepperContext);
|
|
701
702
|
const stepCtx = useContext(StepContext);
|
|
702
|
-
const stepNumber = stepperCtx?.registerStep() ?? 1;
|
|
703
|
-
const orientation = () => stepCtx?.orientation() ?? "
|
|
703
|
+
const stepNumber = local.number ?? stepperCtx?.registerStep() ?? 1;
|
|
704
|
+
const orientation = () => local.orientation ?? stepCtx?.orientation() ?? "vertical";
|
|
704
705
|
const status = () => local.status ?? "upcoming";
|
|
705
706
|
const isVertical = () => orientation() === "vertical";
|
|
706
707
|
const classes = () => {
|
|
@@ -744,7 +745,7 @@ function Step(props) {
|
|
|
744
745
|
return stepNumber;
|
|
745
746
|
};
|
|
746
747
|
return (() => {
|
|
747
|
-
var _el$2 = _tmpl$
|
|
748
|
+
var _el$2 = _tmpl$45(), _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$4.firstChild, _el$8 = _el$4.nextSibling;
|
|
748
749
|
spread(_el$2, mergeProps({
|
|
749
750
|
get ["class"]() {
|
|
750
751
|
return classes();
|
|
@@ -762,11 +763,21 @@ function Step(props) {
|
|
|
762
763
|
return _el$6;
|
|
763
764
|
}
|
|
764
765
|
}), null);
|
|
766
|
+
insert(_el$4, createComponent(Show, {
|
|
767
|
+
get when() {
|
|
768
|
+
return local.children;
|
|
769
|
+
},
|
|
770
|
+
get children() {
|
|
771
|
+
var _el$7 = _tmpl$37();
|
|
772
|
+
insert(_el$7, () => local.children);
|
|
773
|
+
return _el$7;
|
|
774
|
+
}
|
|
775
|
+
}), null);
|
|
765
776
|
effect((_p$) => {
|
|
766
777
|
var _v$ = indicatorClasses(), _v$2 = contentClasses(), _v$3 = connectorClasses();
|
|
767
778
|
_v$ !== _p$.e && className(_el$3, _p$.e = _v$);
|
|
768
779
|
_v$2 !== _p$.t && className(_el$4, _p$.t = _v$2);
|
|
769
|
-
_v$3 !== _p$.a && className(_el$
|
|
780
|
+
_v$3 !== _p$.a && className(_el$8, _p$.a = _v$3);
|
|
770
781
|
return _p$;
|
|
771
782
|
}, {
|
|
772
783
|
e: void 0,
|
|
@@ -798,14 +809,14 @@ function Stepper(props) {
|
|
|
798
809
|
orientation
|
|
799
810
|
},
|
|
800
811
|
get children() {
|
|
801
|
-
var _el$
|
|
802
|
-
spread(_el$
|
|
812
|
+
var _el$9 = _tmpl$53();
|
|
813
|
+
spread(_el$9, mergeProps({
|
|
803
814
|
get ["class"]() {
|
|
804
815
|
return classes();
|
|
805
816
|
}
|
|
806
817
|
}, rest), false, true);
|
|
807
|
-
insert(_el$
|
|
808
|
-
return _el$
|
|
818
|
+
insert(_el$9, () => local.children);
|
|
819
|
+
return _el$9;
|
|
809
820
|
}
|
|
810
821
|
});
|
|
811
822
|
}
|
|
@@ -813,37 +824,72 @@ function Stepper(props) {
|
|
|
813
824
|
}
|
|
814
825
|
var _tmpl$16 = /* @__PURE__ */ template(`<div>`);
|
|
815
826
|
var _tmpl$210 = /* @__PURE__ */ template(`<div role=tablist>`);
|
|
816
|
-
var _tmpl$38 = /* @__PURE__ */ template(`<button type=button role=tab>`);
|
|
817
|
-
var _tmpl$46 = /* @__PURE__ */ template(`<div role=tabpanel>`);
|
|
818
|
-
var TabsContext = createContext();
|
|
827
|
+
var _tmpl$38 = /* @__PURE__ */ template(`<button type=button role=tab aria-selected=false tabindex=-1>`);
|
|
828
|
+
var _tmpl$46 = /* @__PURE__ */ template(`<div role=tabpanel hidden>`);
|
|
819
829
|
function Tabs(props) {
|
|
820
|
-
const [local, rest] = splitProps(props, ["defaultValue", "
|
|
821
|
-
|
|
822
|
-
const
|
|
823
|
-
const
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
830
|
+
const [local, rest] = splitProps(props, ["defaultValue", "children", "class"]);
|
|
831
|
+
let containerRef;
|
|
832
|
+
const [activeTab, setActiveTab] = createSignal(local.defaultValue ?? "");
|
|
833
|
+
const updateTabs = (value) => {
|
|
834
|
+
if (!containerRef) return;
|
|
835
|
+
const tabs = containerRef.querySelectorAll("[data-tab-value]");
|
|
836
|
+
tabs.forEach((tab) => {
|
|
837
|
+
const isActive = tab.dataset.tabValue === value;
|
|
838
|
+
tab.setAttribute("aria-selected", String(isActive));
|
|
839
|
+
tab.setAttribute("tabindex", isActive ? "0" : "-1");
|
|
840
|
+
tab.classList.toggle("active", isActive);
|
|
841
|
+
});
|
|
842
|
+
const panels = containerRef.querySelectorAll("[data-panel-value]");
|
|
843
|
+
panels.forEach((panel) => {
|
|
844
|
+
const isActive = panel.dataset.panelValue === value;
|
|
845
|
+
panel.hidden = !isActive;
|
|
846
|
+
});
|
|
829
847
|
};
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
value
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
var _el$ = _tmpl$16();
|
|
838
|
-
spread(_el$, mergeProps({
|
|
839
|
-
get ["class"]() {
|
|
840
|
-
return classes();
|
|
841
|
-
}
|
|
842
|
-
}, rest), false, true);
|
|
843
|
-
insert(_el$, () => local.children);
|
|
844
|
-
return _el$;
|
|
848
|
+
const initializeTabs = () => {
|
|
849
|
+
if (!containerRef) return;
|
|
850
|
+
let value = activeTab();
|
|
851
|
+
if (!value) {
|
|
852
|
+
const firstTab = containerRef.querySelector("[data-tab-value]");
|
|
853
|
+
value = firstTab?.dataset.tabValue ?? "";
|
|
854
|
+
if (value) setActiveTab(value);
|
|
845
855
|
}
|
|
856
|
+
if (value) updateTabs(value);
|
|
857
|
+
};
|
|
858
|
+
onMount(() => {
|
|
859
|
+
if (!containerRef) return;
|
|
860
|
+
containerRef.addEventListener("click", (e) => {
|
|
861
|
+
const tab = e.target.closest("[data-tab-value]");
|
|
862
|
+
if (tab?.dataset.tabValue) {
|
|
863
|
+
setActiveTab(tab.dataset.tabValue);
|
|
864
|
+
updateTabs(tab.dataset.tabValue);
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
initializeTabs();
|
|
868
|
+
const observer = new MutationObserver(() => {
|
|
869
|
+
initializeTabs();
|
|
870
|
+
});
|
|
871
|
+
observer.observe(containerRef, {
|
|
872
|
+
childList: true,
|
|
873
|
+
subtree: true
|
|
874
|
+
});
|
|
875
|
+
onCleanup(() => observer.disconnect());
|
|
846
876
|
});
|
|
877
|
+
const classes = () => `tabs ${local.class ?? ""}`.trim();
|
|
878
|
+
return (() => {
|
|
879
|
+
var _el$ = _tmpl$16();
|
|
880
|
+
var _ref$ = containerRef;
|
|
881
|
+
typeof _ref$ === "function" ? use(_ref$, _el$) : containerRef = _el$;
|
|
882
|
+
spread(_el$, mergeProps({
|
|
883
|
+
get ["class"]() {
|
|
884
|
+
return classes();
|
|
885
|
+
},
|
|
886
|
+
get ["data-default-value"]() {
|
|
887
|
+
return local.defaultValue;
|
|
888
|
+
}
|
|
889
|
+
}, rest), false, true);
|
|
890
|
+
insert(_el$, () => local.children);
|
|
891
|
+
return _el$;
|
|
892
|
+
})();
|
|
847
893
|
}
|
|
848
894
|
function TabList(props) {
|
|
849
895
|
const [local, rest] = splitProps(props, ["children", "class"]);
|
|
@@ -861,33 +907,15 @@ function TabList(props) {
|
|
|
861
907
|
}
|
|
862
908
|
function Tab(props) {
|
|
863
909
|
const [local, rest] = splitProps(props, ["value", "children", "class"]);
|
|
864
|
-
const
|
|
865
|
-
const isActive = () => ctx?.activeTab() === local.value;
|
|
866
|
-
const handleClick = () => {
|
|
867
|
-
ctx?.setActiveTab(local.value);
|
|
868
|
-
};
|
|
869
|
-
const classes = () => {
|
|
870
|
-
const parts = ["tab"];
|
|
871
|
-
if (isActive()) {
|
|
872
|
-
parts.push("active");
|
|
873
|
-
}
|
|
874
|
-
if (local.class) {
|
|
875
|
-
parts.push(local.class);
|
|
876
|
-
}
|
|
877
|
-
return parts.join(" ");
|
|
878
|
-
};
|
|
910
|
+
const classes = () => `tab ${local.class ?? ""}`.trim();
|
|
879
911
|
return (() => {
|
|
880
912
|
var _el$3 = _tmpl$38();
|
|
881
|
-
_el$3.$$click = handleClick;
|
|
882
913
|
spread(_el$3, mergeProps({
|
|
883
|
-
get ["aria-selected"]() {
|
|
884
|
-
return isActive();
|
|
885
|
-
},
|
|
886
|
-
get tabIndex() {
|
|
887
|
-
return isActive() ? 0 : -1;
|
|
888
|
-
},
|
|
889
914
|
get ["class"]() {
|
|
890
915
|
return classes();
|
|
916
|
+
},
|
|
917
|
+
get ["data-tab-value"]() {
|
|
918
|
+
return local.value;
|
|
891
919
|
}
|
|
892
920
|
}, rest), false, true);
|
|
893
921
|
insert(_el$3, () => local.children);
|
|
@@ -896,26 +924,21 @@ function Tab(props) {
|
|
|
896
924
|
}
|
|
897
925
|
function TabPanel(props) {
|
|
898
926
|
const [local, rest] = splitProps(props, ["value", "children", "class"]);
|
|
899
|
-
const ctx = useContext(TabsContext);
|
|
900
|
-
const isActive = () => ctx?.activeTab() === local.value;
|
|
901
927
|
const classes = () => `tab-panel ${local.class ?? ""}`.trim();
|
|
902
|
-
return
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
}
|
|
916
|
-
});
|
|
928
|
+
return (() => {
|
|
929
|
+
var _el$4 = _tmpl$46();
|
|
930
|
+
spread(_el$4, mergeProps({
|
|
931
|
+
get ["class"]() {
|
|
932
|
+
return classes();
|
|
933
|
+
},
|
|
934
|
+
get ["data-panel-value"]() {
|
|
935
|
+
return local.value;
|
|
936
|
+
}
|
|
937
|
+
}, rest), false, true);
|
|
938
|
+
insert(_el$4, () => local.children);
|
|
939
|
+
return _el$4;
|
|
940
|
+
})();
|
|
917
941
|
}
|
|
918
|
-
delegateEvents(["click"]);
|
|
919
942
|
var _tmpl$17 = /* @__PURE__ */ template(`<label><input type=checkbox class=checkbox-input><span class=checkbox-box aria-hidden=true><svg class=checkbox-check viewBox="0 0 12 12"fill=none><path d="M2 6L5 9L10 3"stroke=currentColor stroke-width=2 stroke-linecap=round stroke-linejoin=round></path></svg><span class=checkbox-indeterminate>`);
|
|
920
943
|
var _tmpl$211 = /* @__PURE__ */ template(`<span class=checkbox-content>`);
|
|
921
944
|
var _tmpl$39 = /* @__PURE__ */ template(`<span class=checkbox-label>`);
|
|
@@ -1063,7 +1086,7 @@ var _tmpl$20 = /* @__PURE__ */ template(`<div class=timeline-dot>`);
|
|
|
1063
1086
|
var _tmpl$214 = /* @__PURE__ */ template(`<div>`);
|
|
1064
1087
|
var _tmpl$312 = /* @__PURE__ */ template(`<div class=timeline-description>`);
|
|
1065
1088
|
var _tmpl$410 = /* @__PURE__ */ template(`<div class=timeline-timestamp>`);
|
|
1066
|
-
var _tmpl$
|
|
1089
|
+
var _tmpl$54 = /* @__PURE__ */ template(`<div><div class="timeline-indicator vertical-indicator"></div><div class=vertical-connector></div><div class="timeline-content vertical-content"><div class=timeline-title>`);
|
|
1067
1090
|
var variantClasses3 = {
|
|
1068
1091
|
default: "",
|
|
1069
1092
|
success: "timeline-item-success",
|
|
@@ -1093,7 +1116,7 @@ function Timeline(props) {
|
|
|
1093
1116
|
return local.items;
|
|
1094
1117
|
},
|
|
1095
1118
|
children: (item, index) => (() => {
|
|
1096
|
-
var _el$3 = _tmpl$
|
|
1119
|
+
var _el$3 = _tmpl$54(), _el$4 = _el$3.firstChild, _el$5 = _el$4.nextSibling, _el$6 = _el$5.nextSibling, _el$7 = _el$6.firstChild;
|
|
1097
1120
|
insert(_el$4, createComponent(Show, {
|
|
1098
1121
|
get when() {
|
|
1099
1122
|
return item.icon;
|
package/dist/index.jsx
CHANGED
|
@@ -445,11 +445,11 @@ function CheckIcon() {
|
|
|
445
445
|
}
|
|
446
446
|
var StepContext = createContext3();
|
|
447
447
|
function Step(props) {
|
|
448
|
-
const [local, rest] = splitProps14(props, ["title", "description", "icon", "status", "class"]);
|
|
448
|
+
const [local, rest] = splitProps14(props, ["title", "description", "icon", "status", "class", "children", "number", "orientation"]);
|
|
449
449
|
const stepperCtx = useContext3(StepperContext);
|
|
450
450
|
const stepCtx = useContext3(StepContext);
|
|
451
|
-
const stepNumber = stepperCtx?.registerStep() ?? 1;
|
|
452
|
-
const orientation = () => stepCtx?.orientation() ?? "
|
|
451
|
+
const stepNumber = local.number ?? stepperCtx?.registerStep() ?? 1;
|
|
452
|
+
const orientation = () => local.orientation ?? stepCtx?.orientation() ?? "vertical";
|
|
453
453
|
const status = () => local.status ?? "upcoming";
|
|
454
454
|
const isVertical = () => orientation() === "vertical";
|
|
455
455
|
const classes = () => {
|
|
@@ -499,6 +499,9 @@ function Step(props) {
|
|
|
499
499
|
<Show5 when={local.description}>
|
|
500
500
|
<div class="step-description">{local.description}</div>
|
|
501
501
|
</Show5>
|
|
502
|
+
<Show5 when={local.children}>
|
|
503
|
+
<div class="step-body">{local.children}</div>
|
|
504
|
+
</Show5>
|
|
502
505
|
</div>
|
|
503
506
|
<div class={connectorClasses()} />
|
|
504
507
|
</div>;
|
|
@@ -525,25 +528,59 @@ function Stepper(props) {
|
|
|
525
528
|
}
|
|
526
529
|
|
|
527
530
|
// src/components/Tabs.tsx
|
|
528
|
-
import { splitProps as splitProps15,
|
|
529
|
-
var TabsContext = createContext4();
|
|
531
|
+
import { splitProps as splitProps15, onMount as onMount3, onCleanup as onCleanup3, createSignal as createSignal4 } from "solid-js";
|
|
530
532
|
function Tabs(props) {
|
|
531
|
-
const [local, rest] = splitProps15(props, ["defaultValue", "
|
|
532
|
-
|
|
533
|
-
const
|
|
534
|
-
const
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
533
|
+
const [local, rest] = splitProps15(props, ["defaultValue", "children", "class"]);
|
|
534
|
+
let containerRef;
|
|
535
|
+
const [activeTab, setActiveTab] = createSignal4(local.defaultValue ?? "");
|
|
536
|
+
const updateTabs = (value) => {
|
|
537
|
+
if (!containerRef) return;
|
|
538
|
+
const tabs = containerRef.querySelectorAll("[data-tab-value]");
|
|
539
|
+
tabs.forEach((tab) => {
|
|
540
|
+
const isActive = tab.dataset.tabValue === value;
|
|
541
|
+
tab.setAttribute("aria-selected", String(isActive));
|
|
542
|
+
tab.setAttribute("tabindex", isActive ? "0" : "-1");
|
|
543
|
+
tab.classList.toggle("active", isActive);
|
|
544
|
+
});
|
|
545
|
+
const panels = containerRef.querySelectorAll("[data-panel-value]");
|
|
546
|
+
panels.forEach((panel) => {
|
|
547
|
+
const isActive = panel.dataset.panelValue === value;
|
|
548
|
+
panel.hidden = !isActive;
|
|
549
|
+
});
|
|
550
|
+
};
|
|
551
|
+
const initializeTabs = () => {
|
|
552
|
+
if (!containerRef) return;
|
|
553
|
+
let value = activeTab();
|
|
554
|
+
if (!value) {
|
|
555
|
+
const firstTab = containerRef.querySelector("[data-tab-value]");
|
|
556
|
+
value = firstTab?.dataset.tabValue ?? "";
|
|
557
|
+
if (value) setActiveTab(value);
|
|
538
558
|
}
|
|
539
|
-
|
|
559
|
+
if (value) updateTabs(value);
|
|
540
560
|
};
|
|
561
|
+
onMount3(() => {
|
|
562
|
+
if (!containerRef) return;
|
|
563
|
+
containerRef.addEventListener("click", (e) => {
|
|
564
|
+
const tab = e.target.closest("[data-tab-value]");
|
|
565
|
+
if (tab?.dataset.tabValue) {
|
|
566
|
+
setActiveTab(tab.dataset.tabValue);
|
|
567
|
+
updateTabs(tab.dataset.tabValue);
|
|
568
|
+
}
|
|
569
|
+
});
|
|
570
|
+
initializeTabs();
|
|
571
|
+
const observer = new MutationObserver(() => {
|
|
572
|
+
initializeTabs();
|
|
573
|
+
});
|
|
574
|
+
observer.observe(containerRef, {
|
|
575
|
+
childList: true,
|
|
576
|
+
subtree: true
|
|
577
|
+
});
|
|
578
|
+
onCleanup3(() => observer.disconnect());
|
|
579
|
+
});
|
|
541
580
|
const classes = () => `tabs ${local.class ?? ""}`.trim();
|
|
542
|
-
return <
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
</div>
|
|
546
|
-
</TabsContext.Provider>;
|
|
581
|
+
return <div ref={containerRef} class={classes()} data-default-value={local.defaultValue} {...rest}>
|
|
582
|
+
{local.children}
|
|
583
|
+
</div>;
|
|
547
584
|
}
|
|
548
585
|
function TabList(props) {
|
|
549
586
|
const [local, rest] = splitProps15(props, ["children", "class"]);
|
|
@@ -554,28 +591,14 @@ function TabList(props) {
|
|
|
554
591
|
}
|
|
555
592
|
function Tab(props) {
|
|
556
593
|
const [local, rest] = splitProps15(props, ["value", "children", "class"]);
|
|
557
|
-
const
|
|
558
|
-
const isActive = () => ctx?.activeTab() === local.value;
|
|
559
|
-
const handleClick = () => {
|
|
560
|
-
ctx?.setActiveTab(local.value);
|
|
561
|
-
};
|
|
562
|
-
const classes = () => {
|
|
563
|
-
const parts = ["tab"];
|
|
564
|
-
if (isActive()) {
|
|
565
|
-
parts.push("active");
|
|
566
|
-
}
|
|
567
|
-
if (local.class) {
|
|
568
|
-
parts.push(local.class);
|
|
569
|
-
}
|
|
570
|
-
return parts.join(" ");
|
|
571
|
-
};
|
|
594
|
+
const classes = () => `tab ${local.class ?? ""}`.trim();
|
|
572
595
|
return <button
|
|
573
596
|
type="button"
|
|
574
597
|
role="tab"
|
|
575
|
-
aria-selected=
|
|
576
|
-
tabIndex={
|
|
598
|
+
aria-selected="false"
|
|
599
|
+
tabIndex={-1}
|
|
577
600
|
class={classes()}
|
|
578
|
-
|
|
601
|
+
data-tab-value={local.value}
|
|
579
602
|
{...rest}
|
|
580
603
|
>
|
|
581
604
|
{local.children}
|
|
@@ -583,25 +606,21 @@ function Tab(props) {
|
|
|
583
606
|
}
|
|
584
607
|
function TabPanel(props) {
|
|
585
608
|
const [local, rest] = splitProps15(props, ["value", "children", "class"]);
|
|
586
|
-
const ctx = useContext4(TabsContext);
|
|
587
|
-
const isActive = () => ctx?.activeTab() === local.value;
|
|
588
609
|
const classes = () => `tab-panel ${local.class ?? ""}`.trim();
|
|
589
|
-
return <
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
</div>
|
|
593
|
-
</Show6>;
|
|
610
|
+
return <div class={classes()} role="tabpanel" data-panel-value={local.value} hidden {...rest}>
|
|
611
|
+
{local.children}
|
|
612
|
+
</div>;
|
|
594
613
|
}
|
|
595
614
|
|
|
596
615
|
// src/components/Checkbox.tsx
|
|
597
|
-
import { splitProps as splitProps16, createEffect, onMount as
|
|
616
|
+
import { splitProps as splitProps16, createEffect, onMount as onMount4 } from "solid-js";
|
|
598
617
|
function Checkbox(props) {
|
|
599
618
|
const [local, rest] = splitProps16(props, ["label", "description", "indeterminate", "class", "disabled", "id"]);
|
|
600
619
|
let inputRef;
|
|
601
620
|
const setIndeterminate = () => {
|
|
602
621
|
if (inputRef) inputRef.indeterminate = local.indeterminate ?? false;
|
|
603
622
|
};
|
|
604
|
-
|
|
623
|
+
onMount4(setIndeterminate);
|
|
605
624
|
createEffect(setIndeterminate);
|
|
606
625
|
const classes = () => `checkbox ${local.disabled ? "checkbox-disabled" : ""} ${local.class ?? ""}`.trim();
|
|
607
626
|
const inputId = () => local.id ?? (local.label ? `checkbox-${local.label.toLowerCase().replace(/\s+/g, "-")}` : void 0);
|
|
@@ -646,29 +665,29 @@ function Toggle(props) {
|
|
|
646
665
|
}
|
|
647
666
|
|
|
648
667
|
// src/components/FormField.tsx
|
|
649
|
-
import { splitProps as splitProps18, Show as
|
|
668
|
+
import { splitProps as splitProps18, Show as Show6 } from "solid-js";
|
|
650
669
|
function FormField(props) {
|
|
651
670
|
const [local, rest] = splitProps18(props, ["label", "error", "description", "required", "children", "id", "class"]);
|
|
652
671
|
const classes = () => `form-field ${local.error ? "form-field-has-error" : ""} ${local.class ?? ""}`.trim();
|
|
653
672
|
return <div class={classes()} {...rest}>
|
|
654
673
|
<label class="form-field-label" for={local.id}>
|
|
655
674
|
{local.label}
|
|
656
|
-
<
|
|
675
|
+
<Show6 when={local.required}>
|
|
657
676
|
<span class="form-field-required" aria-hidden="true">*</span>
|
|
658
|
-
</
|
|
677
|
+
</Show6>
|
|
659
678
|
</label>
|
|
660
|
-
<
|
|
679
|
+
<Show6 when={local.description}>
|
|
661
680
|
<span class="form-field-description">{local.description}</span>
|
|
662
|
-
</
|
|
681
|
+
</Show6>
|
|
663
682
|
{local.children}
|
|
664
|
-
<
|
|
683
|
+
<Show6 when={local.error}>
|
|
665
684
|
<span class="form-field-error" role="alert">{local.error}</span>
|
|
666
|
-
</
|
|
685
|
+
</Show6>
|
|
667
686
|
</div>;
|
|
668
687
|
}
|
|
669
688
|
|
|
670
689
|
// src/components/Timeline.tsx
|
|
671
|
-
import { splitProps as splitProps19, For as
|
|
690
|
+
import { splitProps as splitProps19, For as For2, Show as Show7 } from "solid-js";
|
|
672
691
|
var variantClasses3 = {
|
|
673
692
|
default: "",
|
|
674
693
|
success: "timeline-item-success",
|
|
@@ -687,27 +706,27 @@ function Timeline(props) {
|
|
|
687
706
|
return parts.join(" ");
|
|
688
707
|
};
|
|
689
708
|
return <div class={classes()} {...rest}>
|
|
690
|
-
<
|
|
709
|
+
<For2 each={local.items}>
|
|
691
710
|
{(item, index) => <div
|
|
692
711
|
class={`timeline-item vertical-connector-item ${variantClasses3[item.variant ?? "default"]}`}
|
|
693
712
|
>
|
|
694
713
|
<div class="timeline-indicator vertical-indicator">
|
|
695
|
-
<
|
|
714
|
+
<Show7 when={item.icon} fallback={<DefaultDot />}>
|
|
696
715
|
{item.icon}
|
|
697
|
-
</
|
|
716
|
+
</Show7>
|
|
698
717
|
</div>
|
|
699
718
|
<div class="vertical-connector" />
|
|
700
719
|
<div class="timeline-content vertical-content">
|
|
701
720
|
<div class="timeline-title">{item.title}</div>
|
|
702
|
-
<
|
|
721
|
+
<Show7 when={item.description}>
|
|
703
722
|
<div class="timeline-description">{item.description}</div>
|
|
704
|
-
</
|
|
705
|
-
<
|
|
723
|
+
</Show7>
|
|
724
|
+
<Show7 when={item.timestamp}>
|
|
706
725
|
<div class="timeline-timestamp">{item.timestamp}</div>
|
|
707
|
-
</
|
|
726
|
+
</Show7>
|
|
708
727
|
</div>
|
|
709
728
|
</div>}
|
|
710
|
-
</
|
|
729
|
+
</For2>
|
|
711
730
|
</div>;
|
|
712
731
|
}
|
|
713
732
|
export {
|