@flightlesslabs/dodo-ui 0.22.2 → 0.24.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/README.md +1 -9
- package/dist/index.d.ts +4 -10
- package/dist/index.js +5 -10
- package/dist/styles/components.css +0 -154
- package/dist/styles/components.css.map +1 -1
- package/dist/styles/components.scss +0 -2
- package/package.json +27 -41
- package/src/lib/index.ts +6 -19
- package/src/lib/styles/components.scss +0 -2
- package/src/lib/utils/time/date-creator/createDate/createDate.test.ts +109 -0
- package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.test.ts +146 -0
- package/dist/Home.mdx +0 -69
- package/dist/components/Form/Button/Button.stories.svelte +0 -178
- package/dist/components/Form/Button/Button.stories.svelte.d.ts +0 -22
- package/dist/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
- package/dist/components/Form/Checkbox/Checkbox.stories.svelte.d.ts +0 -25
- package/dist/components/Form/DatePicker/DatePicker.scss +0 -55
- package/dist/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
- package/dist/components/Form/DatePicker/DatePicker.stories.svelte.d.ts +0 -22
- package/dist/components/Form/DatePicker/DatePicker.svelte +0 -136
- package/dist/components/Form/DatePicker/DatePicker.svelte.d.ts +0 -64
- package/dist/components/Form/DatePicker/DatePickerInput/DatePickerInput.svelte +0 -96
- package/dist/components/Form/DatePicker/DatePickerInput/DatePickerInput.svelte.d.ts +0 -23
- package/dist/components/Form/DatePicker/DatePickerInput/Segments.svelte +0 -17
- package/dist/components/Form/DatePicker/DatePickerInput/Segments.svelte.d.ts +0 -8
- package/dist/components/Form/DatePicker/DatePickerInput/utils.d.ts +0 -10
- package/dist/components/Form/DatePicker/DatePickerInput/utils.js +0 -26
- package/dist/components/Form/DatePicker/DatePickerPopup/CalendarGrid.svelte +0 -35
- package/dist/components/Form/DatePicker/DatePickerPopup/CalendarGrid.svelte.d.ts +0 -4
- package/dist/components/Form/DatePicker/DatePickerPopup/DatePickerPopup.svelte +0 -52
- package/dist/components/Form/DatePicker/DatePickerPopup/DatePickerPopup.svelte.d.ts +0 -6
- package/dist/components/Form/DatePicker/DatePickerPopup/Header.svelte +0 -25
- package/dist/components/Form/DatePicker/DatePickerPopup/Header.svelte.d.ts +0 -3
- package/dist/components/Form/FormField/FormField.stories.svelte +0 -48
- package/dist/components/Form/FormField/FormField.stories.svelte.d.ts +0 -25
- package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
- package/dist/components/Form/InputEnclosure/InputEnclosure.stories.svelte.d.ts +0 -22
- package/dist/components/Form/Label/Label.stories.svelte +0 -31
- package/dist/components/Form/Label/Label.stories.svelte.d.ts +0 -25
- package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
- package/dist/components/Form/RadioGroup/Radio/Radio.stories.svelte.d.ts +0 -25
- package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
- package/dist/components/Form/RadioGroup/RadioGroup.stories.svelte.d.ts +0 -25
- package/dist/components/Form/Select/Select.stories.svelte +0 -175
- package/dist/components/Form/Select/Select.stories.svelte.d.ts +0 -22
- package/dist/components/Form/Switch/Switch.stories.svelte +0 -128
- package/dist/components/Form/Switch/Switch.stories.svelte.d.ts +0 -25
- package/dist/components/Form/TextInput/TextInput.stories.svelte +0 -162
- package/dist/components/Form/TextInput/TextInput.stories.svelte.d.ts +0 -22
- package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
- package/dist/components/Form/UtilityButton/UtilityButton.stories.svelte.d.ts +0 -22
- package/dist/components/Info/Calendar/Calendar.scss +0 -147
- package/dist/components/Info/Calendar/Calendar.stories.svelte +0 -134
- package/dist/components/Info/Calendar/Calendar.stories.svelte.d.ts +0 -22
- package/dist/components/Info/Calendar/Calendar.svelte +0 -61
- package/dist/components/Info/Calendar/Calendar.svelte.d.ts +0 -6
- package/dist/components/Info/Calendar/CalendarGrid/CalendarGrid.svelte +0 -16
- package/dist/components/Info/Calendar/CalendarGrid/CalendarGrid.svelte.d.ts +0 -4
- package/dist/components/Info/Calendar/CalendarGrid/TableBody.svelte +0 -25
- package/dist/components/Info/Calendar/CalendarGrid/TableBody.svelte.d.ts +0 -8
- package/dist/components/Info/Calendar/CalendarGrid/TableHead.svelte +0 -19
- package/dist/components/Info/Calendar/CalendarGrid/TableHead.svelte.d.ts +0 -6
- package/dist/components/Info/Calendar/Header.svelte +0 -25
- package/dist/components/Info/Calendar/Header.svelte.d.ts +0 -3
- package/dist/components/Layout/Card/Card.stories.svelte +0 -113
- package/dist/components/Layout/Card/Card.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Grid/Column/Column.stories.svelte +0 -66
- package/dist/components/Layout/Grid/Column/Column.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Grid/Grid.stories.svelte +0 -192
- package/dist/components/Layout/Grid/Grid.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Grid/Row/Row.stories.svelte +0 -39
- package/dist/components/Layout/Grid/Row/Row.stories.svelte.d.ts +0 -22
- package/dist/components/Layout/Theme/Theme.stories.svelte +0 -54
- package/dist/components/Layout/Theme/Theme.stories.svelte.d.ts +0 -25
- package/dist/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
- package/dist/storybook-types.d.ts +0 -129
- package/dist/storybook-types.js +0 -1
- package/dist/utils/time/date-creator/createDate/createDate.mdx +0 -98
- package/dist/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
- package/dist/utils/time/timeout/timeout.mdx +0 -114
- package/src/lib/Home.mdx +0 -69
- package/src/lib/components/Form/Button/Button.stories.svelte +0 -178
- package/src/lib/components/Form/Checkbox/Checkbox.stories.svelte +0 -132
- package/src/lib/components/Form/DatePicker/DatePicker.scss +0 -55
- package/src/lib/components/Form/DatePicker/DatePicker.stories.svelte +0 -139
- package/src/lib/components/Form/DatePicker/DatePicker.svelte +0 -136
- package/src/lib/components/Form/DatePicker/DatePickerInput/DatePickerInput.svelte +0 -96
- package/src/lib/components/Form/DatePicker/DatePickerInput/Segments.svelte +0 -17
- package/src/lib/components/Form/DatePicker/DatePickerInput/utils.ts +0 -55
- package/src/lib/components/Form/DatePicker/DatePickerPopup/CalendarGrid.svelte +0 -35
- package/src/lib/components/Form/DatePicker/DatePickerPopup/DatePickerPopup.svelte +0 -52
- package/src/lib/components/Form/DatePicker/DatePickerPopup/Header.svelte +0 -25
- package/src/lib/components/Form/FormField/FormField.stories.svelte +0 -48
- package/src/lib/components/Form/InputEnclosure/InputEnclosure.stories.svelte +0 -166
- package/src/lib/components/Form/Label/Label.stories.svelte +0 -31
- package/src/lib/components/Form/RadioGroup/Radio/Radio.stories.svelte +0 -78
- package/src/lib/components/Form/RadioGroup/RadioGroup.stories.svelte +0 -172
- package/src/lib/components/Form/Select/Select.stories.svelte +0 -175
- package/src/lib/components/Form/Switch/Switch.stories.svelte +0 -128
- package/src/lib/components/Form/TextInput/TextInput.stories.svelte +0 -162
- package/src/lib/components/Form/UtilityButton/UtilityButton.stories.svelte +0 -163
- package/src/lib/components/Info/Calendar/Calendar.scss +0 -147
- package/src/lib/components/Info/Calendar/Calendar.stories.svelte +0 -134
- package/src/lib/components/Info/Calendar/Calendar.svelte +0 -61
- package/src/lib/components/Info/Calendar/CalendarGrid/CalendarGrid.svelte +0 -16
- package/src/lib/components/Info/Calendar/CalendarGrid/TableBody.svelte +0 -25
- package/src/lib/components/Info/Calendar/CalendarGrid/TableHead.svelte +0 -19
- package/src/lib/components/Info/Calendar/Header.svelte +0 -25
- package/src/lib/components/Layout/Card/Card.stories.svelte +0 -113
- package/src/lib/components/Layout/Grid/Column/Column.stories.svelte +0 -66
- package/src/lib/components/Layout/Grid/Grid.stories.svelte +0 -192
- package/src/lib/components/Layout/Grid/Row/Row.stories.svelte +0 -39
- package/src/lib/components/Layout/Theme/Theme.stories.svelte +0 -54
- package/src/lib/components/Layout/Theme/ThemeSystem/index.mdx +0 -35
- package/src/lib/storybook-types.ts +0 -182
- package/src/lib/utils/time/date-creator/createDate/createDate.mdx +0 -98
- package/src/lib/utils/time/date-creator/createDateFactory/createDateFactory.mdx +0 -104
- package/src/lib/utils/time/timeout/timeout.mdx +0 -114
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import dayjs from 'dayjs';
|
|
3
|
+
import utc from 'dayjs/plugin/utc.js';
|
|
4
|
+
import timezone from 'dayjs/plugin/timezone.js';
|
|
5
|
+
import customParseFormat from 'dayjs/plugin/customParseFormat.js';
|
|
6
|
+
|
|
7
|
+
import { createDateFactory } from './createDateFactory.js';
|
|
8
|
+
|
|
9
|
+
// extend test dayjs (important for factory injection tests)
|
|
10
|
+
dayjs.extend(utc);
|
|
11
|
+
dayjs.extend(timezone);
|
|
12
|
+
dayjs.extend(customParseFormat);
|
|
13
|
+
|
|
14
|
+
describe('createDateFactory', () => {
|
|
15
|
+
it('should create a date with default factory', () => {
|
|
16
|
+
const { createDate } = createDateFactory();
|
|
17
|
+
|
|
18
|
+
const date = createDate();
|
|
19
|
+
|
|
20
|
+
expect(date.isValid()).toBe(true);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('should parse ISO string', () => {
|
|
24
|
+
const { createDate } = createDateFactory();
|
|
25
|
+
|
|
26
|
+
const date = createDate('2025-01-01');
|
|
27
|
+
|
|
28
|
+
expect(date.isValid()).toBe(true);
|
|
29
|
+
expect(date.year()).toBe(2025);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it('should parse formatted date', () => {
|
|
33
|
+
const { createDate } = createDateFactory();
|
|
34
|
+
|
|
35
|
+
const date = createDate('01-02-2025', 'DD-MM-YYYY');
|
|
36
|
+
|
|
37
|
+
expect(date.isValid()).toBe(true);
|
|
38
|
+
expect(date.year()).toBe(2025);
|
|
39
|
+
expect(date.month()).toBe(1);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should respect strict parsing (valid)', () => {
|
|
43
|
+
const { createDate } = createDateFactory();
|
|
44
|
+
|
|
45
|
+
const date = createDate('01-02-2025', 'DD-MM-YYYY', {
|
|
46
|
+
strict: true,
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
expect(date.isValid()).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('should respect strict parsing (invalid)', () => {
|
|
53
|
+
const { createDate } = createDateFactory();
|
|
54
|
+
|
|
55
|
+
const date = createDate('1-2-2025', 'DD-MM-YYYY', {
|
|
56
|
+
strict: true,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
expect(date.isValid()).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should throw on invalid date when enabled', () => {
|
|
63
|
+
const { createDate } = createDateFactory();
|
|
64
|
+
|
|
65
|
+
expect(() => createDate('invalid-date', undefined, { throwOnInvalid: true })).toThrow(
|
|
66
|
+
'Invalid date input',
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('should NOT throw on invalid date when disabled', () => {
|
|
71
|
+
const { createDate } = createDateFactory();
|
|
72
|
+
|
|
73
|
+
const date = createDate('invalid-date');
|
|
74
|
+
|
|
75
|
+
expect(date.isValid()).toBe(false);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it('should handle UTC mode', () => {
|
|
79
|
+
const { createDate } = createDateFactory();
|
|
80
|
+
|
|
81
|
+
const date = createDate('2025-01-01T00:00:00Z', undefined, {
|
|
82
|
+
utc: true,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
expect(date.isUTC()).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('should prioritize UTC over timezone', () => {
|
|
89
|
+
const { createDate } = createDateFactory();
|
|
90
|
+
|
|
91
|
+
const date = createDate('2025-01-01T00:00:00Z', undefined, {
|
|
92
|
+
utc: true,
|
|
93
|
+
timezone: 'Asia/Kolkata',
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
expect(date.isUTC()).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it('should apply timezone when provided', () => {
|
|
100
|
+
const { createDate } = createDateFactory();
|
|
101
|
+
|
|
102
|
+
const date = createDate('01-01-2025', 'DD-MM-YYYY', {
|
|
103
|
+
timezone: 'Asia/Kolkata',
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
expect(date.isValid()).toBe(true);
|
|
107
|
+
expect(typeof date.utcOffset()).toBe('number');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should handle timestamp input', () => {
|
|
111
|
+
const { createDate } = createDateFactory();
|
|
112
|
+
|
|
113
|
+
const ts = Date.now();
|
|
114
|
+
const date = createDate(ts);
|
|
115
|
+
|
|
116
|
+
expect(date.isValid()).toBe(true);
|
|
117
|
+
expect(Math.abs(date.valueOf() - ts)).toBeLessThan(5);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
it('should handle native Date object', () => {
|
|
121
|
+
const { createDate } = createDateFactory();
|
|
122
|
+
|
|
123
|
+
const now = new Date();
|
|
124
|
+
const date = createDate(now);
|
|
125
|
+
|
|
126
|
+
expect(date.isValid()).toBe(true);
|
|
127
|
+
expect(Math.abs(date.valueOf() - now.valueOf())).toBeLessThan(5);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('should work with custom Dayjs instance', () => {
|
|
131
|
+
const custom = dayjs;
|
|
132
|
+
|
|
133
|
+
const { createDate } = createDateFactory(custom);
|
|
134
|
+
|
|
135
|
+
const date = createDate('2025-01-01');
|
|
136
|
+
|
|
137
|
+
expect(date.isValid()).toBe(true);
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it('should return same underlying dayjs instance from factory', () => {
|
|
141
|
+
const { dayjs: d1 } = createDateFactory();
|
|
142
|
+
const { dayjs: d2 } = createDateFactory();
|
|
143
|
+
|
|
144
|
+
expect(d1).toBe(d2);
|
|
145
|
+
});
|
|
146
|
+
});
|
package/dist/Home.mdx
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import item from '../../package.json?raw';
|
|
2
|
-
|
|
3
|
-
<main style={{ textAlign: 'center' }}>
|
|
4
|
-
|
|
5
|
-
<img src="dodo-circle-6.png" style={{ width: 200, height: 'auto' }} />
|
|
6
|
-
|
|
7
|
-
# Dodo UI
|
|
8
|
-
|
|
9
|
-
<h3 style={{ fontWeight: 500 }}>v{JSON.parse(item)?.version}</h3>
|
|
10
|
-
|
|
11
|
-
<h3 style={{ fontWeight: 400 }}>
|
|
12
|
-
Opinionated UI framework for Svelte, based on [Bits UI](https://bits-ui.com/)
|
|
13
|
-
</h3>
|
|
14
|
-
|
|
15
|
-
### [Github](https://github.com/flightlesslabs/dodo-ui) - [npm](https://www.npmjs.com/package/@flightlesslabs/dodo-ui)
|
|
16
|
-
|
|
17
|
-
</main>
|
|
18
|
-
|
|
19
|
-
<br />
|
|
20
|
-
<br />
|
|
21
|
-
|
|
22
|
-
## 🚀 Installation
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
```bash
|
|
26
|
-
pnpm add bits-ui @internationalized/date @flightlesslabs/dodo-ui
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
We are using **bits-ui@{JSON.parse(item).devDependencies['bits-ui']}** internally
|
|
30
|
-
|
|
31
|
-
## 🎨 Add Styles
|
|
32
|
-
|
|
33
|
-
Import global styles in your root component. use the root layout (`+layout.svelte`) for SvelteKit.
|
|
34
|
-
|
|
35
|
-
```ts
|
|
36
|
-
import '@flightlesslabs/dodo-ui/styles/global.css';
|
|
37
|
-
import '@flightlesslabs/dodo-ui/styles/components.css';
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
## 🌗 Theme Setup
|
|
41
|
-
|
|
42
|
-
Wrap your application with the [Theme](?path=/docs/components-layout-theme--docs) component at the root level.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
```ts
|
|
46
|
-
import { Theme } from '@flightlesslabs/dodo-ui';
|
|
47
|
-
|
|
48
|
-
<Theme global>
|
|
49
|
-
<!-- Your app -->
|
|
50
|
-
</Theme>
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Recommended: Place this in your root layout (`+layout.svelte`) for SvelteKit.
|
|
54
|
-
|
|
55
|
-
✨ Usage
|
|
56
|
-
|
|
57
|
-
Start by importing components like [Button](?path=/docs/components-form-button--docs).
|
|
58
|
-
|
|
59
|
-
```ts
|
|
60
|
-
import { Button } '@flightlesslabs/dodo-ui';
|
|
61
|
-
|
|
62
|
-
<Button>Hello</Button>
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
## Explore more
|
|
66
|
-
|
|
67
|
-
- [Button](?path=/docs/components-form-button--docs)
|
|
68
|
-
- [TextInput](?path=/docs/components-form-textinput--docs)
|
|
69
|
-
- [Tailwind CSS Color Generator](https://uicolors.app/generate/1cc049)
|
|
@@ -1,178 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Button from './Button.svelte';
|
|
4
|
-
import type { ButtonProps } from './Button.svelte';
|
|
5
|
-
import type { ArgTypes } from 'storybook/internal/csf';
|
|
6
|
-
import { componentColorOptions } from '../../../attributes/color.js';
|
|
7
|
-
import { componentVariantOptions } from '../../../attributes/variant.js';
|
|
8
|
-
import { componentSizeOptions } from '../../../attributes/size.js';
|
|
9
|
-
import { componentRoundnessOptions } from '../../../attributes/roundness.js';
|
|
10
|
-
import Theme from '../../Layout/Theme/Theme.svelte';
|
|
11
|
-
|
|
12
|
-
const description = `
|
|
13
|
-
A flexible Button component based on bits-ui [button](https://bits-ui.com/docs/components/button).
|
|
14
|
-
\`\`\`ts
|
|
15
|
-
import { Button } from '@flightlesslabs/dodo-ui';
|
|
16
|
-
\`\`\`
|
|
17
|
-
`;
|
|
18
|
-
|
|
19
|
-
// ------------------------------
|
|
20
|
-
// Storybook ArgTypes
|
|
21
|
-
// ------------------------------
|
|
22
|
-
export const storyButtonArgTypes: Partial<ArgTypes<ButtonProps>> = {
|
|
23
|
-
// ------------------------------
|
|
24
|
-
// Core
|
|
25
|
-
// ------------------------------
|
|
26
|
-
children: { table: { category: 'API', subcategory: 'Base' } },
|
|
27
|
-
href: {
|
|
28
|
-
control: { type: 'text' },
|
|
29
|
-
description: 'Render as Anchor when provided',
|
|
30
|
-
table: { category: 'API', subcategory: 'Base' },
|
|
31
|
-
},
|
|
32
|
-
disabled: {
|
|
33
|
-
control: { type: 'boolean' },
|
|
34
|
-
description: 'Disable interactions',
|
|
35
|
-
table: { category: 'API', subcategory: 'Base' },
|
|
36
|
-
},
|
|
37
|
-
class: { table: { category: 'API', subcategory: 'Base' } },
|
|
38
|
-
type: { table: { category: 'API', subcategory: 'Base' } },
|
|
39
|
-
|
|
40
|
-
// ------------------------------
|
|
41
|
-
// Appearance
|
|
42
|
-
// ------------------------------
|
|
43
|
-
color: {
|
|
44
|
-
control: { type: 'select' },
|
|
45
|
-
options: componentColorOptions,
|
|
46
|
-
description: 'Color theme token',
|
|
47
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'primary' } },
|
|
48
|
-
},
|
|
49
|
-
variant: {
|
|
50
|
-
control: { type: 'select' },
|
|
51
|
-
options: componentVariantOptions,
|
|
52
|
-
description: 'Visual variant of the button',
|
|
53
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'solid' } },
|
|
54
|
-
},
|
|
55
|
-
size: {
|
|
56
|
-
control: { type: 'select' },
|
|
57
|
-
options: componentSizeOptions,
|
|
58
|
-
description: 'Visual size token',
|
|
59
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'normal' } },
|
|
60
|
-
},
|
|
61
|
-
roundness: {
|
|
62
|
-
control: { type: 'select' },
|
|
63
|
-
options: componentRoundnessOptions,
|
|
64
|
-
description: 'Border radius token',
|
|
65
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
66
|
-
},
|
|
67
|
-
fullWidth: {
|
|
68
|
-
control: { type: 'boolean' },
|
|
69
|
-
description: 'Stretch button to full container width',
|
|
70
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
71
|
-
},
|
|
72
|
-
compact: {
|
|
73
|
-
control: { type: 'boolean' },
|
|
74
|
-
description: 'Compact spacing (icon buttons)',
|
|
75
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
76
|
-
},
|
|
77
|
-
outline: {
|
|
78
|
-
control: { type: 'boolean' },
|
|
79
|
-
description: 'Render outlined style',
|
|
80
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
81
|
-
},
|
|
82
|
-
|
|
83
|
-
// ------------------------------
|
|
84
|
-
// Accessibility
|
|
85
|
-
// ------------------------------
|
|
86
|
-
'aria-label': {
|
|
87
|
-
control: { type: 'text' },
|
|
88
|
-
description: 'Accessible label (required for icon-only buttons)',
|
|
89
|
-
table: { category: 'API', subcategory: 'Accessibility' },
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
// ------------------------------
|
|
93
|
-
// Events (Svelte-style)
|
|
94
|
-
// ------------------------------
|
|
95
|
-
onclick: { table: { category: 'API', subcategory: 'Events' }, action: 'click' },
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// ------------------------------
|
|
99
|
-
// Storybook Meta
|
|
100
|
-
// ------------------------------
|
|
101
|
-
const { Story } = defineMeta({
|
|
102
|
-
component: Button,
|
|
103
|
-
tags: ['autodocs'],
|
|
104
|
-
argTypes: storyButtonArgTypes,
|
|
105
|
-
parameters: {
|
|
106
|
-
docs: {
|
|
107
|
-
description: {
|
|
108
|
-
component: description,
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
</script>
|
|
114
|
-
|
|
115
|
-
<!-- ------------------------------ -->
|
|
116
|
-
<!-- Stories -->
|
|
117
|
-
<!-- ------------------------------ -->
|
|
118
|
-
|
|
119
|
-
<Story name="Default">Click me!</Story>
|
|
120
|
-
|
|
121
|
-
<Story
|
|
122
|
-
name="Link Button"
|
|
123
|
-
args={{
|
|
124
|
-
href: 'https://www.w3schools.com/tags/tag_a.asp',
|
|
125
|
-
target: '_blank',
|
|
126
|
-
}}
|
|
127
|
-
>
|
|
128
|
-
Click me!
|
|
129
|
-
</Story>
|
|
130
|
-
|
|
131
|
-
<Story
|
|
132
|
-
name="OnClick (Actions)"
|
|
133
|
-
args={{
|
|
134
|
-
onclick: (e: Event) => {
|
|
135
|
-
const target = e.target as HTMLButtonElement;
|
|
136
|
-
alert('Button Clicked');
|
|
137
|
-
console.log('Button Clicked', target);
|
|
138
|
-
},
|
|
139
|
-
}}
|
|
140
|
-
>
|
|
141
|
-
Click me
|
|
142
|
-
</Story>
|
|
143
|
-
|
|
144
|
-
<Story name="Color" args={{ color: 'safe' }}>Click me</Story>
|
|
145
|
-
|
|
146
|
-
<Story name="Text" args={{ variant: 'text' }}>Click me!</Story>
|
|
147
|
-
|
|
148
|
-
<Story name="Outline" args={{ variant: 'text', outline: true }}>Click me!</Story>
|
|
149
|
-
|
|
150
|
-
<Story name="Size" args={{ size: 'large' }}>Click me!</Story>
|
|
151
|
-
|
|
152
|
-
<Story name="Disabled" args={{ disabled: true }}>Click me!</Story>
|
|
153
|
-
|
|
154
|
-
<Story name="Submit Button" args={{ type: 'submit' }}>Click me!</Story>
|
|
155
|
-
|
|
156
|
-
<Story name="Full Width" args={{ fullWidth: true }}>Click me!</Story>
|
|
157
|
-
|
|
158
|
-
<Story
|
|
159
|
-
name="Compact"
|
|
160
|
-
args={{
|
|
161
|
-
compact: true,
|
|
162
|
-
'aria-label': 'Add item',
|
|
163
|
-
}}
|
|
164
|
-
>
|
|
165
|
-
+
|
|
166
|
-
</Story>
|
|
167
|
-
|
|
168
|
-
<Story name="Light Theme" asChild>
|
|
169
|
-
<Theme type="light">
|
|
170
|
-
<Button>Click me!</Button>
|
|
171
|
-
</Theme>
|
|
172
|
-
</Story>
|
|
173
|
-
|
|
174
|
-
<Story name="Dark Theme" asChild globals={{ backgrounds: { value: 'dark' } }}>
|
|
175
|
-
<Theme type="dark">
|
|
176
|
-
<Button>Click me!</Button>
|
|
177
|
-
</Theme>
|
|
178
|
-
</Story>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import Button from './Button.svelte';
|
|
2
|
-
import type { ButtonProps } from './Button.svelte';
|
|
3
|
-
import type { ArgTypes } from 'storybook/internal/csf';
|
|
4
|
-
export declare const storyButtonArgTypes: Partial<ArgTypes<ButtonProps>>;
|
|
5
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
6
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
7
|
-
$$bindings?: Bindings;
|
|
8
|
-
} & Exports;
|
|
9
|
-
(internal: unknown, props: {
|
|
10
|
-
$$events?: Events;
|
|
11
|
-
$$slots?: Slots;
|
|
12
|
-
}): Exports & {
|
|
13
|
-
$set?: any;
|
|
14
|
-
$on?: any;
|
|
15
|
-
};
|
|
16
|
-
z_$$bindings?: Bindings;
|
|
17
|
-
}
|
|
18
|
-
declare const Button: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
19
|
-
[evt: string]: CustomEvent<any>;
|
|
20
|
-
}, {}, {}, string>;
|
|
21
|
-
type Button = InstanceType<typeof Button>;
|
|
22
|
-
export default Button;
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
<script module lang="ts">
|
|
2
|
-
import { defineMeta } from '@storybook/addon-svelte-csf';
|
|
3
|
-
import Checkbox from './Checkbox.svelte';
|
|
4
|
-
import type { CheckboxProps } from './Checkbox.svelte';
|
|
5
|
-
import type { ArgTypes } from 'storybook/internal/csf';
|
|
6
|
-
import { componentColorOptions } from '../../../attributes/color.js';
|
|
7
|
-
import { componentSizeOptions } from '../../../attributes/size.js';
|
|
8
|
-
import { componenRoundnessShapeOptions } from '../../../attributes/roundness.js';
|
|
9
|
-
import Theme from '../../Layout/Theme/Theme.svelte';
|
|
10
|
-
import { componentVariantOptions } from '../../../attributes/variant.js';
|
|
11
|
-
|
|
12
|
-
const description = `
|
|
13
|
-
A simple Checkbox component based on bits-ui [checkbox](https://bits-ui.com/docs/components/checkbox).
|
|
14
|
-
|
|
15
|
-
\`\`\`ts
|
|
16
|
-
import { Checkbox } from '@flightlesslabs/dodo-ui';
|
|
17
|
-
\`\`\`
|
|
18
|
-
`;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Storybook controls for Checkbox
|
|
22
|
-
*/
|
|
23
|
-
export const CheckboxArgTypes: Partial<ArgTypes<CheckboxProps>> = {
|
|
24
|
-
// ------------------------------
|
|
25
|
-
// Core
|
|
26
|
-
// ------------------------------
|
|
27
|
-
children: { table: { category: 'API', subcategory: 'Base' } },
|
|
28
|
-
disabled: {
|
|
29
|
-
control: { type: 'boolean' },
|
|
30
|
-
description: 'Disable interactions',
|
|
31
|
-
table: { category: 'API', subcategory: 'Base' },
|
|
32
|
-
},
|
|
33
|
-
class: { table: { category: 'API', subcategory: 'Base' } },
|
|
34
|
-
|
|
35
|
-
// ------------------------------
|
|
36
|
-
// Appearance
|
|
37
|
-
// ------------------------------
|
|
38
|
-
color: {
|
|
39
|
-
control: { type: 'select' },
|
|
40
|
-
options: componentColorOptions,
|
|
41
|
-
description: 'Color theme token',
|
|
42
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'neutral' } },
|
|
43
|
-
},
|
|
44
|
-
variant: {
|
|
45
|
-
control: { type: 'select' },
|
|
46
|
-
options: componentVariantOptions,
|
|
47
|
-
description: 'Visual variant of the Checkbox',
|
|
48
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'text' } },
|
|
49
|
-
},
|
|
50
|
-
size: {
|
|
51
|
-
control: { type: 'select' },
|
|
52
|
-
options: componentSizeOptions,
|
|
53
|
-
description: 'Visual size token',
|
|
54
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'normal' } },
|
|
55
|
-
},
|
|
56
|
-
roundness: {
|
|
57
|
-
control: { type: 'select' },
|
|
58
|
-
options: componenRoundnessShapeOptions,
|
|
59
|
-
description: 'Border radius token',
|
|
60
|
-
table: { category: 'API', subcategory: 'Appearance' },
|
|
61
|
-
},
|
|
62
|
-
outline: {
|
|
63
|
-
control: { type: 'boolean' },
|
|
64
|
-
description: 'Render outlined style',
|
|
65
|
-
table: { category: 'API', subcategory: 'Appearance', defaultValue: { summary: 'true' } },
|
|
66
|
-
},
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const { Story } = defineMeta({
|
|
70
|
-
component: Checkbox,
|
|
71
|
-
tags: ['autodocs'],
|
|
72
|
-
argTypes: CheckboxArgTypes,
|
|
73
|
-
parameters: {
|
|
74
|
-
docs: {
|
|
75
|
-
description: {
|
|
76
|
-
component: description,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
let myValue = $state<boolean>(true);
|
|
83
|
-
</script>
|
|
84
|
-
|
|
85
|
-
<!-- ------------------------------ -->
|
|
86
|
-
<!-- Stories -->
|
|
87
|
-
<!-- ------------------------------ -->
|
|
88
|
-
|
|
89
|
-
<Story name="Default" args={{ id: 'Default' }}>Check this text</Story>
|
|
90
|
-
|
|
91
|
-
<Story name="Controlled" asChild>
|
|
92
|
-
<Checkbox id="Checked" bind:checked={myValue}>Check this text</Checkbox>
|
|
93
|
-
</Story>
|
|
94
|
-
|
|
95
|
-
<Story
|
|
96
|
-
name="OnChange (Actions)"
|
|
97
|
-
args={{
|
|
98
|
-
id: 'OnChange_Action',
|
|
99
|
-
onCheckedChange: (checked: boolean) => {
|
|
100
|
-
alert('OnChange');
|
|
101
|
-
console.log('OnChange', checked);
|
|
102
|
-
},
|
|
103
|
-
}}
|
|
104
|
-
>
|
|
105
|
-
Check this text
|
|
106
|
-
</Story>
|
|
107
|
-
|
|
108
|
-
<Story name="Indeterminate" args={{ id: 'indeterminate', indeterminate: true }}>
|
|
109
|
-
Check this text
|
|
110
|
-
</Story>
|
|
111
|
-
|
|
112
|
-
<Story name="Color" args={{ id: 'Safe', color: 'safe' }}>Check this text</Story>
|
|
113
|
-
|
|
114
|
-
<Story name="Solid" args={{ id: 'Solid', variant: 'solid', checked: true }}>Check this text</Story>
|
|
115
|
-
|
|
116
|
-
<Story name="NoOutline" args={{ id: 'Outline', outline: false }}>Check this text</Story>
|
|
117
|
-
|
|
118
|
-
<Story name="Size" args={{ id: 'Size', size: 'large' }}>Check this text</Story>
|
|
119
|
-
|
|
120
|
-
<Story name="Disabled" args={{ disabled: true }}>Check this text</Story>
|
|
121
|
-
|
|
122
|
-
<Story name="Light Theme" asChild>
|
|
123
|
-
<Theme type="light">
|
|
124
|
-
<Checkbox id="Light_Theme">Check this text</Checkbox>
|
|
125
|
-
</Theme>
|
|
126
|
-
</Story>
|
|
127
|
-
|
|
128
|
-
<Story name="Dark Theme" asChild globals={{ backgrounds: { value: 'dark' } }}>
|
|
129
|
-
<Theme type="dark">
|
|
130
|
-
<Checkbox id="Dark_Theme">Check this text</Checkbox>
|
|
131
|
-
</Theme>
|
|
132
|
-
</Story>
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import Checkbox from './Checkbox.svelte';
|
|
2
|
-
import type { CheckboxProps } from './Checkbox.svelte';
|
|
3
|
-
import type { ArgTypes } from 'storybook/internal/csf';
|
|
4
|
-
/**
|
|
5
|
-
* Storybook controls for Checkbox
|
|
6
|
-
*/
|
|
7
|
-
export declare const CheckboxArgTypes: Partial<ArgTypes<CheckboxProps>>;
|
|
8
|
-
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
9
|
-
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
10
|
-
$$bindings?: Bindings;
|
|
11
|
-
} & Exports;
|
|
12
|
-
(internal: unknown, props: {
|
|
13
|
-
$$events?: Events;
|
|
14
|
-
$$slots?: Slots;
|
|
15
|
-
}): Exports & {
|
|
16
|
-
$set?: any;
|
|
17
|
-
$on?: any;
|
|
18
|
-
};
|
|
19
|
-
z_$$bindings?: Bindings;
|
|
20
|
-
}
|
|
21
|
-
declare const Checkbox: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
22
|
-
[evt: string]: CustomEvent<any>;
|
|
23
|
-
}, {}, {}, string>;
|
|
24
|
-
type Checkbox = InstanceType<typeof Checkbox>;
|
|
25
|
-
export default Checkbox;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
.dodo-ui-DatePicker {
|
|
2
|
-
button[data-popover-trigger] {
|
|
3
|
-
font-size: 1.4em;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
[data-date-field-input] {
|
|
7
|
-
display: flex;
|
|
8
|
-
align-items: center;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
[data-date-field-segment] {
|
|
12
|
-
height: 80%;
|
|
13
|
-
display: inline-flex;
|
|
14
|
-
align-items: center;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
[data-segment='literal'] {
|
|
18
|
-
color: var(--dodo-color-neutral-500);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// ----------------------------------------
|
|
22
|
-
// Sizes
|
|
23
|
-
// ----------------------------------------
|
|
24
|
-
&.size {
|
|
25
|
-
&--normal {
|
|
26
|
-
button[data-popover-trigger] {
|
|
27
|
-
margin: 0 calc(var(--dodo-ui-space) / 2.5);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
[data-date-field-segment] {
|
|
31
|
-
padding: 0 calc(var(--dodo-ui-space) / 3);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
&--small {
|
|
36
|
-
button[data-popover-trigger] {
|
|
37
|
-
margin: 0 calc(var(--dodo-ui-space--small) / 2.5);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
[data-date-field-segment] {
|
|
41
|
-
padding: 0 calc(var(--dodo-ui-space-small) / 3);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
&--large {
|
|
46
|
-
button[data-popover-trigger] {
|
|
47
|
-
margin: 0 calc(var(--dodo-ui-space--large) / 2.5);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
[data-date-field-segment] {
|
|
51
|
-
padding: 0 calc(var(--dodo-ui-space-large) / 3);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|