intelliwaketssveltekitv25 1.0.81 → 1.0.82
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/INTEGRATION.md +574 -0
- package/README.md +199 -45
- package/dist/ArrayTable.stories.js +215 -0
- package/dist/ArrayTable.svelte +46 -0
- package/dist/ArrayTable.svelte.d.ts +44 -0
- package/dist/DropDown.stories.d.ts +96 -0
- package/dist/DropDown.stories.js +192 -0
- package/dist/DropDown.svelte +32 -0
- package/dist/DropDown.svelte.d.ts +30 -0
- package/dist/InputNumber.stories.d.ts +122 -0
- package/dist/InputNumber.stories.js +186 -0
- package/dist/InputNumber.svelte +52 -0
- package/dist/InputNumber.svelte.d.ts +27 -0
- package/dist/Modal.stories.d.ts +114 -0
- package/dist/Modal.stories.js +139 -0
- package/dist/Modal.svelte +34 -3
- package/dist/Modal.svelte.d.ts +35 -3
- package/dist/MultiSelect.stories.js +338 -0
- package/dist/MultiSelect.svelte +81 -0
- package/dist/MultiSelect.svelte.d.ts +38 -0
- package/dist/Switch.stories.d.ts +81 -0
- package/dist/Switch.stories.js +99 -0
- package/dist/Switch.svelte +40 -0
- package/dist/Switch.svelte.d.ts +26 -0
- package/dist/TextArea.stories.d.ts +180 -0
- package/dist/TextArea.stories.js +216 -0
- package/dist/TextArea.svelte +32 -0
- package/dist/TextArea.svelte.d.ts +24 -0
- package/dist/app.css +1 -1
- package/llm.txt +1635 -0
- package/package.json +6 -2
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
import DropDown from './DropDown.svelte';
|
|
2
|
+
import { faEdit, faTrash, faCopy, faDownload, faFile } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Components/DropDown',
|
|
5
|
+
component: DropDown,
|
|
6
|
+
tags: ['autodocs'],
|
|
7
|
+
argTypes: {
|
|
8
|
+
show: {
|
|
9
|
+
control: 'boolean',
|
|
10
|
+
description: 'Control dropdown open/closed state'
|
|
11
|
+
},
|
|
12
|
+
ddActions: {
|
|
13
|
+
control: 'object',
|
|
14
|
+
description: 'Array of menu items/actions (IDDAction[])'
|
|
15
|
+
},
|
|
16
|
+
buttonTitle: {
|
|
17
|
+
control: 'text',
|
|
18
|
+
description: 'Button text (if not using button snippet)'
|
|
19
|
+
},
|
|
20
|
+
noCaret: {
|
|
21
|
+
control: 'boolean',
|
|
22
|
+
description: 'Hide the dropdown arrow icon'
|
|
23
|
+
},
|
|
24
|
+
buttonClass: {
|
|
25
|
+
control: 'text',
|
|
26
|
+
description: 'CSS classes for the button'
|
|
27
|
+
},
|
|
28
|
+
inputControl: {
|
|
29
|
+
control: 'boolean',
|
|
30
|
+
description: 'Style button as input control'
|
|
31
|
+
},
|
|
32
|
+
fullBlock: {
|
|
33
|
+
control: 'boolean',
|
|
34
|
+
description: 'Make button full width'
|
|
35
|
+
},
|
|
36
|
+
sameSize: {
|
|
37
|
+
control: 'boolean',
|
|
38
|
+
description: 'Make dropdown menu same width as button'
|
|
39
|
+
},
|
|
40
|
+
disabled: {
|
|
41
|
+
control: 'boolean',
|
|
42
|
+
description: 'Disable the dropdown'
|
|
43
|
+
},
|
|
44
|
+
hidden: {
|
|
45
|
+
control: 'boolean',
|
|
46
|
+
description: 'Hide the dropdown'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
export default meta;
|
|
51
|
+
const basicActions = [
|
|
52
|
+
{ title: 'Edit', faProps: { icon: faEdit }, action: () => alert('Edit clicked') },
|
|
53
|
+
{ title: 'Copy', faProps: { icon: faCopy }, action: () => alert('Copy clicked') },
|
|
54
|
+
{ divider: true },
|
|
55
|
+
{ title: 'Delete', faProps: { icon: faTrash }, action: () => alert('Delete clicked') }
|
|
56
|
+
];
|
|
57
|
+
export const Default = {
|
|
58
|
+
args: {
|
|
59
|
+
buttonTitle: 'Actions',
|
|
60
|
+
ddActions: basicActions
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
export const WithActiveItem = {
|
|
64
|
+
args: {
|
|
65
|
+
buttonTitle: 'Option 2',
|
|
66
|
+
inputControl: true,
|
|
67
|
+
ddActions: [
|
|
68
|
+
{ title: 'Option 1', action: () => { } },
|
|
69
|
+
{ title: 'Option 2', active: true, action: () => { } },
|
|
70
|
+
{ title: 'Option 3', action: () => { } }
|
|
71
|
+
]
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
export const WithDisabledItems = {
|
|
75
|
+
args: {
|
|
76
|
+
buttonTitle: 'Actions',
|
|
77
|
+
ddActions: [
|
|
78
|
+
{ title: 'Available Action', action: () => { } },
|
|
79
|
+
{ title: 'Disabled Action', disabled: true, action: () => { } },
|
|
80
|
+
{ title: 'Another Action', action: () => { } }
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
export const WithHeaders = {
|
|
85
|
+
args: {
|
|
86
|
+
buttonTitle: 'Options',
|
|
87
|
+
ddActions: [
|
|
88
|
+
{ title: 'File Operations', header: true },
|
|
89
|
+
{ title: 'Open', action: () => { } },
|
|
90
|
+
{ title: 'Save', action: () => { } },
|
|
91
|
+
{ divider: true },
|
|
92
|
+
{ title: 'Edit Operations', header: true },
|
|
93
|
+
{ title: 'Cut', action: () => { } },
|
|
94
|
+
{ title: 'Copy', action: () => { } }
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export const WithGrouping = {
|
|
99
|
+
args: {
|
|
100
|
+
buttonTitle: 'Grouped',
|
|
101
|
+
ddActions: [
|
|
102
|
+
{ title: 'Item 1', headerGroup: 'Group A', action: () => { } },
|
|
103
|
+
{ title: 'Item 2', headerGroup: 'Group A', action: () => { } },
|
|
104
|
+
{ title: 'Item 3', headerGroup: 'Group B', action: () => { } },
|
|
105
|
+
{ title: 'Item 4', headerGroup: 'Group B', action: () => { } }
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
export const WithNavigation = {
|
|
110
|
+
args: {
|
|
111
|
+
buttonTitle: 'Navigate',
|
|
112
|
+
ddActions: [
|
|
113
|
+
{ title: 'Dashboard', href: '/dashboard' },
|
|
114
|
+
{ title: 'Settings', href: '/settings' },
|
|
115
|
+
{ divider: true },
|
|
116
|
+
{ title: 'Logout', href: '/logout', hrefReplace: true }
|
|
117
|
+
]
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
export const WithDownloads = {
|
|
121
|
+
args: {
|
|
122
|
+
buttonTitle: 'Export',
|
|
123
|
+
ddActions: [
|
|
124
|
+
{
|
|
125
|
+
title: 'Export as CSV',
|
|
126
|
+
faProps: { icon: faFile },
|
|
127
|
+
hrefDownload: '/api/export?format=csv',
|
|
128
|
+
hrefDownloadFilename: 'data.csv'
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
title: 'Export as PDF',
|
|
132
|
+
faProps: { icon: faFile },
|
|
133
|
+
hrefDownload: '/api/export?format=pdf',
|
|
134
|
+
hrefDownloadFilename: 'data.pdf'
|
|
135
|
+
}
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
export const WithAlternateActions = {
|
|
140
|
+
args: {
|
|
141
|
+
buttonTitle: 'Files',
|
|
142
|
+
ddActions: [
|
|
143
|
+
{
|
|
144
|
+
title: 'document.pdf',
|
|
145
|
+
faProps: { icon: faFile },
|
|
146
|
+
action: () => alert('Open document'),
|
|
147
|
+
alternateAction: () => alert('Download document'),
|
|
148
|
+
alternateFAProps: { icon: faDownload }
|
|
149
|
+
}
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
export const AsSelectReplacement = {
|
|
154
|
+
args: {
|
|
155
|
+
buttonTitle: 'Medium',
|
|
156
|
+
inputControl: true,
|
|
157
|
+
fullBlock: true,
|
|
158
|
+
sameSize: true,
|
|
159
|
+
ddActions: [
|
|
160
|
+
{ title: 'Small', action: () => { } },
|
|
161
|
+
{ title: 'Medium', active: true, action: () => { } },
|
|
162
|
+
{ title: 'Large', action: () => { } },
|
|
163
|
+
{ title: 'X-Large', action: () => { } }
|
|
164
|
+
]
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
export const Disabled = {
|
|
168
|
+
args: {
|
|
169
|
+
buttonTitle: 'Actions',
|
|
170
|
+
disabled: true,
|
|
171
|
+
ddActions: basicActions
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
export const NoCaret = {
|
|
175
|
+
args: {
|
|
176
|
+
buttonTitle: 'Menu',
|
|
177
|
+
noCaret: true,
|
|
178
|
+
ddActions: basicActions
|
|
179
|
+
}
|
|
180
|
+
};
|
|
181
|
+
export const FullWidth = {
|
|
182
|
+
args: {
|
|
183
|
+
buttonTitle: 'Select Option',
|
|
184
|
+
fullBlock: true,
|
|
185
|
+
inputControl: true,
|
|
186
|
+
ddActions: [
|
|
187
|
+
{ title: 'Option 1', action: () => { } },
|
|
188
|
+
{ title: 'Option 2', action: () => { } },
|
|
189
|
+
{ title: 'Option 3', action: () => { } }
|
|
190
|
+
]
|
|
191
|
+
}
|
|
192
|
+
};
|
package/dist/DropDown.svelte
CHANGED
|
@@ -1,3 +1,35 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Rich dropdown menu with keyboard navigation, icons, search, and action handling.
|
|
4
|
+
Replaces native <select> elements and provides context menus, action lists, and navigation dropdowns.
|
|
5
|
+
|
|
6
|
+
@example
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { DropDown } from 'intelliwaketssveltekitv25';
|
|
10
|
+
import { faEdit, faTrash } from '@fortawesome/free-solid-svg-icons';
|
|
11
|
+
|
|
12
|
+
const actions = [
|
|
13
|
+
{ title: 'Edit', faProps: { icon: faEdit }, action: () => editItem() },
|
|
14
|
+
{ title: 'Delete', faProps: { icon: faTrash }, action: () => deleteItem() }
|
|
15
|
+
];
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<DropDown buttonTitle="Actions" ddActions={actions} />
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
@remarks
|
|
22
|
+
- Keyboard navigation: Arrow keys, Enter, Tab, type-to-search
|
|
23
|
+
- Supports icons (FontAwesome), dividers, headers, and grouping
|
|
24
|
+
- Action handlers, href navigation, and download links
|
|
25
|
+
- Auto-positioning based on viewport space
|
|
26
|
+
- Active item highlighting for selection scenarios
|
|
27
|
+
- Alternate actions (two buttons per row)
|
|
28
|
+
|
|
29
|
+
@see DropDownControl - Lower-level dropdown control (used internally)
|
|
30
|
+
@see MultiSelect - For selecting multiple options from a list
|
|
31
|
+
-->
|
|
32
|
+
|
|
1
33
|
<script lang='ts'>
|
|
2
34
|
import DropDownControl from './DropDownControl.svelte'
|
|
3
35
|
import { type Snippet, tick } from 'svelte'
|
|
@@ -23,6 +23,36 @@ type $$ComponentProps = {
|
|
|
23
23
|
dataColor?: TDefaultColorPalate;
|
|
24
24
|
clientWidth?: number;
|
|
25
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Rich dropdown menu with keyboard navigation, icons, search, and action handling.
|
|
28
|
+
* Replaces native <select> elements and provides context menus, action lists, and navigation dropdowns.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```svelte
|
|
32
|
+
* <script>
|
|
33
|
+
* import { DropDown } from 'intelliwaketssveltekitv25';
|
|
34
|
+
* import { faEdit, faTrash } from '@fortawesome/free-solid-svg-icons';
|
|
35
|
+
*
|
|
36
|
+
* const actions = [
|
|
37
|
+
* { title: 'Edit', faProps: { icon: faEdit }, action: () => editItem() },
|
|
38
|
+
* { title: 'Delete', faProps: { icon: faTrash }, action: () => deleteItem() }
|
|
39
|
+
* ];
|
|
40
|
+
* </script>
|
|
41
|
+
*
|
|
42
|
+
* <DropDown buttonTitle="Actions" ddActions={actions} />
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* - Keyboard navigation: Arrow keys, Enter, Tab, type-to-search
|
|
47
|
+
* - Supports icons (FontAwesome), dividers, headers, and grouping
|
|
48
|
+
* - Action handlers, href navigation, and download links
|
|
49
|
+
* - Auto-positioning based on viewport space
|
|
50
|
+
* - Active item highlighting for selection scenarios
|
|
51
|
+
* - Alternate actions (two buttons per row)
|
|
52
|
+
*
|
|
53
|
+
* @see DropDownControl - Lower-level dropdown control (used internally)
|
|
54
|
+
* @see MultiSelect - For selecting multiple options from a list
|
|
55
|
+
*/
|
|
26
56
|
declare const DropDown: import("svelte").Component<$$ComponentProps, {}, "show" | "clientWidth">;
|
|
27
57
|
type DropDown = ReturnType<typeof DropDown>;
|
|
28
58
|
export default DropDown;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import type { StoryObj } from '@storybook/svelte';
|
|
2
|
+
type InputNumberProps = {
|
|
3
|
+
value?: number | null;
|
|
4
|
+
currency?: boolean;
|
|
5
|
+
percent?: boolean;
|
|
6
|
+
fixedDecimals?: number;
|
|
7
|
+
minDecimals?: number;
|
|
8
|
+
maxDecimals?: number;
|
|
9
|
+
min?: number;
|
|
10
|
+
max?: number;
|
|
11
|
+
allowNegative?: boolean;
|
|
12
|
+
zeroBlank?: boolean;
|
|
13
|
+
zeroDash?: boolean;
|
|
14
|
+
prefix?: string;
|
|
15
|
+
suffix?: string;
|
|
16
|
+
delayChange?: boolean | number | 'blur';
|
|
17
|
+
widthNumbers?: number;
|
|
18
|
+
disabled?: boolean;
|
|
19
|
+
readonly?: boolean;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
};
|
|
23
|
+
declare const meta: {
|
|
24
|
+
title: string;
|
|
25
|
+
component: import("svelte").Component<import("./Functions").TInputNumberAttributes, {}, "value" | "thisRef">;
|
|
26
|
+
tags: string[];
|
|
27
|
+
argTypes: {
|
|
28
|
+
value: {
|
|
29
|
+
control: "number";
|
|
30
|
+
description: string;
|
|
31
|
+
};
|
|
32
|
+
currency: {
|
|
33
|
+
control: "boolean";
|
|
34
|
+
description: string;
|
|
35
|
+
};
|
|
36
|
+
percent: {
|
|
37
|
+
control: "boolean";
|
|
38
|
+
description: string;
|
|
39
|
+
};
|
|
40
|
+
fixedDecimals: {
|
|
41
|
+
control: "number";
|
|
42
|
+
description: string;
|
|
43
|
+
};
|
|
44
|
+
minDecimals: {
|
|
45
|
+
control: "number";
|
|
46
|
+
description: string;
|
|
47
|
+
};
|
|
48
|
+
maxDecimals: {
|
|
49
|
+
control: "number";
|
|
50
|
+
description: string;
|
|
51
|
+
};
|
|
52
|
+
min: {
|
|
53
|
+
control: "number";
|
|
54
|
+
description: string;
|
|
55
|
+
};
|
|
56
|
+
max: {
|
|
57
|
+
control: "number";
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
allowNegative: {
|
|
61
|
+
control: "boolean";
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
zeroBlank: {
|
|
65
|
+
control: "boolean";
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
zeroDash: {
|
|
69
|
+
control: "boolean";
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
prefix: {
|
|
73
|
+
control: "text";
|
|
74
|
+
description: string;
|
|
75
|
+
};
|
|
76
|
+
suffix: {
|
|
77
|
+
control: "text";
|
|
78
|
+
description: string;
|
|
79
|
+
};
|
|
80
|
+
delayChange: {
|
|
81
|
+
control: "boolean";
|
|
82
|
+
description: string;
|
|
83
|
+
};
|
|
84
|
+
widthNumbers: {
|
|
85
|
+
control: "number";
|
|
86
|
+
description: string;
|
|
87
|
+
};
|
|
88
|
+
disabled: {
|
|
89
|
+
control: "boolean";
|
|
90
|
+
description: string;
|
|
91
|
+
};
|
|
92
|
+
readonly: {
|
|
93
|
+
control: "boolean";
|
|
94
|
+
description: string;
|
|
95
|
+
};
|
|
96
|
+
required: {
|
|
97
|
+
control: "boolean";
|
|
98
|
+
description: string;
|
|
99
|
+
};
|
|
100
|
+
placeholder: {
|
|
101
|
+
control: "text";
|
|
102
|
+
description: string;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
export default meta;
|
|
107
|
+
type Story = StoryObj<InputNumberProps>;
|
|
108
|
+
export declare const Default: Story;
|
|
109
|
+
export declare const Currency: Story;
|
|
110
|
+
export declare const Percentage: Story;
|
|
111
|
+
export declare const IntegerOnly: Story;
|
|
112
|
+
export declare const WithMinMax: Story;
|
|
113
|
+
export declare const AllowNegative: Story;
|
|
114
|
+
export declare const ZeroBlank: Story;
|
|
115
|
+
export declare const ZeroDash: Story;
|
|
116
|
+
export declare const CustomSuffix: Story;
|
|
117
|
+
export declare const CustomPrefix: Story;
|
|
118
|
+
export declare const Disabled: Story;
|
|
119
|
+
export declare const Readonly: Story;
|
|
120
|
+
export declare const WithDelayChange: Story;
|
|
121
|
+
export declare const WithWidth: Story;
|
|
122
|
+
export declare const Required: Story;
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import InputNumber from './InputNumber.svelte';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Components/InputNumber',
|
|
4
|
+
component: InputNumber,
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
argTypes: {
|
|
7
|
+
value: {
|
|
8
|
+
control: 'number',
|
|
9
|
+
description: 'Current numeric value (two-way bindable)'
|
|
10
|
+
},
|
|
11
|
+
currency: {
|
|
12
|
+
control: 'boolean',
|
|
13
|
+
description: 'Format as currency (adds $ prefix, 2 decimals)'
|
|
14
|
+
},
|
|
15
|
+
percent: {
|
|
16
|
+
control: 'boolean',
|
|
17
|
+
description: 'Format as percentage (adds % suffix, stores as decimal 0-1, displays as 0-100)'
|
|
18
|
+
},
|
|
19
|
+
fixedDecimals: {
|
|
20
|
+
control: 'number',
|
|
21
|
+
description: 'Force exact number of decimal places'
|
|
22
|
+
},
|
|
23
|
+
minDecimals: {
|
|
24
|
+
control: 'number',
|
|
25
|
+
description: 'Minimum decimal places to show'
|
|
26
|
+
},
|
|
27
|
+
maxDecimals: {
|
|
28
|
+
control: 'number',
|
|
29
|
+
description: 'Maximum decimal places allowed'
|
|
30
|
+
},
|
|
31
|
+
min: {
|
|
32
|
+
control: 'number',
|
|
33
|
+
description: 'Minimum allowed value'
|
|
34
|
+
},
|
|
35
|
+
max: {
|
|
36
|
+
control: 'number',
|
|
37
|
+
description: 'Maximum allowed value'
|
|
38
|
+
},
|
|
39
|
+
allowNegative: {
|
|
40
|
+
control: 'boolean',
|
|
41
|
+
description: 'Allow negative numbers'
|
|
42
|
+
},
|
|
43
|
+
zeroBlank: {
|
|
44
|
+
control: 'boolean',
|
|
45
|
+
description: 'Display empty string instead of 0'
|
|
46
|
+
},
|
|
47
|
+
zeroDash: {
|
|
48
|
+
control: 'boolean',
|
|
49
|
+
description: 'Display "-" instead of 0'
|
|
50
|
+
},
|
|
51
|
+
prefix: {
|
|
52
|
+
control: 'text',
|
|
53
|
+
description: 'Custom prefix (overrides currency $)'
|
|
54
|
+
},
|
|
55
|
+
suffix: {
|
|
56
|
+
control: 'text',
|
|
57
|
+
description: 'Custom suffix (overrides percent %)'
|
|
58
|
+
},
|
|
59
|
+
delayChange: {
|
|
60
|
+
control: 'boolean',
|
|
61
|
+
description: 'Delay before updating value: true=1500ms, number=custom ms, "blur"=only on blur'
|
|
62
|
+
},
|
|
63
|
+
widthNumbers: {
|
|
64
|
+
control: 'number',
|
|
65
|
+
description: 'Set input width based on number of digits'
|
|
66
|
+
},
|
|
67
|
+
disabled: {
|
|
68
|
+
control: 'boolean',
|
|
69
|
+
description: 'Disable the input'
|
|
70
|
+
},
|
|
71
|
+
readonly: {
|
|
72
|
+
control: 'boolean',
|
|
73
|
+
description: 'Make input readonly'
|
|
74
|
+
},
|
|
75
|
+
required: {
|
|
76
|
+
control: 'boolean',
|
|
77
|
+
description: 'Mark as required field'
|
|
78
|
+
},
|
|
79
|
+
placeholder: {
|
|
80
|
+
control: 'text',
|
|
81
|
+
description: 'Placeholder text'
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
export default meta;
|
|
86
|
+
export const Default = {
|
|
87
|
+
args: {
|
|
88
|
+
value: 0
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
export const Currency = {
|
|
92
|
+
args: {
|
|
93
|
+
value: 29.99,
|
|
94
|
+
currency: true
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
export const Percentage = {
|
|
98
|
+
args: {
|
|
99
|
+
value: 0.08, // Stored as 0.08, displays as 8%
|
|
100
|
+
percent: true
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
export const IntegerOnly = {
|
|
104
|
+
args: {
|
|
105
|
+
value: 42,
|
|
106
|
+
fixedDecimals: 0
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
export const WithMinMax = {
|
|
110
|
+
args: {
|
|
111
|
+
value: 5,
|
|
112
|
+
min: 1,
|
|
113
|
+
max: 10
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
export const AllowNegative = {
|
|
117
|
+
args: {
|
|
118
|
+
value: -50,
|
|
119
|
+
currency: true,
|
|
120
|
+
allowNegative: true
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
export const ZeroBlank = {
|
|
124
|
+
args: {
|
|
125
|
+
value: 0,
|
|
126
|
+
currency: true,
|
|
127
|
+
zeroBlank: true
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
export const ZeroDash = {
|
|
131
|
+
args: {
|
|
132
|
+
value: 0,
|
|
133
|
+
currency: true,
|
|
134
|
+
zeroDash: true
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
export const CustomSuffix = {
|
|
138
|
+
args: {
|
|
139
|
+
value: 72.5,
|
|
140
|
+
suffix: 'kg',
|
|
141
|
+
maxDecimals: 2
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
export const CustomPrefix = {
|
|
145
|
+
args: {
|
|
146
|
+
value: 100,
|
|
147
|
+
prefix: '€',
|
|
148
|
+
fixedDecimals: 2
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
export const Disabled = {
|
|
152
|
+
args: {
|
|
153
|
+
value: 99.99,
|
|
154
|
+
currency: true,
|
|
155
|
+
disabled: true
|
|
156
|
+
}
|
|
157
|
+
};
|
|
158
|
+
export const Readonly = {
|
|
159
|
+
args: {
|
|
160
|
+
value: 1234.56,
|
|
161
|
+
currency: true,
|
|
162
|
+
readonly: true
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
export const WithDelayChange = {
|
|
166
|
+
args: {
|
|
167
|
+
value: 100,
|
|
168
|
+
currency: true,
|
|
169
|
+
delayChange: true
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
export const WithWidth = {
|
|
173
|
+
args: {
|
|
174
|
+
value: 12345,
|
|
175
|
+
widthNumbers: 5,
|
|
176
|
+
fixedDecimals: 0
|
|
177
|
+
}
|
|
178
|
+
};
|
|
179
|
+
export const Required = {
|
|
180
|
+
args: {
|
|
181
|
+
value: null,
|
|
182
|
+
currency: true,
|
|
183
|
+
required: true,
|
|
184
|
+
placeholder: 'Enter amount'
|
|
185
|
+
}
|
|
186
|
+
};
|
package/dist/InputNumber.svelte
CHANGED
|
@@ -1,3 +1,32 @@
|
|
|
1
|
+
<!--
|
|
2
|
+
@component
|
|
3
|
+
Formatted numeric input with automatic currency, percentage, and decimal handling.
|
|
4
|
+
Replaces native <input type="number"> for all numeric data entry.
|
|
5
|
+
|
|
6
|
+
@example
|
|
7
|
+
```svelte
|
|
8
|
+
<script>
|
|
9
|
+
import { InputNumber } from 'intelliwaketssveltekitv25';
|
|
10
|
+
let price = $state(29.99);
|
|
11
|
+
let taxRate = $state(0.08); // Stored as decimal, displays as 8%
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<InputNumber bind:value={price} currency />
|
|
15
|
+
<InputNumber bind:value={taxRate} percent />
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
@remarks
|
|
19
|
+
- Uses Svelte 5 $bindable rune for two-way binding of value
|
|
20
|
+
- Percent mode: stores as decimal (0-1), displays as whole number (0-100)
|
|
21
|
+
- Supports delayed updates via delayChange for performance optimization
|
|
22
|
+
- Automatically enforces min/max constraints
|
|
23
|
+
- Handles prefix ($) and suffix (%) with proper spacing
|
|
24
|
+
- Configurable decimal precision (fixed, min, max)
|
|
25
|
+
|
|
26
|
+
@see InputNumberScroll - Numeric input with scroll wheel support
|
|
27
|
+
@see NumberFormat - Display-only formatted number component
|
|
28
|
+
-->
|
|
29
|
+
|
|
1
30
|
<script lang="ts">
|
|
2
31
|
import {
|
|
3
32
|
CleanNumber,
|
|
@@ -10,28 +39,51 @@
|
|
|
10
39
|
import { useActions } from './useActions'
|
|
11
40
|
|
|
12
41
|
let {
|
|
42
|
+
/** Current numeric value (two-way bindable) */
|
|
13
43
|
value = $bindable(),
|
|
44
|
+
/** Additional CSS classes for wrapper div */
|
|
14
45
|
class: clazz = '',
|
|
46
|
+
/** CSS classes for input element */
|
|
15
47
|
inputClass = '',
|
|
48
|
+
/** Callback when value changes */
|
|
16
49
|
onchange,
|
|
50
|
+
/** Format as currency (adds $ prefix, 2 decimals) */
|
|
17
51
|
currency,
|
|
52
|
+
/** Format as percentage (adds % suffix, stores as decimal 0-1, displays as 0-100) */
|
|
18
53
|
percent,
|
|
54
|
+
/** Force exact number of decimal places */
|
|
19
55
|
fixedDecimals,
|
|
56
|
+
/** Minimum decimal places to show */
|
|
20
57
|
minDecimals,
|
|
58
|
+
/** Maximum decimal places allowed */
|
|
21
59
|
maxDecimals,
|
|
60
|
+
/** Display empty string instead of 0 */
|
|
22
61
|
zeroBlank,
|
|
62
|
+
/** Display "-" instead of 0 */
|
|
23
63
|
zeroDash,
|
|
64
|
+
/** Display empty string for null values */
|
|
24
65
|
nullBlank,
|
|
66
|
+
/** Display "-" for null values */
|
|
25
67
|
nullDash,
|
|
68
|
+
/** Custom prefix (overrides currency $) */
|
|
26
69
|
prefix,
|
|
70
|
+
/** Custom suffix (overrides percent %) */
|
|
27
71
|
suffix,
|
|
72
|
+
/** Minimum allowed value */
|
|
28
73
|
min,
|
|
74
|
+
/** Maximum allowed value */
|
|
29
75
|
max,
|
|
76
|
+
/** Allow negative numbers */
|
|
30
77
|
allowNegative,
|
|
78
|
+
/** Delay before updating value: true=1500ms, number=custom ms, 'blur'=only on blur */
|
|
31
79
|
delayChange = false,
|
|
80
|
+
/** Svelte actions array */
|
|
32
81
|
use = [],
|
|
82
|
+
/** Reference to input element (bindable) */
|
|
33
83
|
thisRef = $bindable<HTMLInputElement>(),
|
|
84
|
+
/** Set input width based on number of digits */
|
|
34
85
|
widthNumbers,
|
|
86
|
+
/** Standard HTML input attributes (disabled, readonly, required, name, placeholder, etc.) */
|
|
35
87
|
...otherProps
|
|
36
88
|
}: TInputNumberAttributes = $props()
|
|
37
89
|
|
|
@@ -1,4 +1,31 @@
|
|
|
1
1
|
import { type TInputNumberAttributes } from './Functions';
|
|
2
|
+
/**
|
|
3
|
+
* Formatted numeric input with automatic currency, percentage, and decimal handling.
|
|
4
|
+
* Replaces native <input type="number"> for all numeric data entry.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```svelte
|
|
8
|
+
* <script>
|
|
9
|
+
* import { InputNumber } from 'intelliwaketssveltekitv25';
|
|
10
|
+
* let price = $state(29.99);
|
|
11
|
+
* let taxRate = $state(0.08); // Stored as decimal, displays as 8%
|
|
12
|
+
* </script>
|
|
13
|
+
*
|
|
14
|
+
* <InputNumber bind:value={price} currency />
|
|
15
|
+
* <InputNumber bind:value={taxRate} percent />
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* @remarks
|
|
19
|
+
* - Uses Svelte 5 $bindable rune for two-way binding of value
|
|
20
|
+
* - Percent mode: stores as decimal (0-1), displays as whole number (0-100)
|
|
21
|
+
* - Supports delayed updates via delayChange for performance optimization
|
|
22
|
+
* - Automatically enforces min/max constraints
|
|
23
|
+
* - Handles prefix ($) and suffix (%) with proper spacing
|
|
24
|
+
* - Configurable decimal precision (fixed, min, max)
|
|
25
|
+
*
|
|
26
|
+
* @see InputNumberScroll - Numeric input with scroll wheel support
|
|
27
|
+
* @see NumberFormat - Display-only formatted number component
|
|
28
|
+
*/
|
|
2
29
|
declare const InputNumber: import("svelte").Component<TInputNumberAttributes, {}, "value" | "thisRef">;
|
|
3
30
|
type InputNumber = ReturnType<typeof InputNumber>;
|
|
4
31
|
export default InputNumber;
|