@cfasim-ui/components 0.1.8 → 0.1.10
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/Box/Box.d.ts +24 -0
- package/dist/Box/Box.spec.d.ts +1 -0
- package/dist/Box/Box.test.d.ts +1 -0
- package/dist/Button/Button.d.ts +29 -0
- package/dist/Button/Button.spec.d.ts +1 -0
- package/dist/Button/Button.test.d.ts +1 -0
- package/dist/Expander/Expander.d.ts +28 -0
- package/dist/Expander/Expander.spec.d.ts +1 -0
- package/dist/Hint/Hint.d.ts +5 -0
- package/dist/Hint/Hint.spec.d.ts +1 -0
- package/dist/Hint/Hint.test.d.ts +1 -0
- package/dist/Icon/Icon.d.ts +18 -0
- package/dist/Icon/Icon.spec.d.ts +1 -0
- package/dist/LightDarkToggle/LightDarkToggle.d.ts +2 -0
- package/dist/NumberInput/NumberInput.d.ts +21 -0
- package/dist/NumberInput/NumberInput.spec.d.ts +1 -0
- package/dist/NumberInput/NumberInput.test.d.ts +1 -0
- package/dist/SelectBox/SelectBox.d.ts +19 -0
- package/dist/SelectBox/SelectBox.spec.d.ts +1 -0
- package/dist/SelectBox/SelectBox.test.d.ts +1 -0
- package/dist/SidebarLayout/SidebarLayout.d.ts +37 -0
- package/dist/SidebarLayout/SidebarLayout.test.d.ts +1 -0
- package/dist/Spinner/Spinner.d.ts +9 -0
- package/dist/Spinner/Spinner.spec.d.ts +1 -0
- package/dist/TextInput/TextInput.d.ts +14 -0
- package/dist/TextInput/TextInput.spec.d.ts +1 -0
- package/dist/TextInput/TextInput.test.d.ts +1 -0
- package/dist/Toggle/Toggle.d.ts +14 -0
- package/dist/Toggle/Toggle.spec.d.ts +1 -0
- package/dist/Toggle/Toggle.test.d.ts +1 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +700 -0
- package/package.json +17 -3
- package/src/Box/Box.md +0 -41
- package/src/Box/Box.spec.ts +0 -13
- package/src/Box/Box.test.ts +0 -49
- package/src/Box/Box.vue +0 -52
- package/src/Button/Button.md +0 -55
- package/src/Button/Button.spec.ts +0 -18
- package/src/Button/Button.test.ts +0 -36
- package/src/Button/Button.vue +0 -81
- package/src/Expander/Expander.md +0 -23
- package/src/Expander/Expander.spec.ts +0 -14
- package/src/Expander/Expander.vue +0 -95
- package/src/Hint/Hint.md +0 -24
- package/src/Hint/Hint.spec.ts +0 -12
- package/src/Hint/Hint.test.ts +0 -34
- package/src/Hint/Hint.vue +0 -83
- package/src/Icon/Icon.md +0 -55
- package/src/Icon/Icon.spec.ts +0 -9
- package/src/Icon/Icon.vue +0 -112
- package/src/LightDarkToggle/LightDarkToggle.vue +0 -49
- package/src/NumberInput/NumberInput.md +0 -187
- package/src/NumberInput/NumberInput.spec.ts +0 -10
- package/src/NumberInput/NumberInput.test.ts +0 -580
- package/src/NumberInput/NumberInput.vue +0 -446
- package/src/SelectBox/SelectBox.md +0 -56
- package/src/SelectBox/SelectBox.spec.ts +0 -9
- package/src/SelectBox/SelectBox.test.ts +0 -42
- package/src/SelectBox/SelectBox.vue +0 -190
- package/src/SidebarLayout/SidebarLayout.md +0 -104
- package/src/SidebarLayout/SidebarLayout.test.ts +0 -86
- package/src/SidebarLayout/SidebarLayout.vue +0 -465
- package/src/Spinner/Spinner.md +0 -45
- package/src/Spinner/Spinner.spec.ts +0 -9
- package/src/Spinner/Spinner.vue +0 -55
- package/src/TextInput/TextInput.md +0 -41
- package/src/TextInput/TextInput.spec.ts +0 -10
- package/src/TextInput/TextInput.test.ts +0 -70
- package/src/TextInput/TextInput.vue +0 -90
- package/src/Toggle/Toggle.md +0 -68
- package/src/Toggle/Toggle.spec.ts +0 -13
- package/src/Toggle/Toggle.test.ts +0 -35
- package/src/Toggle/Toggle.vue +0 -81
- package/src/index.ts +0 -15
package/src/Icon/Icon.md
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
# Icon
|
|
2
|
-
|
|
3
|
-
Renders a [Material Symbols Outlined](https://fonts.google.com/icons) icon.
|
|
4
|
-
|
|
5
|
-
## Examples
|
|
6
|
-
|
|
7
|
-
### Sizes
|
|
8
|
-
|
|
9
|
-
<ComponentDemo>
|
|
10
|
-
<Icon icon="help" size="sm" aria-label="help" />
|
|
11
|
-
<Icon icon="help" size="md" aria-label="help" />
|
|
12
|
-
<Icon icon="help" size="lg" aria-label="help" />
|
|
13
|
-
|
|
14
|
-
<template #code>
|
|
15
|
-
|
|
16
|
-
```vue
|
|
17
|
-
<Icon icon="help" size="sm" aria-label="help" />
|
|
18
|
-
<Icon icon="help" size="md" aria-label="help" />
|
|
19
|
-
<Icon icon="help" size="lg" aria-label="help" />
|
|
20
|
-
```
|
|
21
|
-
|
|
22
|
-
</template>
|
|
23
|
-
</ComponentDemo>
|
|
24
|
-
|
|
25
|
-
### Filled
|
|
26
|
-
|
|
27
|
-
<ComponentDemo>
|
|
28
|
-
<Icon icon="favorite" size="lg" aria-label="favorite" />
|
|
29
|
-
<Icon icon="favorite" size="lg" :fill="true" aria-label="favorite filled" />
|
|
30
|
-
|
|
31
|
-
<template #code>
|
|
32
|
-
|
|
33
|
-
```vue
|
|
34
|
-
<Icon icon="favorite" size="lg" aria-label="favorite" />
|
|
35
|
-
<Icon icon="favorite" size="lg" :fill="true" aria-label="favorite filled" />
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
</template>
|
|
39
|
-
</ComponentDemo>
|
|
40
|
-
|
|
41
|
-
### Inline in text
|
|
42
|
-
|
|
43
|
-
<ComponentDemo>
|
|
44
|
-
<p style="margin: 0">Click the <Icon icon="help" size="sm" :inline="true" aria-label="help" /> icon for more info.</p>
|
|
45
|
-
|
|
46
|
-
<template #code>
|
|
47
|
-
|
|
48
|
-
```vue
|
|
49
|
-
<p>Click the <Icon icon="help" size="sm" :inline="true" aria-label="help" /> icon for more info.</p>
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
</template>
|
|
53
|
-
</ComponentDemo>
|
|
54
|
-
|
|
55
|
-
<!--@include: ./_api/icon.md-->
|
package/src/Icon/Icon.spec.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@playwright/test";
|
|
2
|
-
|
|
3
|
-
test("Icon page renders demos", async ({ page }) => {
|
|
4
|
-
await page.goto("./cfasim-ui/components/icon");
|
|
5
|
-
await expect(page.locator("h1")).toBeVisible();
|
|
6
|
-
const demos = page.locator(".demo-preview");
|
|
7
|
-
await expect(demos.first()).toBeVisible();
|
|
8
|
-
await expect(demos.first().locator(".Icon")).toHaveCount(3);
|
|
9
|
-
});
|
package/src/Icon/Icon.vue
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import type { CSSProperties } from "vue";
|
|
3
|
-
import { computed } from "vue";
|
|
4
|
-
|
|
5
|
-
export type IconSize = "sm" | "md" | "lg" | "xl";
|
|
6
|
-
|
|
7
|
-
interface Props {
|
|
8
|
-
icon: string;
|
|
9
|
-
size?: IconSize | number;
|
|
10
|
-
fill?: boolean;
|
|
11
|
-
weight?: number;
|
|
12
|
-
grade?: number;
|
|
13
|
-
decorative?: boolean;
|
|
14
|
-
ariaLabel?: string;
|
|
15
|
-
inline?: boolean;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
19
|
-
size: "md",
|
|
20
|
-
fill: false,
|
|
21
|
-
decorative: true,
|
|
22
|
-
inline: false,
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
const sizePreset = computed(() =>
|
|
26
|
-
typeof props.size === "string" ? props.size : undefined,
|
|
27
|
-
);
|
|
28
|
-
const numericSize = computed(() =>
|
|
29
|
-
typeof props.size === "number" ? props.size : undefined,
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
const inlineStyle = computed<CSSProperties>(() => {
|
|
33
|
-
const style: CSSProperties = {};
|
|
34
|
-
if (numericSize.value !== undefined) {
|
|
35
|
-
style.fontSize = `${numericSize.value}px`;
|
|
36
|
-
(style as Record<string, unknown>)["--icon-opsz"] = numericSize.value;
|
|
37
|
-
}
|
|
38
|
-
if (props.weight !== undefined) {
|
|
39
|
-
(style as Record<string, unknown>)["--icon-weight"] = props.weight;
|
|
40
|
-
}
|
|
41
|
-
if (props.grade !== undefined) {
|
|
42
|
-
(style as Record<string, unknown>)["--icon-grade"] = props.grade;
|
|
43
|
-
}
|
|
44
|
-
return style;
|
|
45
|
-
});
|
|
46
|
-
</script>
|
|
47
|
-
|
|
48
|
-
<template>
|
|
49
|
-
<span
|
|
50
|
-
class="Icon"
|
|
51
|
-
:data-size="sizePreset"
|
|
52
|
-
:data-fill="fill ? 'true' : undefined"
|
|
53
|
-
:data-inline="inline ? 'true' : undefined"
|
|
54
|
-
:style="inlineStyle"
|
|
55
|
-
:aria-hidden="decorative ? true : undefined"
|
|
56
|
-
:aria-label="decorative ? undefined : ariaLabel"
|
|
57
|
-
:role="decorative ? undefined : 'img'"
|
|
58
|
-
>{{ icon }}</span
|
|
59
|
-
>
|
|
60
|
-
</template>
|
|
61
|
-
|
|
62
|
-
<style>
|
|
63
|
-
.Icon {
|
|
64
|
-
font-family: "Material Symbols Outlined", sans-serif;
|
|
65
|
-
font-weight: normal;
|
|
66
|
-
font-style: normal;
|
|
67
|
-
font-size: 24px;
|
|
68
|
-
line-height: 1;
|
|
69
|
-
letter-spacing: normal;
|
|
70
|
-
text-transform: none;
|
|
71
|
-
display: inline-block;
|
|
72
|
-
white-space: nowrap;
|
|
73
|
-
word-wrap: normal;
|
|
74
|
-
direction: ltr;
|
|
75
|
-
font-feature-settings: "liga";
|
|
76
|
-
-webkit-font-smoothing: antialiased;
|
|
77
|
-
font-variation-settings:
|
|
78
|
-
"FILL" var(--icon-fill, 0),
|
|
79
|
-
"wght" var(--icon-weight, 400),
|
|
80
|
-
"GRAD" var(--icon-grade, 0),
|
|
81
|
-
"opsz" var(--icon-opsz, 24);
|
|
82
|
-
color: inherit;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.Icon[data-size="sm"] {
|
|
86
|
-
font-size: 20px;
|
|
87
|
-
--icon-opsz: 20;
|
|
88
|
-
}
|
|
89
|
-
.Icon[data-size="md"] {
|
|
90
|
-
font-size: 24px;
|
|
91
|
-
--icon-opsz: 24;
|
|
92
|
-
}
|
|
93
|
-
.Icon[data-size="lg"] {
|
|
94
|
-
font-size: 28px;
|
|
95
|
-
--icon-opsz: 28;
|
|
96
|
-
}
|
|
97
|
-
.Icon[data-size="xl"] {
|
|
98
|
-
font-size: 32px;
|
|
99
|
-
--icon-opsz: 32;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
.Icon[data-fill="true"] {
|
|
103
|
-
--icon-fill: 1;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
.Icon[data-inline="true"] {
|
|
107
|
-
font-size: inherit;
|
|
108
|
-
vertical-align: middle;
|
|
109
|
-
transform: scale(1.2) translateY(-0.05em);
|
|
110
|
-
transform-origin: 50% 50%;
|
|
111
|
-
}
|
|
112
|
-
</style>
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { ref, watch } from "vue";
|
|
3
|
-
import Icon from "../Icon/Icon.vue";
|
|
4
|
-
|
|
5
|
-
const isDark = ref(window.matchMedia("(prefers-color-scheme: dark)").matches);
|
|
6
|
-
|
|
7
|
-
function apply(dark: boolean) {
|
|
8
|
-
document.documentElement.classList.toggle("dark", dark);
|
|
9
|
-
document.documentElement.classList.toggle("light", !dark);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
apply(isDark.value);
|
|
13
|
-
|
|
14
|
-
watch(isDark, apply);
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<template>
|
|
18
|
-
<button
|
|
19
|
-
class="light-dark-toggle"
|
|
20
|
-
type="button"
|
|
21
|
-
:aria-label="isDark ? 'Switch to light mode' : 'Switch to dark mode'"
|
|
22
|
-
@click="isDark = !isDark"
|
|
23
|
-
>
|
|
24
|
-
<Icon :icon="isDark ? 'dark_mode' : 'light_mode'" size="sm" />
|
|
25
|
-
</button>
|
|
26
|
-
</template>
|
|
27
|
-
|
|
28
|
-
<style scoped>
|
|
29
|
-
.light-dark-toggle {
|
|
30
|
-
display: flex;
|
|
31
|
-
align-items: center;
|
|
32
|
-
justify-content: center;
|
|
33
|
-
width: 32px;
|
|
34
|
-
height: 32px;
|
|
35
|
-
border: 1px solid var(--color-border);
|
|
36
|
-
border-radius: 0.25em;
|
|
37
|
-
background: var(--color-bg-0);
|
|
38
|
-
color: var(--color-text-secondary);
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
transition:
|
|
41
|
-
color var(--transition-fast),
|
|
42
|
-
background-color var(--transition-fast);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
.light-dark-toggle:hover {
|
|
46
|
-
color: var(--color-text);
|
|
47
|
-
background: var(--color-bg-1);
|
|
48
|
-
}
|
|
49
|
-
</style>
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
# NumberInput
|
|
2
|
-
|
|
3
|
-
A number input field with optional slider, percent mode, and validation.
|
|
4
|
-
|
|
5
|
-
## Examples
|
|
6
|
-
|
|
7
|
-
### Basic
|
|
8
|
-
|
|
9
|
-
<script setup>
|
|
10
|
-
import { ref } from 'vue'
|
|
11
|
-
const days = ref(10)
|
|
12
|
-
const population = ref(100000)
|
|
13
|
-
const coverage = ref(0.5)
|
|
14
|
-
const r0 = ref(3.5)
|
|
15
|
-
</script>
|
|
16
|
-
|
|
17
|
-
<ComponentDemo>
|
|
18
|
-
<div style="width: 300px">
|
|
19
|
-
<NumberInput v-model="days" label="Days" placeholder="Number of days" />
|
|
20
|
-
</div>
|
|
21
|
-
|
|
22
|
-
<template #code>
|
|
23
|
-
|
|
24
|
-
```vue
|
|
25
|
-
<script setup>
|
|
26
|
-
import { ref } from "vue";
|
|
27
|
-
const days = ref(10);
|
|
28
|
-
</script>
|
|
29
|
-
|
|
30
|
-
<NumberInput v-model="days" label="Days" placeholder="Number of days" />
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
</template>
|
|
34
|
-
</ComponentDemo>
|
|
35
|
-
|
|
36
|
-
### With hint and validation
|
|
37
|
-
|
|
38
|
-
<ComponentDemo>
|
|
39
|
-
<div style="width: 300px">
|
|
40
|
-
<NumberInput
|
|
41
|
-
v-model="population"
|
|
42
|
-
label="Population"
|
|
43
|
-
hint="Total number of individuals"
|
|
44
|
-
:min="1000"
|
|
45
|
-
:max="100000"
|
|
46
|
-
:step="1"
|
|
47
|
-
/>
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
<template #code>
|
|
51
|
-
|
|
52
|
-
```vue
|
|
53
|
-
<NumberInput
|
|
54
|
-
v-model="population"
|
|
55
|
-
label="Population"
|
|
56
|
-
hint="Total number of individuals"
|
|
57
|
-
:min="1000"
|
|
58
|
-
:max="100000"
|
|
59
|
-
:step="1"
|
|
60
|
-
/>
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
</template>
|
|
64
|
-
</ComponentDemo>
|
|
65
|
-
|
|
66
|
-
### Percent mode
|
|
67
|
-
|
|
68
|
-
<ComponentDemo>
|
|
69
|
-
<div style="width: 300px">
|
|
70
|
-
<NumberInput
|
|
71
|
-
v-model="coverage"
|
|
72
|
-
label="Vaccination coverage"
|
|
73
|
-
percent
|
|
74
|
-
:max="1"
|
|
75
|
-
/>
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
<template #code>
|
|
79
|
-
|
|
80
|
-
```vue
|
|
81
|
-
<NumberInput v-model="coverage" label="Vaccination coverage" percent :max="1" />
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
</template>
|
|
85
|
-
</ComponentDemo>
|
|
86
|
-
|
|
87
|
-
### Slider
|
|
88
|
-
|
|
89
|
-
<ComponentDemo>
|
|
90
|
-
<div style="width: 300px">
|
|
91
|
-
<NumberInput
|
|
92
|
-
v-model="r0"
|
|
93
|
-
label="R0"
|
|
94
|
-
hint="Basic reproduction number"
|
|
95
|
-
:step="0.1"
|
|
96
|
-
:min="1"
|
|
97
|
-
:max="18"
|
|
98
|
-
slider
|
|
99
|
-
/>
|
|
100
|
-
</div>
|
|
101
|
-
|
|
102
|
-
<template #code>
|
|
103
|
-
|
|
104
|
-
```vue
|
|
105
|
-
<NumberInput
|
|
106
|
-
v-model="r0"
|
|
107
|
-
label="R0"
|
|
108
|
-
hint="Basic reproduction number"
|
|
109
|
-
:step="0.1"
|
|
110
|
-
:min="1"
|
|
111
|
-
:max="18"
|
|
112
|
-
slider
|
|
113
|
-
/>
|
|
114
|
-
```
|
|
115
|
-
|
|
116
|
-
</template>
|
|
117
|
-
</ComponentDemo>
|
|
118
|
-
|
|
119
|
-
### Live slider
|
|
120
|
-
|
|
121
|
-
With `live`, the model updates while dragging the slider thumb rather than only on release.
|
|
122
|
-
|
|
123
|
-
<ComponentDemo>
|
|
124
|
-
<div style="width: 300px">
|
|
125
|
-
<NumberInput
|
|
126
|
-
v-model="coverage"
|
|
127
|
-
label="Vaccination coverage"
|
|
128
|
-
percent
|
|
129
|
-
slider
|
|
130
|
-
live
|
|
131
|
-
:max="1"
|
|
132
|
-
/>
|
|
133
|
-
</div>
|
|
134
|
-
|
|
135
|
-
<template #code>
|
|
136
|
-
|
|
137
|
-
```vue
|
|
138
|
-
<NumberInput
|
|
139
|
-
v-model="coverage"
|
|
140
|
-
label="Vaccination coverage"
|
|
141
|
-
percent
|
|
142
|
-
slider
|
|
143
|
-
live
|
|
144
|
-
:max="1"
|
|
145
|
-
/>
|
|
146
|
-
```
|
|
147
|
-
|
|
148
|
-
</template>
|
|
149
|
-
</ComponentDemo>
|
|
150
|
-
|
|
151
|
-
### Live input
|
|
152
|
-
|
|
153
|
-
With `live` on a regular input, the model updates as you type (debounced 300ms). Arrow keys and spinner buttons commit immediately.
|
|
154
|
-
|
|
155
|
-
<ComponentDemo>
|
|
156
|
-
<div style="width: 300px">
|
|
157
|
-
<NumberInput v-model="days" label="Days" live />
|
|
158
|
-
</div>
|
|
159
|
-
|
|
160
|
-
<template #code>
|
|
161
|
-
|
|
162
|
-
```vue
|
|
163
|
-
<NumberInput v-model="days" label="Days" live />
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
</template>
|
|
167
|
-
</ComponentDemo>
|
|
168
|
-
|
|
169
|
-
### Integer type
|
|
170
|
-
|
|
171
|
-
With `number-type="integer"`, decimal values are truncated to whole numbers on commit. When combined with `percent`, the display value (e.g. 42%) is treated as the integer — so internal values like 0.42 are valid.
|
|
172
|
-
|
|
173
|
-
<ComponentDemo>
|
|
174
|
-
<div style="width: 300px">
|
|
175
|
-
<NumberInput v-model="days" label="Steps" number-type="integer" />
|
|
176
|
-
</div>
|
|
177
|
-
|
|
178
|
-
<template #code>
|
|
179
|
-
|
|
180
|
-
```vue
|
|
181
|
-
<NumberInput v-model="days" label="Steps" number-type="integer" />
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
</template>
|
|
185
|
-
</ComponentDemo>
|
|
186
|
-
|
|
187
|
-
<!--@include: ./_api/number-input.md-->
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { test, expect } from "@playwright/test";
|
|
2
|
-
|
|
3
|
-
test("NumberInput page renders demos", async ({ page }) => {
|
|
4
|
-
await page.goto("./cfasim-ui/components/number-input");
|
|
5
|
-
await expect(page.locator("h1")).toBeVisible();
|
|
6
|
-
const demos = page.locator(".demo-preview");
|
|
7
|
-
await expect(demos.first()).toBeVisible();
|
|
8
|
-
await expect(demos.first().getByText("Days")).toBeVisible();
|
|
9
|
-
await expect(demos.first().locator('input[type="text"]')).toBeVisible();
|
|
10
|
-
});
|