@soadtech/cli 0.1.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.
- package/dist/index.js +272 -0
- package/package.json +24 -0
- package/registry/base/cn.ts +5 -0
- package/registry/base/css-modules.d.ts +4 -0
- package/registry/base/theme/reset.css +43 -0
- package/registry/base/theme/tokens.css +154 -0
- package/registry/components/Accordion/Accordion.module.css +3 -0
- package/registry/components/Accordion/Accordion.tsx +54 -0
- package/registry/components/Accordion/Accordion.types.ts +17 -0
- package/registry/components/Accordion/AccordionContext.ts +18 -0
- package/registry/components/Accordion/AccordionItem.module.css +124 -0
- package/registry/components/Accordion/AccordionItem.tsx +148 -0
- package/registry/components/Accordion/AccordionItem.types.ts +14 -0
- package/registry/components/Accordion/index.ts +8 -0
- package/registry/components/ActionBar/ActionBar.module.css +18 -0
- package/registry/components/ActionBar/ActionBar.tsx +21 -0
- package/registry/components/ActionBar/ActionBar.types.ts +8 -0
- package/registry/components/ActionBar/ActionBarLink.module.css +31 -0
- package/registry/components/ActionBar/ActionBarLink.tsx +55 -0
- package/registry/components/ActionBar/ActionBarLink.types.ts +7 -0
- package/registry/components/ActionBar/index.ts +4 -0
- package/registry/components/Alert/Alert.module.css +172 -0
- package/registry/components/Alert/Alert.tsx +146 -0
- package/registry/components/Alert/Alert.types.ts +25 -0
- package/registry/components/Alert/index.ts +7 -0
- package/registry/components/Avatar/Avatar.module.css +100 -0
- package/registry/components/Avatar/Avatar.tsx +54 -0
- package/registry/components/Avatar/Avatar.types.ts +18 -0
- package/registry/components/Avatar/AvatarGroup.module.css +64 -0
- package/registry/components/Avatar/AvatarGroup.tsx +65 -0
- package/registry/components/Avatar/AvatarGroup.types.ts +13 -0
- package/registry/components/Avatar/index.ts +8 -0
- package/registry/components/Badge/Badge.module.css +92 -0
- package/registry/components/Badge/Badge.tsx +89 -0
- package/registry/components/Badge/Badge.types.ts +20 -0
- package/registry/components/Badge/TrendBadge.module.css +47 -0
- package/registry/components/Badge/TrendBadge.tsx +65 -0
- package/registry/components/Badge/TrendBadge.types.ts +15 -0
- package/registry/components/Badge/index.ts +14 -0
- package/registry/components/Breadcrumbs/BreadcrumbItem.tsx +41 -0
- package/registry/components/Breadcrumbs/Breadcrumbs.module.css +81 -0
- package/registry/components/Breadcrumbs/Breadcrumbs.tsx +71 -0
- package/registry/components/Breadcrumbs/Breadcrumbs.types.ts +22 -0
- package/registry/components/Breadcrumbs/index.ts +7 -0
- package/registry/components/Button/Button.module.css +169 -0
- package/registry/components/Button/Button.tsx +43 -0
- package/registry/components/Button/Button.types.ts +18 -0
- package/registry/components/Button/index.ts +7 -0
- package/registry/components/ButtonLink/ButtonLink.module.css +85 -0
- package/registry/components/ButtonLink/ButtonLink.tsx +42 -0
- package/registry/components/ButtonLink/ButtonLink.types.ts +18 -0
- package/registry/components/ButtonLink/index.ts +6 -0
- package/registry/components/Calendar/Calendar.module.css +213 -0
- package/registry/components/Calendar/Calendar.tsx +370 -0
- package/registry/components/Calendar/Calendar.types.ts +28 -0
- package/registry/components/Calendar/CalendarDialog.module.css +29 -0
- package/registry/components/Calendar/CalendarDialog.tsx +173 -0
- package/registry/components/Calendar/CalendarDialog.types.ts +30 -0
- package/registry/components/Calendar/index.ts +9 -0
- package/registry/components/Card/Card.module.css +35 -0
- package/registry/components/Card/Card.tsx +36 -0
- package/registry/components/Card/Card.types.ts +37 -0
- package/registry/components/Card/CardContent.module.css +3 -0
- package/registry/components/Card/CardContent.tsx +16 -0
- package/registry/components/Card/CardFooter.module.css +31 -0
- package/registry/components/Card/CardFooter.tsx +34 -0
- package/registry/components/Card/CardHeader.module.css +61 -0
- package/registry/components/Card/CardHeader.tsx +46 -0
- package/registry/components/Card/InsightCard.module.css +106 -0
- package/registry/components/Card/InsightCard.tsx +68 -0
- package/registry/components/Card/InsightCard.types.ts +24 -0
- package/registry/components/Card/KPICard.module.css +31 -0
- package/registry/components/Card/KPICard.tsx +29 -0
- package/registry/components/Card/KPICard.types.ts +13 -0
- package/registry/components/Card/ListItemCard.module.css +59 -0
- package/registry/components/Card/ListItemCard.tsx +37 -0
- package/registry/components/Card/ListItemCard.types.ts +18 -0
- package/registry/components/Card/PlanCard.module.css +125 -0
- package/registry/components/Card/PlanCard.tsx +108 -0
- package/registry/components/Card/PlanCard.types.ts +30 -0
- package/registry/components/Card/ProductCard.module.css +118 -0
- package/registry/components/Card/ProductCard.tsx +56 -0
- package/registry/components/Card/ProductCard.types.ts +24 -0
- package/registry/components/Card/StatCard.module.css +20 -0
- package/registry/components/Card/StatCard.tsx +26 -0
- package/registry/components/Card/StatCard.types.ts +12 -0
- package/registry/components/Card/UserGroupCard.module.css +50 -0
- package/registry/components/Card/UserGroupCard.tsx +59 -0
- package/registry/components/Card/UserGroupCard.types.ts +23 -0
- package/registry/components/Card/index.ts +38 -0
- package/registry/components/Chart/BarChart.module.css +54 -0
- package/registry/components/Chart/BarChart.tsx +196 -0
- package/registry/components/Chart/BarChart.types.ts +20 -0
- package/registry/components/Chart/ChartAction.module.css +43 -0
- package/registry/components/Chart/ChartAction.tsx +35 -0
- package/registry/components/Chart/ChartAction.types.ts +17 -0
- package/registry/components/Chart/ChartAxis.module.css +47 -0
- package/registry/components/Chart/ChartAxis.tsx +79 -0
- package/registry/components/Chart/ChartAxis.types.ts +14 -0
- package/registry/components/Chart/ChartLegend.module.css +31 -0
- package/registry/components/Chart/ChartLegend.tsx +49 -0
- package/registry/components/Chart/ChartLegend.types.ts +18 -0
- package/registry/components/Chart/ChartTooltip.module.css +54 -0
- package/registry/components/Chart/ChartTooltip.tsx +44 -0
- package/registry/components/Chart/ChartTooltip.types.ts +19 -0
- package/registry/components/Chart/DonutChart.module.css +32 -0
- package/registry/components/Chart/DonutChart.tsx +107 -0
- package/registry/components/Chart/DonutChart.types.ts +20 -0
- package/registry/components/Chart/GridChart.module.css +26 -0
- package/registry/components/Chart/GridChart.tsx +61 -0
- package/registry/components/Chart/GridChart.types.ts +14 -0
- package/registry/components/Chart/HoverTooltip.module.css +16 -0
- package/registry/components/Chart/HoverTooltip.tsx +22 -0
- package/registry/components/Chart/KPIIndicator.module.css +48 -0
- package/registry/components/Chart/KPIIndicator.tsx +28 -0
- package/registry/components/Chart/KPIIndicator.types.ts +16 -0
- package/registry/components/Chart/LineChart.module.css +54 -0
- package/registry/components/Chart/LineChart.tsx +282 -0
- package/registry/components/Chart/LineChart.types.ts +22 -0
- package/registry/components/Chart/ProgressChart.module.css +54 -0
- package/registry/components/Chart/ProgressChart.tsx +64 -0
- package/registry/components/Chart/ProgressChart.types.ts +18 -0
- package/registry/components/Chart/TrendLineChart.module.css +5 -0
- package/registry/components/Chart/TrendLineChart.tsx +131 -0
- package/registry/components/Chart/TrendLineChart.types.ts +19 -0
- package/registry/components/Chart/chart.utils.ts +131 -0
- package/registry/components/Chart/index.ts +47 -0
- package/registry/components/Chart/useChartHover.ts +24 -0
- package/registry/components/Checkbox/Checkbox.module.css +101 -0
- package/registry/components/Checkbox/Checkbox.tsx +100 -0
- package/registry/components/Checkbox/Checkbox.types.ts +11 -0
- package/registry/components/Checkbox/CheckboxField.module.css +69 -0
- package/registry/components/Checkbox/CheckboxField.tsx +54 -0
- package/registry/components/Checkbox/CheckboxField.types.ts +9 -0
- package/registry/components/Checkbox/CheckboxGroup.module.css +41 -0
- package/registry/components/Checkbox/CheckboxGroup.tsx +60 -0
- package/registry/components/Checkbox/CheckboxGroup.types.ts +11 -0
- package/registry/components/Checkbox/CheckboxGroupContext.ts +13 -0
- package/registry/components/Checkbox/index.ts +11 -0
- package/registry/components/Chip/Chip.module.css +143 -0
- package/registry/components/Chip/Chip.tsx +93 -0
- package/registry/components/Chip/Chip.types.ts +19 -0
- package/registry/components/Chip/ChipGroup.module.css +5 -0
- package/registry/components/Chip/ChipGroup.tsx +16 -0
- package/registry/components/Chip/ChipGroup.types.ts +3 -0
- package/registry/components/Chip/index.ts +9 -0
- package/registry/components/Datepicker/Datepicker.module.css +133 -0
- package/registry/components/Datepicker/Datepicker.tsx +236 -0
- package/registry/components/Datepicker/Datepicker.types.ts +36 -0
- package/registry/components/Datepicker/index.ts +2 -0
- package/registry/components/Dialog/Dialog.module.css +18 -0
- package/registry/components/Dialog/Dialog.tsx +69 -0
- package/registry/components/Dialog/Dialog.types.ts +45 -0
- package/registry/components/Dialog/DialogBody.module.css +3 -0
- package/registry/components/Dialog/DialogBody.tsx +16 -0
- package/registry/components/Dialog/DialogContext.ts +11 -0
- package/registry/components/Dialog/DialogFooter.module.css +38 -0
- package/registry/components/Dialog/DialogFooter.tsx +30 -0
- package/registry/components/Dialog/DialogHeader.module.css +70 -0
- package/registry/components/Dialog/DialogHeader.tsx +72 -0
- package/registry/components/Dialog/DialogIcon.module.css +31 -0
- package/registry/components/Dialog/DialogIcon.tsx +89 -0
- package/registry/components/Dialog/index.ts +14 -0
- package/registry/components/Divider/Divider.module.css +19 -0
- package/registry/components/Divider/Divider.tsx +20 -0
- package/registry/components/Divider/Divider.types.ts +9 -0
- package/registry/components/Divider/index.ts +2 -0
- package/registry/components/DropdownMenu/DropdownMenu.module.css +9 -0
- package/registry/components/DropdownMenu/DropdownMenu.tsx +21 -0
- package/registry/components/DropdownMenu/DropdownMenu.types.ts +22 -0
- package/registry/components/DropdownMenu/DropdownMenuDivider.module.css +5 -0
- package/registry/components/DropdownMenu/DropdownMenuDivider.tsx +20 -0
- package/registry/components/DropdownMenu/DropdownMenuHeader.module.css +7 -0
- package/registry/components/DropdownMenu/DropdownMenuHeader.tsx +17 -0
- package/registry/components/DropdownMenu/DropdownMenuItem.module.css +78 -0
- package/registry/components/DropdownMenu/DropdownMenuItem.tsx +40 -0
- package/registry/components/DropdownMenu/index.ts +10 -0
- package/registry/components/FileUpload/FileUpload.module.css +122 -0
- package/registry/components/FileUpload/FileUpload.tsx +354 -0
- package/registry/components/FileUpload/FileUpload.types.ts +89 -0
- package/registry/components/FileUpload/FileUploadIcon.module.css +61 -0
- package/registry/components/FileUpload/FileUploadIcon.tsx +84 -0
- package/registry/components/FileUpload/FileUploadInput.module.css +140 -0
- package/registry/components/FileUpload/FileUploadInput.tsx +113 -0
- package/registry/components/FileUpload/FileUploadItem.module.css +41 -0
- package/registry/components/FileUpload/FileUploadItem.tsx +39 -0
- package/registry/components/FileUpload/index.ts +12 -0
- package/registry/components/InputCounter/InputCounter.module.css +146 -0
- package/registry/components/InputCounter/InputCounter.tsx +232 -0
- package/registry/components/InputCounter/InputCounter.types.ts +37 -0
- package/registry/components/InputCounter/index.ts +7 -0
- package/registry/components/InputMessage/InputMessage.module.css +148 -0
- package/registry/components/InputMessage/InputMessage.tsx +294 -0
- package/registry/components/InputMessage/InputMessage.types.ts +30 -0
- package/registry/components/InputMessage/index.ts +2 -0
- package/registry/components/InputSearch/InputSearch.module.css +168 -0
- package/registry/components/InputSearch/InputSearch.tsx +251 -0
- package/registry/components/InputSearch/InputSearch.types.ts +35 -0
- package/registry/components/InputSearch/index.ts +6 -0
- package/registry/components/InputText/InputText.module.css +183 -0
- package/registry/components/InputText/InputText.tsx +244 -0
- package/registry/components/InputText/InputText.types.ts +32 -0
- package/registry/components/InputText/index.ts +7 -0
- package/registry/components/InputTextArea/InputTextArea.module.css +141 -0
- package/registry/components/InputTextArea/InputTextArea.tsx +170 -0
- package/registry/components/InputTextArea/InputTextArea.types.ts +18 -0
- package/registry/components/InputTextArea/index.ts +6 -0
- package/registry/components/NavbarUser/NavbarUser.module.css +265 -0
- package/registry/components/NavbarUser/NavbarUser.tsx +202 -0
- package/registry/components/NavbarUser/NavbarUser.types.ts +31 -0
- package/registry/components/NavbarUser/index.ts +2 -0
- package/registry/components/Notification/Notification.types.ts +65 -0
- package/registry/components/Notification/NotificationItem.module.css +143 -0
- package/registry/components/Notification/NotificationItem.tsx +157 -0
- package/registry/components/Notification/NotificationPanel.module.css +75 -0
- package/registry/components/Notification/NotificationPanel.tsx +68 -0
- package/registry/components/Notification/NotificationReply.module.css +56 -0
- package/registry/components/Notification/NotificationReply.tsx +52 -0
- package/registry/components/Notification/index.ts +9 -0
- package/registry/components/Pagination/Pagination.module.css +123 -0
- package/registry/components/Pagination/Pagination.tsx +212 -0
- package/registry/components/Pagination/Pagination.types.ts +24 -0
- package/registry/components/Pagination/PaginationDots.module.css +60 -0
- package/registry/components/Pagination/PaginationDots.tsx +48 -0
- package/registry/components/Pagination/PaginationDots.types.ts +17 -0
- package/registry/components/Pagination/index.ts +12 -0
- package/registry/components/Persona/MessageDropdown.module.css +76 -0
- package/registry/components/Persona/MessageDropdown.tsx +68 -0
- package/registry/components/Persona/Persona.module.css +92 -0
- package/registry/components/Persona/Persona.tsx +90 -0
- package/registry/components/Persona/Persona.types.ts +71 -0
- package/registry/components/Persona/PersonaAction.module.css +80 -0
- package/registry/components/Persona/PersonaAction.tsx +49 -0
- package/registry/components/Persona/PersonaMessage.module.css +156 -0
- package/registry/components/Persona/PersonaMessage.tsx +70 -0
- package/registry/components/Persona/index.ts +11 -0
- package/registry/components/Progress/Progress.module.css +41 -0
- package/registry/components/Progress/Progress.tsx +43 -0
- package/registry/components/Progress/Progress.types.ts +10 -0
- package/registry/components/Progress/index.ts +2 -0
- package/registry/components/RadioButton/RadioButton.module.css +103 -0
- package/registry/components/RadioButton/RadioButton.tsx +59 -0
- package/registry/components/RadioButton/RadioButton.types.ts +19 -0
- package/registry/components/RadioButton/RadioField.module.css +68 -0
- package/registry/components/RadioButton/RadioField.tsx +68 -0
- package/registry/components/RadioButton/RadioGroup.module.css +41 -0
- package/registry/components/RadioButton/RadioGroup.tsx +76 -0
- package/registry/components/RadioButton/RadioGroupContext.ts +16 -0
- package/registry/components/RadioButton/index.ts +12 -0
- package/registry/components/RangeSlider/RangeSlider.module.css +133 -0
- package/registry/components/RangeSlider/RangeSlider.tsx +251 -0
- package/registry/components/RangeSlider/RangeSlider.types.ts +25 -0
- package/registry/components/RangeSlider/index.ts +2 -0
- package/registry/components/Rating/Rating.module.css +56 -0
- package/registry/components/Rating/Rating.tsx +142 -0
- package/registry/components/Rating/Rating.types.ts +14 -0
- package/registry/components/Rating/index.ts +7 -0
- package/registry/components/SegmentedControl/SegmentedControl.module.css +56 -0
- package/registry/components/SegmentedControl/SegmentedControl.tsx +46 -0
- package/registry/components/SegmentedControl/SegmentedControl.types.ts +27 -0
- package/registry/components/SegmentedControl/SegmentedControlContext.ts +20 -0
- package/registry/components/SegmentedControl/SegmentedControlItem.module.css +55 -0
- package/registry/components/SegmentedControl/SegmentedControlItem.tsx +32 -0
- package/registry/components/SegmentedControl/index.ts +8 -0
- package/registry/components/SelectDropdown/SelectDropdown.module.css +214 -0
- package/registry/components/SelectDropdown/SelectDropdown.tsx +375 -0
- package/registry/components/SelectDropdown/SelectDropdown.types.ts +50 -0
- package/registry/components/SelectDropdown/SelectDropdownOption.module.css +101 -0
- package/registry/components/SelectDropdown/SelectDropdownOption.tsx +86 -0
- package/registry/components/SelectDropdown/SelectDropdownOverlay.module.css +74 -0
- package/registry/components/SelectDropdown/SelectDropdownOverlay.tsx +202 -0
- package/registry/components/SelectDropdown/index.ts +11 -0
- package/registry/components/Sidebar/Sidebar.module.css +14 -0
- package/registry/components/Sidebar/Sidebar.tsx +41 -0
- package/registry/components/Sidebar/Sidebar.types.ts +41 -0
- package/registry/components/Sidebar/SidebarContent.module.css +5 -0
- package/registry/components/Sidebar/SidebarContent.tsx +14 -0
- package/registry/components/Sidebar/SidebarContext.ts +15 -0
- package/registry/components/Sidebar/SidebarDivider.module.css +5 -0
- package/registry/components/Sidebar/SidebarDivider.tsx +17 -0
- package/registry/components/Sidebar/SidebarFooter.module.css +5 -0
- package/registry/components/Sidebar/SidebarFooter.tsx +14 -0
- package/registry/components/Sidebar/SidebarGroup.module.css +12 -0
- package/registry/components/Sidebar/SidebarGroup.tsx +22 -0
- package/registry/components/Sidebar/SidebarHeader.module.css +5 -0
- package/registry/components/Sidebar/SidebarHeader.tsx +14 -0
- package/registry/components/Sidebar/SidebarNavItem.module.css +176 -0
- package/registry/components/Sidebar/SidebarNavItem.tsx +96 -0
- package/registry/components/Sidebar/index.ts +16 -0
- package/registry/components/Stepper/Stepper.module.css +11 -0
- package/registry/components/Stepper/Stepper.tsx +47 -0
- package/registry/components/Stepper/Stepper.types.ts +26 -0
- package/registry/components/Stepper/StepperContext.ts +17 -0
- package/registry/components/Stepper/StepperStep.module.css +183 -0
- package/registry/components/Stepper/StepperStep.tsx +204 -0
- package/registry/components/Stepper/index.ts +9 -0
- package/registry/components/Switch/Switch.module.css +145 -0
- package/registry/components/Switch/Switch.tsx +96 -0
- package/registry/components/Switch/Switch.types.ts +19 -0
- package/registry/components/Switch/SwitchField.module.css +69 -0
- package/registry/components/Switch/SwitchField.tsx +49 -0
- package/registry/components/Switch/index.ts +8 -0
- package/registry/components/Tab/Tab.module.css +20 -0
- package/registry/components/Tab/Tab.tsx +35 -0
- package/registry/components/Tab/Tab.types.ts +21 -0
- package/registry/components/Tab/TabAdd.module.css +36 -0
- package/registry/components/Tab/TabAdd.tsx +41 -0
- package/registry/components/Tab/TabContext.ts +19 -0
- package/registry/components/Tab/TabItem.module.css +145 -0
- package/registry/components/Tab/TabItem.tsx +87 -0
- package/registry/components/Tab/index.ts +9 -0
- package/registry/components/Table/Table.module.css +33 -0
- package/registry/components/Table/Table.tsx +74 -0
- package/registry/components/Table/Table.types.ts +64 -0
- package/registry/components/Table/TableBody.tsx +23 -0
- package/registry/components/Table/TableCell.module.css +21 -0
- package/registry/components/Table/TableCell.tsx +20 -0
- package/registry/components/Table/TableContext.ts +22 -0
- package/registry/components/Table/TableFooter.module.css +27 -0
- package/registry/components/Table/TableFooter.tsx +20 -0
- package/registry/components/Table/TableHeader.module.css +3 -0
- package/registry/components/Table/TableHeader.tsx +17 -0
- package/registry/components/Table/TableHeaderCell.module.css +55 -0
- package/registry/components/Table/TableHeaderCell.tsx +98 -0
- package/registry/components/Table/TableRow.module.css +53 -0
- package/registry/components/Table/TableRow.tsx +31 -0
- package/registry/components/Table/TableToolbar.module.css +7 -0
- package/registry/components/Table/TableToolbar.tsx +16 -0
- package/registry/components/Table/index.ts +22 -0
- package/registry/components/Tag/Tag.module.css +46 -0
- package/registry/components/Tag/Tag.tsx +38 -0
- package/registry/components/Tag/Tag.types.ts +37 -0
- package/registry/components/Tag/TagBrand.module.css +42 -0
- package/registry/components/Tag/TagBrand.tsx +38 -0
- package/registry/components/Tag/TagStatus.module.css +43 -0
- package/registry/components/Tag/TagStatus.tsx +119 -0
- package/registry/components/Tag/index.ts +15 -0
- package/registry/components/Tooltip/Tooltip.module.css +208 -0
- package/registry/components/Tooltip/Tooltip.tsx +81 -0
- package/registry/components/Tooltip/Tooltip.types.ts +27 -0
- package/registry/components/Tooltip/index.ts +7 -0
- package/registry/components/TreeviewList/TreeviewItem.module.css +89 -0
- package/registry/components/TreeviewList/TreeviewItem.tsx +142 -0
- package/registry/components/TreeviewList/TreeviewList.module.css +3 -0
- package/registry/components/TreeviewList/TreeviewList.tsx +19 -0
- package/registry/components/TreeviewList/TreeviewList.types.ts +18 -0
- package/registry/components/TreeviewList/TreeviewListContext.ts +13 -0
- package/registry/components/TreeviewList/index.ts +6 -0
- package/registry/components/VerificationCode/VerificationCode.module.css +49 -0
- package/registry/components/VerificationCode/VerificationCode.tsx +147 -0
- package/registry/components/VerificationCode/VerificationCode.types.ts +21 -0
- package/registry/components/VerificationCode/index.ts +2 -0
- package/registry/registry.json +746 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/index.ts
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
|
|
6
|
+
// src/commands/init.ts
|
|
7
|
+
import { resolve as resolve3 } from "path";
|
|
8
|
+
import { copyFileSync, mkdirSync, existsSync as existsSync2 } from "fs";
|
|
9
|
+
import { execSync } from "child_process";
|
|
10
|
+
import prompts from "prompts";
|
|
11
|
+
|
|
12
|
+
// src/utils/config.ts
|
|
13
|
+
import { readFileSync, writeFileSync, existsSync } from "fs";
|
|
14
|
+
import { resolve } from "path";
|
|
15
|
+
var CONFIG_FILE = "components.json";
|
|
16
|
+
function getConfigPath(cwd) {
|
|
17
|
+
return resolve(cwd, CONFIG_FILE);
|
|
18
|
+
}
|
|
19
|
+
function readConfig(cwd) {
|
|
20
|
+
const configPath = getConfigPath(cwd);
|
|
21
|
+
if (!existsSync(configPath)) return null;
|
|
22
|
+
return JSON.parse(readFileSync(configPath, "utf-8"));
|
|
23
|
+
}
|
|
24
|
+
function writeConfig(cwd, config) {
|
|
25
|
+
const configPath = getConfigPath(cwd);
|
|
26
|
+
writeFileSync(configPath, JSON.stringify(config, null, 2) + "\n");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// src/registry.ts
|
|
30
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
31
|
+
import { resolve as resolve2, dirname } from "path";
|
|
32
|
+
import { fileURLToPath } from "url";
|
|
33
|
+
function getRegistryDir() {
|
|
34
|
+
const currentDir = dirname(fileURLToPath(import.meta.url));
|
|
35
|
+
return resolve2(currentDir, "../registry");
|
|
36
|
+
}
|
|
37
|
+
function loadRegistry() {
|
|
38
|
+
const registryPath = resolve2(getRegistryDir(), "registry.json");
|
|
39
|
+
return JSON.parse(readFileSync2(registryPath, "utf-8"));
|
|
40
|
+
}
|
|
41
|
+
function getComponentSourceDir(componentName) {
|
|
42
|
+
return resolve2(getRegistryDir(), "components", componentName);
|
|
43
|
+
}
|
|
44
|
+
function getBaseDir() {
|
|
45
|
+
return resolve2(getRegistryDir(), "base");
|
|
46
|
+
}
|
|
47
|
+
function resolveTransitiveDeps(registry, componentNames) {
|
|
48
|
+
const resolved = /* @__PURE__ */ new Set();
|
|
49
|
+
const queue = [...componentNames];
|
|
50
|
+
while (queue.length > 0) {
|
|
51
|
+
const name = queue.pop();
|
|
52
|
+
if (resolved.has(name)) continue;
|
|
53
|
+
const component = registry.components[name];
|
|
54
|
+
if (!component) {
|
|
55
|
+
throw new Error(`Component "${name}" not found in registry.`);
|
|
56
|
+
}
|
|
57
|
+
resolved.add(name);
|
|
58
|
+
for (const dep of component.dependencies) {
|
|
59
|
+
if (!resolved.has(dep)) {
|
|
60
|
+
queue.push(dep);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return [...resolved].sort();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// src/utils/logger.ts
|
|
68
|
+
import pc from "picocolors";
|
|
69
|
+
var logger = {
|
|
70
|
+
info: (...args) => console.log(pc.cyan("info"), ...args),
|
|
71
|
+
success: (...args) => console.log(pc.green("success"), ...args),
|
|
72
|
+
warn: (...args) => console.log(pc.yellow("warn"), ...args),
|
|
73
|
+
error: (...args) => console.log(pc.red("error"), ...args)
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/commands/init.ts
|
|
77
|
+
var DEFAULTS = {
|
|
78
|
+
components: "src/components/ui",
|
|
79
|
+
utils: "src/lib",
|
|
80
|
+
theme: "src/styles"
|
|
81
|
+
};
|
|
82
|
+
function detectPackageManager(cwd) {
|
|
83
|
+
if (existsSync2(resolve3(cwd, "bun.lockb")) || existsSync2(resolve3(cwd, "bun.lock"))) return "bun";
|
|
84
|
+
if (existsSync2(resolve3(cwd, "pnpm-lock.yaml"))) return "pnpm";
|
|
85
|
+
if (existsSync2(resolve3(cwd, "yarn.lock"))) return "yarn";
|
|
86
|
+
return "npm";
|
|
87
|
+
}
|
|
88
|
+
async function init(options) {
|
|
89
|
+
const { cwd } = options;
|
|
90
|
+
if (existsSync2(getConfigPath(cwd))) {
|
|
91
|
+
logger.warn("components.json already exists. Overwriting.");
|
|
92
|
+
}
|
|
93
|
+
let aliases = DEFAULTS;
|
|
94
|
+
if (!options.yes) {
|
|
95
|
+
const response = await prompts([
|
|
96
|
+
{
|
|
97
|
+
type: "text",
|
|
98
|
+
name: "components",
|
|
99
|
+
message: "Components directory:",
|
|
100
|
+
initial: DEFAULTS.components
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
type: "text",
|
|
104
|
+
name: "utils",
|
|
105
|
+
message: "Utils directory:",
|
|
106
|
+
initial: DEFAULTS.utils
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
type: "text",
|
|
110
|
+
name: "theme",
|
|
111
|
+
message: "Theme directory:",
|
|
112
|
+
initial: DEFAULTS.theme
|
|
113
|
+
}
|
|
114
|
+
]);
|
|
115
|
+
if (!response.components) {
|
|
116
|
+
logger.error("Cancelled.");
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
aliases = {
|
|
120
|
+
components: response.components,
|
|
121
|
+
utils: response.utils,
|
|
122
|
+
theme: response.theme
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
const baseDir = getBaseDir();
|
|
126
|
+
const themeDir = resolve3(cwd, aliases.theme);
|
|
127
|
+
mkdirSync(themeDir, { recursive: true });
|
|
128
|
+
copyFileSync(
|
|
129
|
+
resolve3(baseDir, "theme/tokens.css"),
|
|
130
|
+
resolve3(themeDir, "tokens.css")
|
|
131
|
+
);
|
|
132
|
+
logger.success(`Copied tokens.css \u2192 ${aliases.theme}/tokens.css`);
|
|
133
|
+
const utilsDir = resolve3(cwd, aliases.utils);
|
|
134
|
+
mkdirSync(utilsDir, { recursive: true });
|
|
135
|
+
copyFileSync(resolve3(baseDir, "cn.ts"), resolve3(utilsDir, "cn.ts"));
|
|
136
|
+
logger.success(`Copied cn.ts \u2192 ${aliases.utils}/cn.ts`);
|
|
137
|
+
copyFileSync(
|
|
138
|
+
resolve3(baseDir, "css-modules.d.ts"),
|
|
139
|
+
resolve3(cwd, "css-modules.d.ts")
|
|
140
|
+
);
|
|
141
|
+
logger.success("Copied css-modules.d.ts \u2192 project root");
|
|
142
|
+
mkdirSync(resolve3(cwd, aliases.components), { recursive: true });
|
|
143
|
+
const pm = detectPackageManager(cwd);
|
|
144
|
+
const pkgJsonPath = resolve3(cwd, "package.json");
|
|
145
|
+
if (existsSync2(pkgJsonPath)) {
|
|
146
|
+
const pkg = JSON.parse(
|
|
147
|
+
(await import("fs")).readFileSync(pkgJsonPath, "utf-8")
|
|
148
|
+
);
|
|
149
|
+
const allDeps = {
|
|
150
|
+
...pkg.dependencies,
|
|
151
|
+
...pkg.devDependencies
|
|
152
|
+
};
|
|
153
|
+
if (!allDeps["clsx"]) {
|
|
154
|
+
logger.info(`Installing clsx with ${pm}...`);
|
|
155
|
+
const installCmd = pm === "npm" ? "npm install clsx" : `${pm} add clsx`;
|
|
156
|
+
execSync(installCmd, { cwd, stdio: "inherit" });
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
writeConfig(cwd, { aliases });
|
|
160
|
+
logger.success("Created components.json");
|
|
161
|
+
logger.info("Run `npx @soadtech/cli add <component>` to add components.");
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// src/commands/add.ts
|
|
165
|
+
import { resolve as resolve4 } from "path";
|
|
166
|
+
import prompts2 from "prompts";
|
|
167
|
+
|
|
168
|
+
// src/utils/fs.ts
|
|
169
|
+
import { cpSync, existsSync as existsSync3, mkdirSync as mkdirSync2 } from "fs";
|
|
170
|
+
function copyDir(src, dest) {
|
|
171
|
+
mkdirSync2(dest, { recursive: true });
|
|
172
|
+
cpSync(src, dest, { recursive: true });
|
|
173
|
+
}
|
|
174
|
+
function exists(path) {
|
|
175
|
+
return existsSync3(path);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
// src/transform.ts
|
|
179
|
+
import { readFileSync as readFileSync3, writeFileSync as writeFileSync2, readdirSync } from "fs";
|
|
180
|
+
import { join, relative, dirname as dirname2 } from "path";
|
|
181
|
+
function rewriteImports(componentDir, utilsDir) {
|
|
182
|
+
const files = readdirSync(componentDir).filter(
|
|
183
|
+
(f) => f.endsWith(".ts") || f.endsWith(".tsx")
|
|
184
|
+
);
|
|
185
|
+
for (const file of files) {
|
|
186
|
+
const filePath = join(componentDir, file);
|
|
187
|
+
let content = readFileSync3(filePath, "utf-8");
|
|
188
|
+
const fromDir = dirname2(filePath);
|
|
189
|
+
const targetCn = join(utilsDir, "cn");
|
|
190
|
+
let rel = relative(fromDir, targetCn);
|
|
191
|
+
rel = rel.split("\\").join("/");
|
|
192
|
+
if (!rel.startsWith(".")) rel = "./" + rel;
|
|
193
|
+
content = content.replace(
|
|
194
|
+
/from\s+['"]\.\.\/\.\.\/utils\/cn['"]/g,
|
|
195
|
+
`from '${rel}'`
|
|
196
|
+
);
|
|
197
|
+
writeFileSync2(filePath, content, "utf-8");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// src/commands/add.ts
|
|
202
|
+
async function add(componentNames, options) {
|
|
203
|
+
const { cwd } = options;
|
|
204
|
+
const config = readConfig(cwd);
|
|
205
|
+
if (!config) {
|
|
206
|
+
logger.error(
|
|
207
|
+
"components.json not found. Run `npx @soadtech/cli init` first."
|
|
208
|
+
);
|
|
209
|
+
process.exit(1);
|
|
210
|
+
}
|
|
211
|
+
const registry = loadRegistry();
|
|
212
|
+
for (const name of componentNames) {
|
|
213
|
+
if (!registry.components[name]) {
|
|
214
|
+
logger.error(
|
|
215
|
+
`Component "${name}" not found. Available: ${Object.keys(registry.components).join(", ")}`
|
|
216
|
+
);
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const allComponents = resolveTransitiveDeps(registry, componentNames);
|
|
221
|
+
const componentsDir = resolve4(cwd, config.aliases.components);
|
|
222
|
+
const existing = allComponents.filter(
|
|
223
|
+
(name) => exists(resolve4(componentsDir, name))
|
|
224
|
+
);
|
|
225
|
+
const toInstall = options.overwrite ? allComponents : allComponents.filter((name) => !existing.includes(name));
|
|
226
|
+
if (existing.length > 0 && !options.overwrite) {
|
|
227
|
+
logger.info(
|
|
228
|
+
`Skipping existing: ${existing.join(", ")} (use --overwrite to replace)`
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
if (toInstall.length === 0) {
|
|
232
|
+
logger.info("All components already installed.");
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
if (!options.yes) {
|
|
236
|
+
logger.info(`Components to install: ${toInstall.join(", ")}`);
|
|
237
|
+
const { confirm } = await prompts2({
|
|
238
|
+
type: "confirm",
|
|
239
|
+
name: "confirm",
|
|
240
|
+
message: "Proceed?",
|
|
241
|
+
initial: true
|
|
242
|
+
});
|
|
243
|
+
if (!confirm) {
|
|
244
|
+
logger.error("Cancelled.");
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
const utilsDir = resolve4(cwd, config.aliases.utils);
|
|
249
|
+
for (const name of toInstall) {
|
|
250
|
+
const src = getComponentSourceDir(name);
|
|
251
|
+
const dest = resolve4(componentsDir, name);
|
|
252
|
+
copyDir(src, dest);
|
|
253
|
+
rewriteImports(dest, utilsDir);
|
|
254
|
+
logger.success(`Added ${name}`);
|
|
255
|
+
}
|
|
256
|
+
logger.info(`Done. ${toInstall.length} component(s) installed.`);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// src/index.ts
|
|
260
|
+
var program = new Command();
|
|
261
|
+
program.name("soadtech").description("Add soadtech-ui components to your project").version("0.1.0");
|
|
262
|
+
program.command("init").description("Initialize your project for soadtech-ui components").option("-y, --yes", "Use default configuration", false).option("--cwd <path>", "Working directory", process.cwd()).action(async (opts) => {
|
|
263
|
+
await init({ yes: opts.yes, cwd: opts.cwd });
|
|
264
|
+
});
|
|
265
|
+
program.command("add").description("Add components to your project").argument("<components...>", "Components to add").option("--overwrite", "Overwrite existing components", false).option("-y, --yes", "Skip confirmation", false).option("--cwd <path>", "Working directory", process.cwd()).action(async (components, opts) => {
|
|
266
|
+
await add(components, {
|
|
267
|
+
overwrite: opts.overwrite,
|
|
268
|
+
yes: opts.yes,
|
|
269
|
+
cwd: opts.cwd
|
|
270
|
+
});
|
|
271
|
+
});
|
|
272
|
+
program.parse();
|
package/package.json
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@soadtech/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"bin": {
|
|
6
|
+
"soadtech": "./dist/index.js"
|
|
7
|
+
},
|
|
8
|
+
"files": ["dist", "registry"],
|
|
9
|
+
"scripts": {
|
|
10
|
+
"prebuild": "tsx scripts/copy-source.ts",
|
|
11
|
+
"build": "tsup"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"commander": "^13.1.0",
|
|
15
|
+
"picocolors": "^1.1.1",
|
|
16
|
+
"prompts": "^2.4.2"
|
|
17
|
+
},
|
|
18
|
+
"devDependencies": {
|
|
19
|
+
"@types/prompts": "^2.4.9",
|
|
20
|
+
"tsup": "^8.4.0",
|
|
21
|
+
"tsx": "^4.19.0",
|
|
22
|
+
"typescript": "^5.7.3"
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
*,
|
|
2
|
+
*::before,
|
|
3
|
+
*::after {
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
* {
|
|
8
|
+
margin: 0;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
body {
|
|
12
|
+
line-height: var(--st-line-height-normal);
|
|
13
|
+
-webkit-font-smoothing: antialiased;
|
|
14
|
+
font-family: var(--st-font-family);
|
|
15
|
+
color: var(--st-color-foreground);
|
|
16
|
+
background-color: var(--st-color-background);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
img,
|
|
20
|
+
picture,
|
|
21
|
+
video,
|
|
22
|
+
canvas,
|
|
23
|
+
svg {
|
|
24
|
+
display: block;
|
|
25
|
+
max-width: 100%;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
input,
|
|
29
|
+
button,
|
|
30
|
+
textarea,
|
|
31
|
+
select {
|
|
32
|
+
font: inherit;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
p,
|
|
36
|
+
h1,
|
|
37
|
+
h2,
|
|
38
|
+
h3,
|
|
39
|
+
h4,
|
|
40
|
+
h5,
|
|
41
|
+
h6 {
|
|
42
|
+
overflow-wrap: break-word;
|
|
43
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
:root {
|
|
2
|
+
/* ─── Colors: Primary ─── */
|
|
3
|
+
--st-color-primary: #2563eb;
|
|
4
|
+
--st-color-primary-hover: #1d4ed8;
|
|
5
|
+
--st-color-primary-active: #1e40af;
|
|
6
|
+
--st-color-primary-subtle: #eff6ff;
|
|
7
|
+
--st-color-primary-foreground: #ffffff;
|
|
8
|
+
|
|
9
|
+
/* ─── Colors: Secondary ─── */
|
|
10
|
+
--st-color-secondary: #7c3aed;
|
|
11
|
+
--st-color-secondary-hover: #6d28d9;
|
|
12
|
+
--st-color-secondary-active: #5b21b6;
|
|
13
|
+
--st-color-secondary-subtle: #f5f3ff;
|
|
14
|
+
--st-color-secondary-foreground: #ffffff;
|
|
15
|
+
|
|
16
|
+
/* ─── Colors: Tertiary ─── */
|
|
17
|
+
--st-color-tertiary: #ec4899;
|
|
18
|
+
--st-color-tertiary-hover: #db2777;
|
|
19
|
+
--st-color-tertiary-active: #be185d;
|
|
20
|
+
--st-color-tertiary-subtle: #fdf2f8;
|
|
21
|
+
--st-color-tertiary-foreground: #ffffff;
|
|
22
|
+
|
|
23
|
+
/* ─── Colors: Neutral scale ─── */
|
|
24
|
+
--st-color-neutral-50: #fafafa;
|
|
25
|
+
--st-color-neutral-100: #f5f5f5;
|
|
26
|
+
--st-color-neutral-200: #e5e5e5;
|
|
27
|
+
--st-color-neutral-300: #d4d4d4;
|
|
28
|
+
--st-color-neutral-400: #a3a3a3;
|
|
29
|
+
--st-color-neutral-500: #737373;
|
|
30
|
+
--st-color-neutral-600: #525252;
|
|
31
|
+
--st-color-neutral-700: #404040;
|
|
32
|
+
--st-color-neutral-800: #262626;
|
|
33
|
+
--st-color-neutral-900: #171717;
|
|
34
|
+
--st-color-neutral-950: #0a0a0a;
|
|
35
|
+
|
|
36
|
+
/* ─── Colors: Semantic ─── */
|
|
37
|
+
--st-color-success: #16a34a;
|
|
38
|
+
--st-color-success-hover: #15803d;
|
|
39
|
+
--st-color-success-subtle: #f0fdf4;
|
|
40
|
+
--st-color-success-foreground: #ffffff;
|
|
41
|
+
|
|
42
|
+
--st-color-warning: #d97706;
|
|
43
|
+
--st-color-warning-hover: #b45309;
|
|
44
|
+
--st-color-warning-subtle: #fffbeb;
|
|
45
|
+
--st-color-warning-foreground: #ffffff;
|
|
46
|
+
|
|
47
|
+
--st-color-error: #dc2626;
|
|
48
|
+
--st-color-error-hover: #b91c1c;
|
|
49
|
+
--st-color-error-subtle: #fef2f2;
|
|
50
|
+
--st-color-error-foreground: #ffffff;
|
|
51
|
+
|
|
52
|
+
--st-color-info: #0284c7;
|
|
53
|
+
--st-color-info-hover: #0369a1;
|
|
54
|
+
--st-color-info-subtle: #f0f9ff;
|
|
55
|
+
--st-color-info-foreground: #ffffff;
|
|
56
|
+
|
|
57
|
+
/* ─── Colors: Surfaces & Borders ─── */
|
|
58
|
+
--st-color-background: #ffffff;
|
|
59
|
+
--st-color-foreground: #0a0a0a;
|
|
60
|
+
--st-color-surface: #ffffff;
|
|
61
|
+
--st-color-surface-raised: #fafafa;
|
|
62
|
+
--st-color-border: #e5e5e5;
|
|
63
|
+
--st-color-border-strong: #d4d4d4;
|
|
64
|
+
--st-color-muted: #737373;
|
|
65
|
+
--st-color-overlay: rgb(0 0 0 / 0.5);
|
|
66
|
+
|
|
67
|
+
/* ─── Typography ─── */
|
|
68
|
+
--st-font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
69
|
+
--st-font-family-mono: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, monospace;
|
|
70
|
+
|
|
71
|
+
--st-font-size-xs: 0.75rem;
|
|
72
|
+
--st-font-size-sm: 0.875rem;
|
|
73
|
+
--st-font-size-md: 1rem;
|
|
74
|
+
--st-font-size-lg: 1.125rem;
|
|
75
|
+
--st-font-size-xl: 1.25rem;
|
|
76
|
+
--st-font-size-2xl: 1.5rem;
|
|
77
|
+
--st-font-size-3xl: 1.875rem;
|
|
78
|
+
--st-font-size-4xl: 2.25rem;
|
|
79
|
+
|
|
80
|
+
--st-font-weight-normal: 400;
|
|
81
|
+
--st-font-weight-medium: 500;
|
|
82
|
+
--st-font-weight-semibold: 600;
|
|
83
|
+
--st-font-weight-bold: 700;
|
|
84
|
+
|
|
85
|
+
--st-line-height-tight: 1.25;
|
|
86
|
+
--st-line-height-normal: 1.5;
|
|
87
|
+
--st-line-height-relaxed: 1.75;
|
|
88
|
+
|
|
89
|
+
/* ─── Spacing (4px increments) ─── */
|
|
90
|
+
--st-space-0: 0;
|
|
91
|
+
--st-space-1: 0.25rem;
|
|
92
|
+
--st-space-2: 0.5rem;
|
|
93
|
+
--st-space-3: 0.75rem;
|
|
94
|
+
--st-space-4: 1rem;
|
|
95
|
+
--st-space-5: 1.25rem;
|
|
96
|
+
--st-space-6: 1.5rem;
|
|
97
|
+
--st-space-7: 1.75rem;
|
|
98
|
+
--st-space-8: 2rem;
|
|
99
|
+
--st-space-9: 2.25rem;
|
|
100
|
+
--st-space-10: 2.5rem;
|
|
101
|
+
--st-space-11: 2.75rem;
|
|
102
|
+
--st-space-12: 3rem;
|
|
103
|
+
--st-space-13: 3.25rem;
|
|
104
|
+
--st-space-14: 3.5rem;
|
|
105
|
+
--st-space-15: 3.75rem;
|
|
106
|
+
--st-space-16: 4rem;
|
|
107
|
+
|
|
108
|
+
/* ─── Border Radius ─── */
|
|
109
|
+
--st-radius-none: 0;
|
|
110
|
+
--st-radius-sm: 0.25rem;
|
|
111
|
+
--st-radius-md: 0.375rem;
|
|
112
|
+
--st-radius-lg: 0.5rem;
|
|
113
|
+
--st-radius-xl: 0.75rem;
|
|
114
|
+
--st-radius-2xl: 1rem;
|
|
115
|
+
--st-radius-full: 9999px;
|
|
116
|
+
|
|
117
|
+
/* ─── Shadows ─── */
|
|
118
|
+
--st-shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
|
|
119
|
+
--st-shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
|
|
120
|
+
--st-shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
|
121
|
+
--st-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
|
|
122
|
+
--st-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
|
|
123
|
+
|
|
124
|
+
/* ─── Transitions ─── */
|
|
125
|
+
--st-transition-fast: 100ms ease;
|
|
126
|
+
--st-transition-base: 200ms ease;
|
|
127
|
+
--st-transition-slow: 300ms ease;
|
|
128
|
+
|
|
129
|
+
/* ─── Chart Colors ─── */
|
|
130
|
+
--st-color-chart-1: #22c55e;
|
|
131
|
+
--st-color-chart-1-subtle: #dcfce7;
|
|
132
|
+
--st-color-chart-1-muted: #86efac;
|
|
133
|
+
--st-color-chart-1-faded: #bbf7d0;
|
|
134
|
+
--st-color-chart-2: #3b82f6;
|
|
135
|
+
--st-color-chart-2-subtle: #dbeafe;
|
|
136
|
+
--st-color-chart-2-muted: #93c5fd;
|
|
137
|
+
--st-color-chart-2-faded: #bfdbfe;
|
|
138
|
+
--st-color-chart-3: #a78bfa;
|
|
139
|
+
--st-color-chart-3-subtle: #ede9fe;
|
|
140
|
+
--st-color-chart-4: #737373;
|
|
141
|
+
--st-color-chart-4-subtle: #f5f5f5;
|
|
142
|
+
--st-color-chart-grid: #f0f0f0;
|
|
143
|
+
--st-color-chart-axis: var(--st-color-neutral-400);
|
|
144
|
+
--st-color-chart-tooltip-bg: var(--st-color-neutral-900);
|
|
145
|
+
--st-color-chart-tooltip-fg: #ffffff;
|
|
146
|
+
|
|
147
|
+
/* ─── Z-index ─── */
|
|
148
|
+
--st-z-dropdown: 1000;
|
|
149
|
+
--st-z-sticky: 1100;
|
|
150
|
+
--st-z-overlay: 1200;
|
|
151
|
+
--st-z-modal: 1300;
|
|
152
|
+
--st-z-toast: 1400;
|
|
153
|
+
--st-z-tooltip: 1500;
|
|
154
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { forwardRef, useState } from 'react';
|
|
2
|
+
import { cn } from '../../utils/cn';
|
|
3
|
+
import { AccordionContext } from './AccordionContext';
|
|
4
|
+
import type { AccordionProps } from './Accordion.types';
|
|
5
|
+
import styles from './Accordion.module.css';
|
|
6
|
+
|
|
7
|
+
function normalizeValue(val?: string | string[]): string[] {
|
|
8
|
+
if (!val) return [];
|
|
9
|
+
return Array.isArray(val) ? val : [val];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Accordion = forwardRef<HTMLDivElement, AccordionProps>(
|
|
13
|
+
(
|
|
14
|
+
{
|
|
15
|
+
type = 'multiple',
|
|
16
|
+
variant = 'collapsible',
|
|
17
|
+
defaultValue,
|
|
18
|
+
value,
|
|
19
|
+
onValueChange,
|
|
20
|
+
className,
|
|
21
|
+
children,
|
|
22
|
+
...rest
|
|
23
|
+
},
|
|
24
|
+
ref
|
|
25
|
+
) => {
|
|
26
|
+
const [internalOpen, setInternalOpen] = useState(() =>
|
|
27
|
+
normalizeValue(defaultValue)
|
|
28
|
+
);
|
|
29
|
+
const openItems =
|
|
30
|
+
value !== undefined ? normalizeValue(value) : internalOpen;
|
|
31
|
+
|
|
32
|
+
const toggle = (itemValue: string) => {
|
|
33
|
+
let next: string[];
|
|
34
|
+
if (openItems.includes(itemValue)) {
|
|
35
|
+
next = openItems.filter((v) => v !== itemValue);
|
|
36
|
+
} else {
|
|
37
|
+
next =
|
|
38
|
+
type === 'single' ? [itemValue] : [...openItems, itemValue];
|
|
39
|
+
}
|
|
40
|
+
if (value === undefined) setInternalOpen(next);
|
|
41
|
+
onValueChange?.(next);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<AccordionContext.Provider value={{ variant, openItems, toggle }}>
|
|
46
|
+
<div ref={ref} className={cn(styles.root, className)} {...rest}>
|
|
47
|
+
{children}
|
|
48
|
+
</div>
|
|
49
|
+
</AccordionContext.Provider>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
Accordion.displayName = 'Accordion';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
|
|
3
|
+
export type AccordionType = 'single' | 'multiple';
|
|
4
|
+
export type AccordionVariant = 'collapsible' | 'accordion' | 'showmore';
|
|
5
|
+
|
|
6
|
+
export interface AccordionProps extends HTMLAttributes<HTMLDivElement> {
|
|
7
|
+
/** `single` allows only one open item; `multiple` allows many */
|
|
8
|
+
type?: AccordionType;
|
|
9
|
+
/** Visual variant: trigger icon and layout */
|
|
10
|
+
variant?: AccordionVariant;
|
|
11
|
+
/** Initial open items (uncontrolled) */
|
|
12
|
+
defaultValue?: string | string[];
|
|
13
|
+
/** Currently open items (controlled) */
|
|
14
|
+
value?: string | string[];
|
|
15
|
+
/** Callback when open items change */
|
|
16
|
+
onValueChange?: (value: string[]) => void;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { createContext, useContext } from 'react';
|
|
2
|
+
import type { AccordionVariant } from './Accordion.types';
|
|
3
|
+
|
|
4
|
+
export interface AccordionContextValue {
|
|
5
|
+
variant: AccordionVariant;
|
|
6
|
+
openItems: string[];
|
|
7
|
+
toggle: (value: string) => void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const AccordionContext = createContext<AccordionContextValue | null>(null);
|
|
11
|
+
|
|
12
|
+
export function useAccordion(): AccordionContextValue {
|
|
13
|
+
const ctx = useContext(AccordionContext);
|
|
14
|
+
if (!ctx) {
|
|
15
|
+
throw new Error('AccordionItem must be used within an Accordion');
|
|
16
|
+
}
|
|
17
|
+
return ctx;
|
|
18
|
+
}
|