gooee 0.52.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -3
- package/package.json +6 -2
- package/scripts/add.js +181 -42
- package/src/base.css +3 -1
- package/src/components/Accordion/Accordion.module.css +7 -5
- package/src/components/Accordion/Accordion.tsx +13 -11
- package/src/components/Accordion/Accordion.vue +16 -15
- package/src/components/Accordion/AccordionItem.vue +8 -7
- package/src/components/Alert/Alert.module.css +9 -7
- package/src/components/Alert/Alert.tsx +25 -16
- package/src/components/Alert/Alert.vue +31 -27
- package/src/components/AlertDialog/AlertDialog.module.css +2 -0
- package/src/components/AlertDialog/AlertDialog.tsx +8 -7
- package/src/components/AlertDialog/AlertDialog.vue +25 -23
- package/src/components/AnimatedNumber/AnimatedNumber.module.css +5 -3
- package/src/components/AnimatedNumber/AnimatedNumber.tsx +6 -6
- package/src/components/AnimatedNumber/AnimatedNumber.vue +5 -5
- package/src/components/AspectRatio/AspectRatio.module.css +2 -0
- package/src/components/AspectRatio/AspectRatio.tsx +3 -3
- package/src/components/AspectRatio/AspectRatio.vue +5 -8
- package/src/components/Avatar/Avatar.module.css +10 -8
- package/src/components/Avatar/Avatar.tsx +4 -3
- package/src/components/Avatar/Avatar.vue +17 -19
- package/src/components/Avatar/index.ts +0 -2
- package/src/components/AvatarGroup/AvatarGroup.module.css +11 -9
- package/src/components/AvatarGroup/AvatarGroup.tsx +4 -4
- package/src/components/AvatarGroup/AvatarGroup.vue +13 -16
- package/src/components/Badge/Badge.module.css +6 -4
- package/src/components/Badge/Badge.tsx +3 -3
- package/src/components/Badge/Badge.vue +15 -14
- package/src/components/Breadcrumb/Breadcrumb.module.css +5 -3
- package/src/components/Breadcrumb/Breadcrumb.tsx +20 -12
- package/src/components/Breadcrumb/Breadcrumb.vue +33 -25
- package/src/components/Button/Button.module.css +16 -14
- package/src/components/Button/Button.tsx +6 -4
- package/src/components/Button/Button.vue +42 -33
- package/src/components/ButtonGroup/ButtonGroup.module.css +2 -0
- package/src/components/ButtonGroup/ButtonGroup.tsx +1 -1
- package/src/components/ButtonGroup/ButtonGroup.vue +9 -12
- package/src/components/Card/Card.module.css +6 -4
- package/src/components/Card/Card.tsx +6 -6
- package/src/components/Card/Card.vue +18 -21
- package/src/components/Center/Center.module.css +2 -0
- package/src/components/Center/Center.tsx +1 -1
- package/src/components/Center/Center.vue +18 -15
- package/src/components/Checkbox/Checkbox.module.css +10 -8
- package/src/components/Checkbox/Checkbox.tsx +15 -9
- package/src/components/Checkbox/Checkbox.vue +29 -31
- package/src/components/CheckboxGroup/CheckboxGroup.module.css +3 -1
- package/src/components/CheckboxGroup/CheckboxGroup.tsx +4 -4
- package/src/components/CheckboxGroup/CheckboxGroup.vue +33 -30
- package/src/components/Cluster/Cluster.module.css +2 -0
- package/src/components/Cluster/Cluster.tsx +1 -1
- package/src/components/Cluster/Cluster.vue +21 -17
- package/src/components/CodeBlock/CodeBlock.module.css +12 -10
- package/src/components/CodeBlock/CodeBlock.tsx +18 -10
- package/src/components/CodeBlock/CodeBlock.vue +30 -27
- package/src/components/CodeBlock/highlight.ts +1 -1
- package/src/components/Collapsible/Collapsible.module.css +7 -5
- package/src/components/Collapsible/Collapsible.tsx +7 -6
- package/src/components/Collapsible/Collapsible.vue +30 -26
- package/src/components/Container/Container.module.css +2 -0
- package/src/components/Container/Container.tsx +1 -1
- package/src/components/Container/Container.vue +13 -12
- package/src/components/CopyButton/CopyButton.module.css +20 -18
- package/src/components/CopyButton/CopyButton.tsx +21 -14
- package/src/components/CopyButton/CopyButton.vue +41 -31
- package/src/components/Dial/Dial.module.css +26 -11
- package/src/components/Dial/Dial.tsx +18 -18
- package/src/components/Dial/Dial.vue +57 -60
- package/src/components/Dialog/Dialog.module.css +4 -2
- package/src/components/Dialog/Dialog.tsx +22 -13
- package/src/components/Dialog/Dialog.vue +34 -30
- package/src/components/Divider/Divider.module.css +5 -3
- package/src/components/Divider/Divider.tsx +6 -4
- package/src/components/Divider/Divider.vue +13 -16
- package/src/components/DropdownMenu/DropdownMenu.module.css +8 -6
- package/src/components/DropdownMenu/DropdownMenu.tsx +12 -9
- package/src/components/DropdownMenu/DropdownMenu.vue +25 -28
- package/src/components/EmptyState/EmptyState.module.css +6 -4
- package/src/components/EmptyState/EmptyState.tsx +6 -6
- package/src/components/EmptyState/EmptyState.vue +14 -17
- package/src/components/Fab/Fab.module.css +19 -17
- package/src/components/Fab/Fab.tsx +11 -9
- package/src/components/Fab/Fab.vue +29 -26
- package/src/components/Fieldset/Fieldset.module.css +2 -0
- package/src/components/Fieldset/Fieldset.tsx +4 -3
- package/src/components/Fieldset/Fieldset.vue +4 -4
- package/src/components/FormField/FormField.module.css +5 -3
- package/src/components/FormField/FormField.tsx +7 -7
- package/src/components/FormField/FormField.vue +4 -4
- package/src/components/Grid/Grid.module.css +2 -0
- package/src/components/Grid/Grid.tsx +1 -1
- package/src/components/Grid/Grid.vue +25 -22
- package/src/components/HoldToConfirm/HoldToConfirm.module.css +13 -11
- package/src/components/HoldToConfirm/HoldToConfirm.tsx +11 -9
- package/src/components/HoldToConfirm/HoldToConfirm.vue +37 -32
- package/src/components/IconButton/IconButton.module.css +7 -5
- package/src/components/IconButton/IconButton.tsx +2 -1
- package/src/components/IconButton/IconButton.vue +15 -14
- package/src/components/Input/Input.module.css +12 -10
- package/src/components/Input/Input.tsx +9 -7
- package/src/components/Input/Input.vue +45 -35
- package/src/components/InputGroup/InputGroup.module.css +8 -6
- package/src/components/InputGroup/InputGroup.tsx +5 -4
- package/src/components/InputGroup/InputGroup.vue +41 -36
- package/src/components/Kbd/Kbd.module.css +9 -7
- package/src/components/Kbd/Kbd.tsx +1 -1
- package/src/components/Kbd/Kbd.vue +1 -1
- package/src/components/Link/Link.module.css +4 -2
- package/src/components/Link/Link.tsx +4 -3
- package/src/components/Link/Link.vue +13 -16
- package/src/components/LivePill/LivePill.module.css +39 -37
- package/src/components/LivePill/LivePill.tsx +11 -10
- package/src/components/LivePill/LivePill.vue +38 -40
- package/src/components/Meter/Meter.module.css +5 -3
- package/src/components/Meter/Meter.tsx +9 -8
- package/src/components/Meter/Meter.vue +52 -43
- package/src/components/MorphButton/MorphButton.module.css +11 -9
- package/src/components/MorphButton/MorphButton.tsx +20 -10
- package/src/components/MorphButton/MorphButton.vue +29 -25
- package/src/components/NumberInput/NumberInput.module.css +7 -5
- package/src/components/NumberInput/NumberInput.tsx +11 -8
- package/src/components/NumberInput/NumberInput.vue +69 -57
- package/src/components/Pagination/Pagination.module.css +147 -5
- package/src/components/Pagination/Pagination.tsx +216 -41
- package/src/components/Pagination/Pagination.vue +201 -36
- package/src/components/Pagination/labels.ts +38 -0
- package/src/components/PasswordInput/PasswordInput.module.css +10 -8
- package/src/components/PasswordInput/PasswordInput.tsx +15 -7
- package/src/components/PasswordInput/PasswordInput.vue +20 -16
- package/src/components/PasswordInput/index.ts +1 -1
- package/src/components/PickerWheel/DateWheel.vue +20 -12
- package/src/components/PickerWheel/PickerWheel.module.css +15 -6
- package/src/components/PickerWheel/PickerWheel.tsx +70 -44
- package/src/components/PickerWheel/PickerWheel.vue +39 -38
- package/src/components/PickerWheel/TimeWheel.vue +23 -21
- package/src/components/PickerWheel/WheelColumn.vue +7 -5
- package/src/components/Popover/Popover.module.css +5 -3
- package/src/components/Popover/Popover.tsx +17 -8
- package/src/components/Popover/Popover.vue +26 -25
- package/src/components/ProgressBar/ProgressBar.module.css +4 -2
- package/src/components/ProgressBar/ProgressBar.tsx +6 -5
- package/src/components/ProgressBar/ProgressBar.vue +28 -25
- package/src/components/Prose/Prose.module.css +5 -3
- package/src/components/Prose/Prose.tsx +1 -1
- package/src/components/Prose/Prose.vue +5 -8
- package/src/components/Radio/Radio.module.css +10 -8
- package/src/components/Radio/Radio.tsx +10 -8
- package/src/components/Radio/Radio.vue +8 -8
- package/src/components/Radio/RadioGroup.vue +33 -35
- package/src/components/Radio/radioContext.ts +12 -0
- package/src/components/Retime/Retime.vue +25 -22
- package/src/components/RulerScrubber/RulerScrubber.module.css +11 -2
- package/src/components/RulerScrubber/RulerScrubber.tsx +19 -18
- package/src/components/RulerScrubber/RulerScrubber.vue +50 -54
- package/src/components/ScrollArea/ScrollArea.module.css +17 -15
- package/src/components/ScrollArea/ScrollArea.tsx +5 -4
- package/src/components/ScrollArea/ScrollArea.vue +15 -17
- package/src/components/SearchInput/SearchInput.module.css +6 -4
- package/src/components/SearchInput/SearchInput.tsx +22 -10
- package/src/components/SearchInput/SearchInput.vue +20 -17
- package/src/components/SearchInput/index.ts +1 -1
- package/src/components/SegmentedControl/SegmentedControl.module.css +7 -5
- package/src/components/SegmentedControl/SegmentedControl.tsx +9 -5
- package/src/components/SegmentedControl/SegmentedControl.vue +25 -29
- package/src/components/Select/Select.module.css +19 -17
- package/src/components/Select/Select.tsx +31 -18
- package/src/components/Select/Select.vue +63 -58
- package/src/components/Sheet/Sheet.module.css +6 -4
- package/src/components/Sheet/Sheet.tsx +39 -29
- package/src/components/Sheet/Sheet.vue +46 -40
- package/src/components/Skeleton/Skeleton.module.css +4 -2
- package/src/components/Skeleton/Skeleton.tsx +3 -2
- package/src/components/Skeleton/Skeleton.vue +16 -18
- package/src/components/Slider/Slider.module.css +14 -12
- package/src/components/Slider/Slider.tsx +27 -11
- package/src/components/Slider/Slider.vue +47 -37
- package/src/components/Spinner/Spinner.module.css +2 -0
- package/src/components/Spinner/Spinner.tsx +3 -3
- package/src/components/Spinner/Spinner.vue +9 -12
- package/src/components/Split/Split.module.css +2 -0
- package/src/components/Split/Split.tsx +3 -3
- package/src/components/Split/Split.vue +19 -17
- package/src/components/SplitFlap/SplitFlap.module.css +9 -7
- package/src/components/SplitFlap/SplitFlap.tsx +2 -2
- package/src/components/SplitFlap/SplitFlap.vue +24 -21
- package/src/components/Stack/Stack.module.css +2 -0
- package/src/components/Stack/Stack.tsx +1 -1
- package/src/components/Stack/Stack.vue +13 -12
- package/src/components/SwipeDeck/SwipeDeck.module.css +13 -11
- package/src/components/SwipeDeck/SwipeDeck.tsx +23 -28
- package/src/components/SwipeDeck/SwipeDeck.vue +32 -38
- package/src/components/Switch/Switch.module.css +10 -8
- package/src/components/Switch/Switch.tsx +6 -5
- package/src/components/Switch/Switch.vue +22 -24
- package/src/components/Table/Table.module.css +24 -22
- package/src/components/Table/Table.tsx +27 -30
- package/src/components/Table/Table.vue +93 -79
- package/src/components/TableOfContents/TableOfContents.module.css +9 -7
- package/src/components/TableOfContents/TableOfContents.tsx +8 -8
- package/src/components/TableOfContents/TableOfContents.vue +20 -23
- package/src/components/Tabs/Tab.vue +3 -0
- package/src/components/Tabs/TabList.vue +2 -2
- package/src/components/Tabs/TabPanel.vue +2 -0
- package/src/components/Tabs/Tabs.module.css +4 -2
- package/src/components/Tabs/Tabs.tsx +10 -5
- package/src/components/Tabs/Tabs.vue +1 -1
- package/src/components/Tag/Tag.module.css +12 -10
- package/src/components/Tag/Tag.tsx +13 -15
- package/src/components/Tag/Tag.vue +12 -14
- package/src/components/Textarea/Textarea.module.css +8 -6
- package/src/components/Textarea/Textarea.tsx +4 -3
- package/src/components/Textarea/Textarea.vue +32 -34
- package/src/components/ThemeToggle/ThemeToggle.module.css +2 -0
- package/src/components/ThemeToggle/ThemeToggle.tsx +7 -7
- package/src/components/ThemeToggle/ThemeToggle.vue +24 -22
- package/src/components/Toast/Toast.module.css +17 -15
- package/src/components/Toast/Toast.tsx +51 -34
- package/src/components/Toast/Toast.vue +35 -24
- package/src/components/Toast/ToastItem.vue +17 -16
- package/src/components/Toggle/Toggle.module.css +11 -9
- package/src/components/Toggle/Toggle.tsx +3 -2
- package/src/components/Toggle/Toggle.vue +13 -15
- package/src/components/Tooltip/Tooltip.module.css +5 -3
- package/src/components/Tooltip/Tooltip.tsx +1 -0
- package/src/components/Tooltip/Tooltip.vue +13 -18
- package/src/components/VisuallyHidden/VisuallyHidden.module.css +2 -0
- package/src/components/VisuallyHidden/VisuallyHidden.tsx +1 -1
- package/src/components/VisuallyHidden/VisuallyHidden.vue +5 -8
- package/src/{internal → icons}/icons.module.css +4 -2
- package/src/{internal → icons}/icons.tsx +15 -16
- package/src/internal/FieldMessage.module.css +5 -3
- package/src/internal/FieldMessage.tsx +2 -2
- package/src/internal/FieldMessage.vue +2 -2
- package/src/internal/Roll.module.css +5 -3
- package/src/internal/feel.ts +12 -10
- package/src/internal/fling.ts +3 -3
- package/src/internal/liquid.ts +12 -10
- package/src/internal/liquidMatter.ts +1 -1
- package/src/internal/liquidMore.ts +7 -7
- package/src/internal/motion/checkbox.ts +4 -4
- package/src/internal/motion/fling.ts +19 -9
- package/src/internal/motion/holdToConfirm.ts +3 -3
- package/src/internal/motion/index.ts +8 -6
- package/src/internal/motion/liquid.ts +16 -4
- package/src/internal/motion/liquidMatter.ts +8 -6
- package/src/internal/motion/liquidMore.ts +44 -25
- package/src/internal/motion/livePill.ts +1 -1
- package/src/internal/motion/numberInput.ts +2 -2
- package/src/internal/motion/pickerWheel.ts +7 -4
- package/src/internal/motion/ruler.ts +1 -1
- package/src/internal/motion/scrollArea.ts +3 -3
- package/src/internal/motion/scrollFrame.ts +9 -7
- package/src/internal/motion/scrubber.ts +39 -20
- package/src/internal/motion/slider.ts +38 -4
- package/src/internal/motion/softPress.ts +10 -9
- package/src/internal/motion/splitFlap.ts +4 -4
- package/src/internal/motion/swipeDeck.ts +38 -7
- package/src/internal/motion/table.ts +3 -6
- package/src/internal/motion/themeIcon.ts +1 -1
- package/src/internal/motion/themeReveal.ts +1 -1
- package/src/internal/motion/toast.ts +3 -3
- package/src/internal/motion.ts +7 -8
- package/src/internal/scrollFrame.ts +3 -3
- package/src/internal/useScrub.ts +1 -15
- package/src/internal/vue/useScrub.ts +2 -6
- package/src/tokens.css +81 -421
- package/src/{internal/vueIcons.ts → icons/vue.ts} +5 -5
package/README.md
CHANGED
|
@@ -34,7 +34,7 @@ import { Button } from './ui/components/Button'
|
|
|
34
34
|
<Button onClick={save}>Save</Button>
|
|
35
35
|
```
|
|
36
36
|
|
|
37
|
-
Using Vue?
|
|
37
|
+
Using Vue? Set it up with `npx gooee@latest init --vue`. `gooee.json` then remembers Vue, so `add`, `diff` and `update` copy `.vue` files. Import the `.vue` file:
|
|
38
38
|
|
|
39
39
|
```vue
|
|
40
40
|
<script setup lang="ts">
|
|
@@ -66,14 +66,21 @@ It writes the same files as `npx gooee add button`, into `src/ui`, with `tokens.
|
|
|
66
66
|
| `diff <name>...` | Show what changed between your copy and the latest version |
|
|
67
67
|
| `update <name>...` | Show the changes, then replace your copy after you say yes |
|
|
68
68
|
|
|
69
|
+
The command always comes first: `npx gooee add button`, not `npx gooee button`.
|
|
70
|
+
|
|
69
71
|
| Option | What it does |
|
|
70
72
|
| --- | --- |
|
|
71
|
-
| `--vue` |
|
|
73
|
+
| `--vue` | Copy the Vue 3.5 version of each part. With `init`, `gooee.json` remembers it for every later command |
|
|
74
|
+
| `--react` | Copy the React version, even when `gooee.json` says Vue. React is the default |
|
|
72
75
|
| `--to <folder>` | Where the files go. Default: the folder in `gooee.json`, else `src/ui` |
|
|
73
76
|
| `--dry-run` | Print what would happen, write nothing |
|
|
74
77
|
| `--overwrite` | `add`: replace files that are already there. Without it, they are skipped and listed |
|
|
75
78
|
| `--with-base` | `add`: also copy `base.css` (`init` always does) |
|
|
76
|
-
| `--yes` | `update`: replace without asking |
|
|
79
|
+
| `--yes` | `update`: replace without asking, and also update the other parts that use a changed shared file |
|
|
80
|
+
|
|
81
|
+
`gooee.json` holds `framework` (`react` or `vue`), `to` (the folder) and `files`, a short hash of each file the CLI wrote. When a shared file in `internal/` or `icons/` changes, `diff` and `update` name the other installed parts that use it, and `update` offers to update them too. When the latest version of a part no longer has a file, `update` deletes your copy only if it is still exactly as the CLI wrote it. Otherwise it lists the file and keeps it.
|
|
82
|
+
|
|
83
|
+
A part that draws icons brings `icons/` with it (`icons.tsx`, or `vue.ts` for Vue). That folder is public: import `CheckIcon` and the rest from it in your own code, and names and props stay the same within a major version. `internal/` is not public and may change in any version.
|
|
77
84
|
|
|
78
85
|
Every copied file starts with one line naming Gooee UI and the MIT licence, so the licence notice travels with the code. `diff` and `update` ignore that line.
|
|
79
86
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gooee",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "React and Vue components in black, white and grey with one blue accent. Copy them into your app with npx gooee add <name>.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://gooee.dev",
|
|
@@ -13,11 +13,15 @@
|
|
|
13
13
|
"gooee": "scripts/add.js"
|
|
14
14
|
},
|
|
15
15
|
"engines": {
|
|
16
|
-
"node": ">=
|
|
16
|
+
"node": ">=20"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
"./package.json": "./package.json"
|
|
17
20
|
},
|
|
18
21
|
"files": [
|
|
19
22
|
"scripts/add.js",
|
|
20
23
|
"src/components",
|
|
24
|
+
"src/icons",
|
|
21
25
|
"src/internal",
|
|
22
26
|
"src/tokens.css",
|
|
23
27
|
"src/base.css",
|
package/scripts/add.js
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
// templates and themes (with everything they import) into it, then shows and takes later changes.
|
|
4
4
|
// Runs as `npx gooee <command>` from the npm package, or `npm run add -- <command>` in this repo.
|
|
5
5
|
// Plain JavaScript on purpose: the project has no Node type package.
|
|
6
|
-
import {
|
|
6
|
+
import { createHash } from 'node:crypto'
|
|
7
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, writeFileSync } from 'node:fs'
|
|
7
8
|
import { basename, dirname, join, relative, resolve, sep } from 'node:path'
|
|
8
9
|
import { createInterface } from 'node:readline/promises'
|
|
9
10
|
import { fileURLToPath } from 'node:url'
|
|
@@ -11,6 +12,11 @@ import { fileURLToPath } from 'node:url'
|
|
|
11
12
|
const ROOT = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
12
13
|
const SRC = join(ROOT, 'src')
|
|
13
14
|
const INTERNAL = join(SRC, 'internal')
|
|
15
|
+
// Shared folders: what a part imports from them comes along, into the same folder name in the app.
|
|
16
|
+
// src/icons is public (names and props stay within a major version); src/internal may change.
|
|
17
|
+
const ICONS = join(SRC, 'icons')
|
|
18
|
+
const SHARED = [INTERNAL, ICONS]
|
|
19
|
+
const inShared = (file) => SHARED.some((dir) => file.startsWith(dir + sep))
|
|
14
20
|
const EXCLUDED = /(\.(test|spec|stories|demo)\.[jt]sx?$)|(^|\/)(docs|demos|__tests__)\//
|
|
15
21
|
const DEFAULT_TO = 'src/ui'
|
|
16
22
|
const CONFIG = 'gooee.json'
|
|
@@ -28,8 +34,9 @@ Options:
|
|
|
28
34
|
--to <folder> Where files go. Defaults to the folder in ${CONFIG}, else ${DEFAULT_TO}
|
|
29
35
|
--overwrite add: replace files that are already there
|
|
30
36
|
--with-base add: also copy base.css (init always does)
|
|
31
|
-
--yes update: replace without asking
|
|
32
|
-
--vue
|
|
37
|
+
--yes update: replace without asking, and update the parts that share a changed file
|
|
38
|
+
--vue Vue parts (.vue). init saves it in ${CONFIG}, so later commands use it too
|
|
39
|
+
--react React parts (.tsx), the default. Wins over the framework in ${CONFIG}
|
|
33
40
|
--dry-run Show what would happen, write nothing
|
|
34
41
|
|
|
35
42
|
In this repo, run: npm run add -- <command> ...`
|
|
@@ -60,7 +67,7 @@ function fail(message, usage = true) {
|
|
|
60
67
|
}
|
|
61
68
|
|
|
62
69
|
function parseArgs(argv) {
|
|
63
|
-
const opts = { command: '
|
|
70
|
+
const opts = { command: '', names: [], to: '', kind: '', overwrite: false, dryRun: false, withBase: false, yes: false, framework: '' }
|
|
64
71
|
const rest = []
|
|
65
72
|
for (let i = 0; i < argv.length; i++) {
|
|
66
73
|
const arg = argv[i]
|
|
@@ -79,13 +86,22 @@ function parseArgs(argv) {
|
|
|
79
86
|
else if (arg === '--overwrite') opts.overwrite = true
|
|
80
87
|
else if (arg === '--dry-run') opts.dryRun = true
|
|
81
88
|
else if (arg === '--with-base') opts.withBase = true
|
|
82
|
-
else if (arg === '--vue'
|
|
89
|
+
else if (arg === '--vue' || arg === '--react') {
|
|
90
|
+
if (opts.framework && opts.framework !== arg.slice(2)) fail('Use --vue or --react, not both.')
|
|
91
|
+
opts.framework = arg.slice(2)
|
|
92
|
+
}
|
|
83
93
|
else if (arg === '--yes' || arg === '-y') opts.yes = true
|
|
84
94
|
else if (arg.startsWith('-')) fail(`Unknown option ${arg}.`)
|
|
85
95
|
else rest.push(arg)
|
|
86
96
|
}
|
|
87
|
-
// The command comes first,
|
|
88
|
-
if (
|
|
97
|
+
// The command always comes first, so a new command can never clash with a part's name.
|
|
98
|
+
if (!rest.length) fail('Name a command.')
|
|
99
|
+
const first = rest.shift()
|
|
100
|
+
if (!COMMANDS.includes(first)) {
|
|
101
|
+
const near = COMMANDS.find((c) => distance(first.toLowerCase(), c) <= 1)
|
|
102
|
+
fail(`"${first}" is not a command. ${near ? `Did you mean npx gooee ${near}?` : `To add it, run: npx gooee add ${[first, ...rest].join(' ')}`}`, false)
|
|
103
|
+
}
|
|
104
|
+
opts.command = first
|
|
89
105
|
opts.names = rest
|
|
90
106
|
if (['add', 'diff', 'update'].includes(opts.command) && !opts.names.length) {
|
|
91
107
|
fail(`Name at least one component, block, template or theme, for example: npx gooee ${opts.command} button`)
|
|
@@ -192,10 +208,13 @@ function listFiles(dir) {
|
|
|
192
208
|
})
|
|
193
209
|
}
|
|
194
210
|
|
|
195
|
-
// React or Vue
|
|
211
|
+
// React or Vue: --react or --vue, else the framework in gooee.json, else React.
|
|
212
|
+
// A part folder holds both: Switch.tsx and Switch.vue share Switch.module.css.
|
|
196
213
|
let framework = 'react'
|
|
197
214
|
const forFramework = (file) => (file.endsWith('.vue') ? framework === 'vue' : framework === 'react' || file.endsWith('.css'))
|
|
198
215
|
|
|
216
|
+
const hasVue = (item) => kindOf(item.kind).single || listFiles(join(kindOf(item.kind).dir, item.name)).some((f) => f.endsWith('.vue'))
|
|
217
|
+
|
|
199
218
|
const filesOf = (item) => {
|
|
200
219
|
const k = kindOf(item.kind)
|
|
201
220
|
if (k.single) return [join(k.dir, `${item.name}.css`)]
|
|
@@ -234,15 +253,15 @@ function resolveImport(from, spec) {
|
|
|
234
253
|
return hit
|
|
235
254
|
}
|
|
236
255
|
|
|
237
|
-
// Which component, block, template or theme a file belongs to, or null for src/internal.
|
|
256
|
+
// Which component, block, template or theme a file belongs to, or null for src/internal and src/icons.
|
|
238
257
|
function ownerOf(file) {
|
|
239
|
-
if (file
|
|
258
|
+
if (inShared(file)) return null
|
|
240
259
|
for (const k of KINDS) {
|
|
241
260
|
if (!file.startsWith(k.dir + sep)) continue
|
|
242
261
|
if (k.single) return { kind: k.key, name: basename(file, '.css') }
|
|
243
262
|
return { kind: k.key, name: relative(k.dir, file).split(sep)[0] }
|
|
244
263
|
}
|
|
245
|
-
fail(`${rel(file)} is outside src/components, src/blocks, src/templates, src/themes and src/
|
|
264
|
+
fail(`${rel(file)} is outside src/components, src/blocks, src/templates, src/themes, src/internal and src/icons, so it cannot be copied.`, false)
|
|
246
265
|
}
|
|
247
266
|
|
|
248
267
|
function plan(items) {
|
|
@@ -282,7 +301,7 @@ function plan(items) {
|
|
|
282
301
|
for (let i = 0; i < seenInternal.length; i++) {
|
|
283
302
|
for (const spec of importsOf(seenInternal[i])) {
|
|
284
303
|
const target = resolveImport(seenInternal[i], spec)
|
|
285
|
-
if (ownerOf(target) !== null) fail(`${rel(seenInternal[i])} imports from outside src/internal, which
|
|
304
|
+
if (ownerOf(target) !== null) fail(`${rel(seenInternal[i])} imports from outside src/internal and src/icons, which shared files must not do.`, false)
|
|
286
305
|
visitInternal(target)
|
|
287
306
|
}
|
|
288
307
|
}
|
|
@@ -311,6 +330,21 @@ function readConfig() {
|
|
|
311
330
|
}
|
|
312
331
|
}
|
|
313
332
|
|
|
333
|
+
// gooee.json keeps a short hash of each file the CLI wrote, so update can tell whether a file the
|
|
334
|
+
// latest version dropped is still exactly as written, and only then delete it.
|
|
335
|
+
const hash = (text) => createHash('sha256').update(text).digest('hex').slice(0, 16)
|
|
336
|
+
const configKey = (file) => relative(CWD, file).split(sep).join('/')
|
|
337
|
+
|
|
338
|
+
function saveHashes(written, dropped = []) {
|
|
339
|
+
const config = readConfig()
|
|
340
|
+
if (!config) return
|
|
341
|
+
const files = { ...config.files }
|
|
342
|
+
for (const c of written) files[configKey(c.to)] = hash(readFileSync(c.from, 'utf8'))
|
|
343
|
+
for (const f of dropped) delete files[configKey(f)]
|
|
344
|
+
config.files = Object.fromEntries(Object.entries(files).sort(([a], [b]) => a.localeCompare(b)))
|
|
345
|
+
writeFileSync(join(CWD, CONFIG), `${JSON.stringify(config, null, 2)}\n`)
|
|
346
|
+
}
|
|
347
|
+
|
|
314
348
|
function targetFolder(opts) {
|
|
315
349
|
const folder = opts.to || readConfig()?.to || DEFAULT_TO
|
|
316
350
|
const to = resolve(CWD, folder)
|
|
@@ -326,7 +360,7 @@ function copiesFor(items, internal, to) {
|
|
|
326
360
|
const pro = isPro(item)
|
|
327
361
|
for (const file of filesOf(item)) copies.push({ from: file, to: join(to, k.folder, relative(k.dir, file)), pro })
|
|
328
362
|
}
|
|
329
|
-
for (const file of internal) copies.push({ from: file, to: join(to,
|
|
363
|
+
for (const file of internal) copies.push({ from: file, to: join(to, relative(SRC, file)), pro: false })
|
|
330
364
|
return copies
|
|
331
365
|
}
|
|
332
366
|
|
|
@@ -383,11 +417,11 @@ function runInit(opts) {
|
|
|
383
417
|
const config = join(CWD, CONFIG)
|
|
384
418
|
if (isFile(config)) console.log(` ${CONFIG}: already there, kept`)
|
|
385
419
|
else {
|
|
386
|
-
if (!opts.dryRun) writeFileSync(config, `${JSON.stringify({ to: folder }, null, 2)}\n`)
|
|
387
|
-
console.log(` ${CONFIG}: added, so later commands put files in ${folder}`)
|
|
420
|
+
if (!opts.dryRun) writeFileSync(config, `${JSON.stringify({ framework, to: folder }, null, 2)}\n`)
|
|
421
|
+
console.log(` ${CONFIG}: added, so later commands use ${framework === 'vue' ? 'Vue' : 'React'} and put files in ${folder}`)
|
|
388
422
|
}
|
|
389
423
|
console.log(`\nNext:\n 1. Import both once, tokens first, ${fromEntry(folder)}`)
|
|
390
|
-
console.log(
|
|
424
|
+
console.log(' 2. Add your first component: npx gooee add button')
|
|
391
425
|
console.log(` See everything there is: npx gooee list, or ${SITE}`)
|
|
392
426
|
}
|
|
393
427
|
|
|
@@ -395,17 +429,22 @@ function runList(opts) {
|
|
|
395
429
|
const all = listItems()
|
|
396
430
|
const wanted = opts.kind ? KINDS.find((k) => k.folder === opts.kind.toLowerCase() || k.key === opts.kind.toLowerCase()) : null
|
|
397
431
|
if (opts.kind && !wanted) fail(`"${opts.kind}" is not a kind. Use components, blocks, templates or themes.`)
|
|
432
|
+
const vue = framework === 'vue'
|
|
433
|
+
if (vue) console.log('Vue parts. Add --react to see the React ones.')
|
|
398
434
|
for (const k of KINDS) {
|
|
399
435
|
if (wanted && wanted !== k) continue
|
|
400
436
|
const names = all.filter((i) => i.kind === k.key)
|
|
401
|
-
const
|
|
402
|
-
const
|
|
403
|
-
|
|
437
|
+
const fits = vue ? names.filter(hasVue) : names
|
|
438
|
+
const free = fits.filter((i) => !isPro(i)).map((i) => i.name)
|
|
439
|
+
const pro = [...fits.filter((i) => isPro(i)).map((i) => i.name), ...(k.key === 'component' ? proComponents() : [])]
|
|
440
|
+
const reactOnly = names.filter((i) => !fits.includes(i)).map((i) => i.name)
|
|
441
|
+
if (!free.length && !pro.length && !reactOnly.length) continue
|
|
404
442
|
console.log(`${k.plural} (${free.length + pro.length})`)
|
|
405
443
|
if (free.length) console.log(` ${free.join(', ')}`)
|
|
406
444
|
if (pro.length) console.log(` Pro: ${pro.join(', ')}`)
|
|
445
|
+
if (reactOnly.length) console.log(` React only: ${reactOnly.join(', ')}`)
|
|
407
446
|
}
|
|
408
|
-
if (!wanted) console.log(`Helpers (${Object.keys(HELPERS).length})\n ${Object.keys(HELPERS).join(', ')}`)
|
|
447
|
+
if (!wanted && !vue) console.log(`Helpers (${Object.keys(HELPERS).length})\n ${Object.keys(HELPERS).join(', ')}`)
|
|
409
448
|
console.log(`\nAdd one: npx gooee add <name>. Every page: ${SITE}`)
|
|
410
449
|
}
|
|
411
450
|
|
|
@@ -430,6 +469,7 @@ function runAdd(opts) {
|
|
|
430
469
|
return true
|
|
431
470
|
}
|
|
432
471
|
for (const c of copies) put(c, opts.overwrite)
|
|
472
|
+
if (!opts.dryRun) saveHashes(copies.filter((c) => state(c) === 'same'))
|
|
433
473
|
// Stylesheets hold the app's own theme edits, so they are never replaced.
|
|
434
474
|
const tokensNew = put(sheets[0], false)
|
|
435
475
|
if (sheets[1]) put(sheets[1], false)
|
|
@@ -440,7 +480,9 @@ function runAdd(opts) {
|
|
|
440
480
|
const names = items.filter((i) => i.kind === k.key).map((i) => i.name)
|
|
441
481
|
if (names.length || k.key === 'component') console.log(`${k.plural}: ${names.length ? names.join(', ') : 'none'}`)
|
|
442
482
|
}
|
|
443
|
-
|
|
483
|
+
const inside = (dir) => internal.filter((f) => f.startsWith(dir + sep)).map((f) => relative(dir, f))
|
|
484
|
+
console.log(`Internal files: ${inside(INTERNAL).join(', ') || 'none'}`)
|
|
485
|
+
if (inside(ICONS).length) console.log(`Icons: ${inside(ICONS).map((f) => `icons/${f}`).join(', ')}`)
|
|
444
486
|
if (needs.size) {
|
|
445
487
|
console.log('Dependencies:')
|
|
446
488
|
for (const { item, deps } of needs.values()) console.log(` ${item.name} needs ${[...deps.values()].map(label).join(', ')}`)
|
|
@@ -455,16 +497,73 @@ function runAdd(opts) {
|
|
|
455
497
|
if (items.some((i) => i.kind === 'theme')) console.log('Themes: import each one after tokens.css, then set data-theme-brand or data-density on <html>.')
|
|
456
498
|
}
|
|
457
499
|
|
|
458
|
-
// Compares the
|
|
459
|
-
function compare(
|
|
460
|
-
const all = listItems()
|
|
461
|
-
const { to } = targetFolder(opts)
|
|
462
|
-
const { items, internal } = plan(opts.names.map((n) => lookup(n, all)))
|
|
500
|
+
// Compares the items (and what they import) with the copies in the project.
|
|
501
|
+
function compare(to, items, internal) {
|
|
463
502
|
const copies = copiesFor(items, internal, to).map((c) => ({ ...c, state: state(c) }))
|
|
464
|
-
return { to, items, copies }
|
|
503
|
+
return { copies, gone: goneFiles(to, items, copies) }
|
|
465
504
|
}
|
|
466
505
|
|
|
467
|
-
|
|
506
|
+
const walkFiles = (dir) => (isDir(dir) ? readdirSync(dir, { withFileTypes: true }).flatMap((d) => (d.isDirectory() ? walkFiles(join(dir, d.name)) : [join(dir, d.name)])) : [])
|
|
507
|
+
|
|
508
|
+
// Files in an item's folder that start with our credit line, but that the latest version no longer has.
|
|
509
|
+
// One can go only when it is still exactly what the CLI wrote (its hash in gooee.json); otherwise it stays.
|
|
510
|
+
function goneFiles(to, items, copies) {
|
|
511
|
+
const ours = new Set(copies.map((c) => c.to))
|
|
512
|
+
const hashes = readConfig()?.files ?? {}
|
|
513
|
+
return items
|
|
514
|
+
.filter((item) => !kindOf(item.kind).single)
|
|
515
|
+
.flatMap((item) => {
|
|
516
|
+
const k = kindOf(item.kind)
|
|
517
|
+
const latest = new Set(listFiles(join(k.dir, item.name)).map((f) => relative(k.dir, f)))
|
|
518
|
+
return walkFiles(join(to, k.folder, item.name)).filter((f) => !ours.has(f) && !latest.has(relative(join(to, k.folder), f)))
|
|
519
|
+
})
|
|
520
|
+
.flatMap((file) => {
|
|
521
|
+
const text = readFileSync(file, 'utf8')
|
|
522
|
+
const body = withoutCredit(text)
|
|
523
|
+
if (body === text) return []
|
|
524
|
+
const saved = hashes[configKey(file)]
|
|
525
|
+
return [{ file, remove: saved === hash(body), why: saved ? 'you changed it' : `${CONFIG} has no record of it` }]
|
|
526
|
+
})
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
// Installed parts, besides the ones asked for, that import a shared file (internal/ or icons/) whose latest version differs.
|
|
530
|
+
function dependents(to, items, copies) {
|
|
531
|
+
const sharedIn = (file) => ['internal', 'icons'].some((d) => file.startsWith(join(to, d) + sep))
|
|
532
|
+
const changed = new Set(copies.filter((c) => c.state === 'changed' && sharedIn(c.to)).map((c) => c.to))
|
|
533
|
+
if (!changed.size) return []
|
|
534
|
+
const asked = new Set(items.map(keyOf))
|
|
535
|
+
const local = (from, spec) => {
|
|
536
|
+
const base = resolve(dirname(from), spec)
|
|
537
|
+
return [base, `${base}.ts`, `${base}.tsx`, join(base, 'index.ts'), join(base, 'index.tsx')].find(isFile)
|
|
538
|
+
}
|
|
539
|
+
const reach = new Map()
|
|
540
|
+
const internalOf = (file) => {
|
|
541
|
+
if (reach.has(file)) return reach.get(file)
|
|
542
|
+
const found = new Set()
|
|
543
|
+
reach.set(file, found)
|
|
544
|
+
for (const spec of importsOf(file)) {
|
|
545
|
+
const hit = local(file, spec)
|
|
546
|
+
if (!hit || !sharedIn(hit)) continue
|
|
547
|
+
found.add(hit)
|
|
548
|
+
for (const f of internalOf(hit)) found.add(f)
|
|
549
|
+
}
|
|
550
|
+
return found
|
|
551
|
+
}
|
|
552
|
+
const fits = (f) => (f.endsWith('.vue') ? framework === 'vue' : f.endsWith('.tsx') ? framework === 'react' : /\.ts$/.test(f))
|
|
553
|
+
const all = listItems()
|
|
554
|
+
return KINDS.filter((k) => !k.single && isDir(join(to, k.folder))).flatMap((k) =>
|
|
555
|
+
readdirSync(join(to, k.folder), { withFileTypes: true })
|
|
556
|
+
.filter((d) => d.isDirectory() && !asked.has(`${k.key}:${d.name}`))
|
|
557
|
+
.flatMap((d) => {
|
|
558
|
+
const uses = new Set(walkFiles(join(to, k.folder, d.name)).filter(fits).flatMap((f) => [...internalOf(f)].filter((i) => changed.has(i))))
|
|
559
|
+
if (!uses.size) return []
|
|
560
|
+
const item = all.find((i) => i.kind === k.key && i.name === d.name)
|
|
561
|
+
return [{ name: d.name, item, uses: [...uses].map((f) => shown(to, f)).sort() }]
|
|
562
|
+
}),
|
|
563
|
+
)
|
|
564
|
+
}
|
|
565
|
+
|
|
566
|
+
function report(to, copies, gone, withLines) {
|
|
468
567
|
const changed = copies.filter((c) => c.state === 'changed')
|
|
469
568
|
const missing = copies.filter((c) => c.state === 'missing')
|
|
470
569
|
for (const c of changed) {
|
|
@@ -472,26 +571,64 @@ function report(to, copies, withLines) {
|
|
|
472
571
|
if (withLines) for (const line of lineDiff(withoutCredit(readFileSync(c.to, 'utf8')), readFileSync(c.from, 'utf8'))) console.log(` ${line}`)
|
|
473
572
|
}
|
|
474
573
|
for (const c of missing) console.log(`New: ${shown(to, c.to)}`)
|
|
574
|
+
for (const g of gone) console.log(`Gone: ${shown(to, g.file)} (not in the latest version. ${g.remove ? 'update deletes it' : `update keeps it, since ${g.why}. Delete it yourself if nothing uses it`})`)
|
|
475
575
|
const same = copies.length - changed.length - missing.length
|
|
476
|
-
console.log(`\n${plural(changed.length, 'file')} changed, ${missing.length} new, ${same} up to date.`)
|
|
576
|
+
console.log(`\n${plural(changed.length, 'file')} changed, ${missing.length} new, ${gone.length} gone, ${same} up to date.`)
|
|
477
577
|
if (withLines && changed.length) console.log('Lines with "-" are in your copy, lines with "+" are in the latest version.')
|
|
478
|
-
return changed.length + missing.length
|
|
578
|
+
return changed.length + missing.length + gone.length
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
function reportDependents(deps) {
|
|
582
|
+
if (!deps.length) return
|
|
583
|
+
console.log('\nThese installed parts use a shared file that changed, so they may need the update too:')
|
|
584
|
+
for (const d of deps) console.log(` ${d.name}${d.item ? '' : ' (your own part)'}: ${d.uses.join(', ')}`)
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
async function ask(question) {
|
|
588
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout })
|
|
589
|
+
const answer = (await rl.question(`${question} (y/N) `)).trim().toLowerCase()
|
|
590
|
+
rl.close()
|
|
591
|
+
return answer === 'y' || answer === 'yes'
|
|
479
592
|
}
|
|
480
593
|
|
|
481
594
|
function runDiff(opts) {
|
|
482
|
-
const
|
|
483
|
-
const
|
|
484
|
-
|
|
595
|
+
const all = listItems()
|
|
596
|
+
const { to } = targetFolder(opts)
|
|
597
|
+
const { items, internal } = plan(opts.names.map((n) => lookup(n, all)))
|
|
598
|
+
const { copies, gone } = compare(to, items, internal)
|
|
599
|
+
const count = report(to, copies, gone, true)
|
|
600
|
+
const deps = dependents(to, items, copies)
|
|
601
|
+
reportDependents(deps)
|
|
602
|
+
const more = deps.filter((d) => d.item).map((d) => kebab(d.name))
|
|
603
|
+
if (count) console.log(`\nTake the latest version: npx gooee update ${[...opts.names, ...more].join(' ')}`)
|
|
485
604
|
}
|
|
486
605
|
|
|
487
606
|
async function runUpdate(opts) {
|
|
488
|
-
const
|
|
607
|
+
const all = listItems()
|
|
608
|
+
const { to } = targetFolder(opts)
|
|
609
|
+
const asked = opts.names.map((n) => lookup(n, all))
|
|
610
|
+
let { items, internal } = plan(asked)
|
|
611
|
+
let { copies, gone } = compare(to, items, internal)
|
|
612
|
+
const deps = dependents(to, items, copies)
|
|
613
|
+
reportDependents(deps)
|
|
614
|
+
const extra = deps.filter((d) => d.item).map((d) => d.item)
|
|
615
|
+
if (extra.length && !opts.dryRun) {
|
|
616
|
+
const names = extra.map((i) => i.name).join(', ')
|
|
617
|
+
if (!opts.yes && !process.stdin.isTTY) fail('update asks before replacing files. Run it in a terminal, or add --yes.', false)
|
|
618
|
+
if (opts.yes || (await ask(`Update ${names} too?`))) {
|
|
619
|
+
;({ items, internal } = plan([...asked, ...extra]))
|
|
620
|
+
;({ copies, gone } = compare(to, items, internal))
|
|
621
|
+
console.log(`Also updating ${names}.`)
|
|
622
|
+
}
|
|
623
|
+
}
|
|
489
624
|
const todo = copies.filter((c) => c.state !== 'same')
|
|
490
|
-
|
|
625
|
+
const remove = gone.filter((g) => g.remove)
|
|
626
|
+
if (!todo.length && !gone.length) {
|
|
491
627
|
console.log(`Everything is up to date (${plural(copies.length, 'file')}).`)
|
|
492
628
|
return
|
|
493
629
|
}
|
|
494
|
-
report(to, copies, false)
|
|
630
|
+
report(to, copies, gone, false)
|
|
631
|
+
if (!todo.length && !remove.length) return
|
|
495
632
|
if (opts.dryRun) {
|
|
496
633
|
console.log('Dry run, nothing written.')
|
|
497
634
|
return
|
|
@@ -499,16 +636,16 @@ async function runUpdate(opts) {
|
|
|
499
636
|
if (!opts.yes) {
|
|
500
637
|
if (!process.stdin.isTTY) fail('update asks before replacing files. Run it in a terminal, or add --yes.', false)
|
|
501
638
|
console.log('Your own edits in the changed files will be replaced. See them first with diff.')
|
|
502
|
-
const
|
|
503
|
-
|
|
504
|
-
rl.close()
|
|
505
|
-
if (answer !== 'y' && answer !== 'yes') {
|
|
639
|
+
const what = [todo.length && `replace ${plural(todo.length, 'file')}`, remove.length && `delete ${plural(remove.length, 'file')}`].filter(Boolean).join(' and ')
|
|
640
|
+
if (!(await ask(`${what[0].toUpperCase()}${what.slice(1)}?`))) {
|
|
506
641
|
console.log('Nothing changed.')
|
|
507
642
|
return
|
|
508
643
|
}
|
|
509
644
|
}
|
|
510
645
|
for (const c of todo) writeCopy(c, false)
|
|
511
|
-
|
|
646
|
+
for (const g of remove) rmSync(g.file)
|
|
647
|
+
saveHashes(copies, remove.map((g) => g.file))
|
|
648
|
+
console.log([todo.length && `Updated ${plural(todo.length, 'file')}.`, remove.length && `Deleted ${plural(remove.length, 'file')} the latest version no longer has.`].filter(Boolean).join(' '))
|
|
512
649
|
}
|
|
513
650
|
|
|
514
651
|
const tokenNames = (text) => new Set([...text.replace(/\/\*[\s\S]*?\*\//g, '').matchAll(/(--[\w-]+)\s*:/g)].map((m) => m[1]))
|
|
@@ -547,9 +684,11 @@ function warnMissingTokens(opts) {
|
|
|
547
684
|
}
|
|
548
685
|
|
|
549
686
|
const opts = parseArgs(process.argv.slice(2))
|
|
687
|
+
framework = opts.framework || readConfig()?.framework || 'react'
|
|
688
|
+
if (!['react', 'vue'].includes(framework)) fail(`${CONFIG} has "framework": ${JSON.stringify(framework)}. Use "react" or "vue".`, false)
|
|
550
689
|
if (opts.command === 'init') runInit(opts)
|
|
551
690
|
else if (opts.command === 'list') runList(opts)
|
|
552
691
|
else if (opts.command === 'diff') runDiff(opts)
|
|
553
692
|
else if (opts.command === 'update') await runUpdate(opts)
|
|
554
|
-
else runAdd(opts)
|
|
693
|
+
else if (opts.command === 'add') runAdd(opts)
|
|
555
694
|
if (['add', 'diff', 'update'].includes(opts.command)) warnMissingTokens(opts)
|
package/src/base.css
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.base {
|
|
1
2
|
*,
|
|
2
3
|
*::before,
|
|
3
4
|
*::after {
|
|
@@ -18,7 +19,7 @@ body {
|
|
|
18
19
|
line-height: var(--gooee-leading-normal);
|
|
19
20
|
-webkit-font-smoothing: antialiased;
|
|
20
21
|
-moz-osx-font-smoothing: grayscale;
|
|
21
|
-
transition: background-color var(--gooee-motion-base) var(--gooee-ease-
|
|
22
|
+
transition: background-color var(--gooee-motion-base) var(--gooee-ease-morph), color var(--gooee-motion-base) var(--gooee-ease-morph);
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
button,
|
|
@@ -37,3 +38,4 @@ svg {
|
|
|
37
38
|
:focus:not(:focus-visible) {
|
|
38
39
|
outline: none;
|
|
39
40
|
}
|
|
41
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
@layer gooee.components {
|
|
1
2
|
.root {
|
|
2
3
|
display: flex;
|
|
3
4
|
flex-direction: column;
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
font-weight: var(--gooee-weight-medium);
|
|
33
34
|
text-align: left;
|
|
34
35
|
cursor: pointer;
|
|
35
|
-
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-
|
|
36
|
+
transition: background-color var(--gooee-motion-fast) var(--gooee-ease-morph);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
@media (hover: hover) {
|
|
@@ -42,7 +43,7 @@
|
|
|
42
43
|
|
|
43
44
|
.trigger:focus-visible {
|
|
44
45
|
outline: none;
|
|
45
|
-
box-shadow: inset 0 0 0 var(--gooee-
|
|
46
|
+
box-shadow: inset 0 0 0 var(--gooee-focus-width) var(--gooee-color-fg);
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
.title {
|
|
@@ -55,10 +56,10 @@
|
|
|
55
56
|
width: var(--gooee-icon-md);
|
|
56
57
|
height: var(--gooee-icon-md);
|
|
57
58
|
color: var(--gooee-color-fg-muted);
|
|
58
|
-
transition: transform var(--gooee-motion-slow) var(--gooee-ease-
|
|
59
|
+
transition: transform var(--gooee-motion-slow) var(--gooee-ease-morph);
|
|
59
60
|
}
|
|
60
61
|
|
|
61
|
-
.item[data-open] .chevron { transform: rotate(180deg); }
|
|
62
|
+
.item[data-state='open'] .chevron { transform: rotate(180deg); }
|
|
62
63
|
|
|
63
64
|
/* Height animates with grid rows from 0fr to 1fr, so no JS measuring is needed. */
|
|
64
65
|
.panel {
|
|
@@ -70,7 +71,7 @@
|
|
|
70
71
|
visibility 0s linear var(--gooee-motion-morph);
|
|
71
72
|
}
|
|
72
73
|
|
|
73
|
-
.item[data-open] .panel {
|
|
74
|
+
.item[data-state='open'] .panel {
|
|
74
75
|
grid-template-rows: 1fr;
|
|
75
76
|
visibility: visible;
|
|
76
77
|
transition:
|
|
@@ -88,3 +89,4 @@
|
|
|
88
89
|
color: var(--gooee-color-fg-muted);
|
|
89
90
|
line-height: var(--gooee-leading-normal);
|
|
90
91
|
}
|
|
92
|
+
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { createContext, useContext, useId, useRef, type KeyboardEvent, type ReactNode } from 'react'
|
|
4
4
|
import { cx } from '../../internal/cx'
|
|
5
|
-
import { ChevronDownIcon } from '../../
|
|
5
|
+
import { ChevronDownIcon } from '../../icons/icons'
|
|
6
6
|
import { useControllable } from '../../internal/useControllable'
|
|
7
7
|
import styles from './Accordion.module.css'
|
|
8
8
|
|
|
@@ -65,13 +65,13 @@ export function Accordion({
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
return (
|
|
68
|
-
<AccCtx
|
|
69
|
-
<LevelCtx
|
|
70
|
-
<div ref={rootRef} className={cx(styles.root, className)} onKeyDown={onKeyDown}>
|
|
68
|
+
<AccCtx value={{ open, toggle }}>
|
|
69
|
+
<LevelCtx value={headingLevel}>
|
|
70
|
+
<div ref={rootRef} data-slot="accordion" className={cx(styles.root, className)} onKeyDown={onKeyDown}>
|
|
71
71
|
{children}
|
|
72
72
|
</div>
|
|
73
|
-
</LevelCtx
|
|
74
|
-
</AccCtx
|
|
73
|
+
</LevelCtx>
|
|
74
|
+
</AccCtx>
|
|
75
75
|
)
|
|
76
76
|
}
|
|
77
77
|
|
|
@@ -94,30 +94,32 @@ export function AccordionItem({ value, title, disabled, children }: AccordionIte
|
|
|
94
94
|
const isOpen = ctx.open.includes(value)
|
|
95
95
|
const Heading = `h${level}` as 'h3'
|
|
96
96
|
return (
|
|
97
|
-
<div className={styles.item} data-
|
|
98
|
-
<Heading className={styles.heading}>
|
|
97
|
+
<div data-slot="accordion-item" className={styles.item} data-state={isOpen ? 'open' : 'closed'} data-disabled={disabled || undefined}>
|
|
98
|
+
<Heading data-slot="accordion-heading" className={styles.heading}>
|
|
99
99
|
<button
|
|
100
100
|
id={`${id}-trigger`}
|
|
101
101
|
type="button"
|
|
102
|
+
data-slot="accordion-trigger"
|
|
102
103
|
className={styles.trigger}
|
|
103
104
|
aria-expanded={isOpen}
|
|
104
105
|
aria-controls={`${id}-panel`}
|
|
105
106
|
disabled={disabled}
|
|
106
107
|
onClick={() => ctx.toggle(value)}
|
|
107
108
|
>
|
|
108
|
-
<span className={styles.title}>{title}</span>
|
|
109
|
-
<ChevronDownIcon className={styles.chevron} />
|
|
109
|
+
<span data-slot="accordion-title" className={styles.title}>{title}</span>
|
|
110
|
+
<ChevronDownIcon data-slot="accordion-icon" className={styles.chevron} />
|
|
110
111
|
</button>
|
|
111
112
|
</Heading>
|
|
112
113
|
<div
|
|
113
114
|
id={`${id}-panel`}
|
|
114
115
|
role="region"
|
|
115
116
|
aria-labelledby={`${id}-trigger`}
|
|
117
|
+
data-slot="accordion-panel"
|
|
116
118
|
className={styles.panel}
|
|
117
119
|
inert={!isOpen}
|
|
118
120
|
>
|
|
119
121
|
<div className={styles.panelInner}>
|
|
120
|
-
<div className={styles.content}>{children}</div>
|
|
122
|
+
<div data-slot="accordion-content" className={styles.content}>{children}</div>
|
|
121
123
|
</div>
|
|
122
124
|
</div>
|
|
123
125
|
</div>
|
|
@@ -6,21 +6,22 @@ import styles from './Accordion.module.css'
|
|
|
6
6
|
// The Vue Accordion: the same look (Accordion.module.css) and keys as the React one. Put AccordionItem
|
|
7
7
|
// parts inside.
|
|
8
8
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
const {
|
|
10
|
+
type = 'single',
|
|
11
|
+
defaultValue = [],
|
|
12
|
+
headingLevel = 3,
|
|
13
|
+
} = defineProps<{
|
|
14
|
+
/** "single" keeps one item open at a time. */
|
|
15
|
+
type?: 'single' | 'multiple'
|
|
16
|
+
/** Starting open items when there is no v-model. */
|
|
17
|
+
defaultValue?: string[]
|
|
18
|
+
/** Heading level for item titles, to fit the page outline. */
|
|
19
|
+
headingLevel?: 2 | 3 | 4 | 5 | 6
|
|
20
|
+
}>()
|
|
20
21
|
|
|
21
22
|
/** Values of the open items. Use v-model, or leave it out and the accordion keeps its own state. */
|
|
22
23
|
const model = defineModel<string[]>()
|
|
23
|
-
const local = ref(
|
|
24
|
+
const local = ref(defaultValue)
|
|
24
25
|
const open = computed(() => model.value ?? local.value)
|
|
25
26
|
const set = (next: string[]) => {
|
|
26
27
|
local.value = next
|
|
@@ -29,10 +30,10 @@ const set = (next: string[]) => {
|
|
|
29
30
|
|
|
30
31
|
provide(accordionKey, {
|
|
31
32
|
open,
|
|
32
|
-
level: computed(() =>
|
|
33
|
+
level: computed(() => headingLevel),
|
|
33
34
|
toggle: (v) => {
|
|
34
35
|
const isOpen = open.value.includes(v)
|
|
35
|
-
if (
|
|
36
|
+
if (type === 'single') set(isOpen ? [] : [v])
|
|
36
37
|
else set(isOpen ? open.value.filter((x) => x !== v) : [...open.value, v])
|
|
37
38
|
},
|
|
38
39
|
})
|
|
@@ -56,7 +57,7 @@ const onKeyDown = (e: KeyboardEvent) => {
|
|
|
56
57
|
</script>
|
|
57
58
|
|
|
58
59
|
<template>
|
|
59
|
-
<div ref="root" :class="styles.root" @keydown="onKeyDown">
|
|
60
|
+
<div ref="root" data-slot="accordion" :class="styles.root" @keydown="onKeyDown">
|
|
60
61
|
<slot />
|
|
61
62
|
</div>
|
|
62
63
|
</template>
|