intelliwaketssveltekitv25 1.0.80 → 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.
@@ -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
+ };
@@ -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;
@@ -0,0 +1,114 @@
1
+ import type { StoryObj } from '@storybook/svelte';
2
+ type ModalProps = {
3
+ show: unknown;
4
+ noShowValue?: unknown;
5
+ width?: string;
6
+ cancelButton?: string | false;
7
+ okButton?: string | false;
8
+ okDisabled?: boolean;
9
+ noCloseOnOK?: boolean;
10
+ disable?: boolean;
11
+ okType?: 'submit' | 'button';
12
+ overflowY?: 'auto' | 'visible' | 'hidden';
13
+ borderFooter?: boolean;
14
+ };
15
+ declare const meta: {
16
+ title: string;
17
+ component: import("svelte").Component<{
18
+ header?: import("svelte").Snippet;
19
+ body?: import("svelte").Snippet;
20
+ leftFooter?: import("svelte").Snippet;
21
+ centerFooter?: import("svelte").Snippet;
22
+ rightFooter?: import("svelte").Snippet;
23
+ show: unknown;
24
+ noShowValue?: unknown;
25
+ forceNoShow?: boolean;
26
+ width?: string;
27
+ cancelButton?: string | false;
28
+ okButton?: string | false;
29
+ okFAProps?: import("./Definitions").IFAProps;
30
+ okActionNotOnEnter?: boolean;
31
+ okDisabled?: boolean;
32
+ noCloseOnOK?: boolean;
33
+ overflowY?: "auto" | "visible" | "hidden";
34
+ disable?: boolean;
35
+ okType?: "submit" | "button";
36
+ marginForStickyHeader?: boolean;
37
+ okButtonWrap?: boolean;
38
+ class?: string;
39
+ okColor?: TDefaultColorPalate | null;
40
+ color?: TDefaultColorPalate | null;
41
+ classHeader?: string;
42
+ classBody?: string;
43
+ classFooter?: string;
44
+ classButton?: string;
45
+ borderFooter?: boolean;
46
+ onOK?: () => void;
47
+ onOKPromise?: () => Promise<unknown>;
48
+ onCancel?: () => void;
49
+ onClose?: () => void;
50
+ }, {}, "show">;
51
+ tags: string[];
52
+ argTypes: {
53
+ show: {
54
+ control: "boolean";
55
+ description: string;
56
+ };
57
+ noShowValue: {
58
+ control: "text";
59
+ description: string;
60
+ };
61
+ width: {
62
+ control: "text";
63
+ description: string;
64
+ };
65
+ cancelButton: {
66
+ control: "text";
67
+ description: string;
68
+ };
69
+ okButton: {
70
+ control: "text";
71
+ description: string;
72
+ };
73
+ okDisabled: {
74
+ control: "boolean";
75
+ description: string;
76
+ };
77
+ noCloseOnOK: {
78
+ control: "boolean";
79
+ description: string;
80
+ };
81
+ disable: {
82
+ control: "boolean";
83
+ description: string;
84
+ };
85
+ okType: {
86
+ control: "select";
87
+ options: string[];
88
+ description: string;
89
+ };
90
+ overflowY: {
91
+ control: "select";
92
+ options: string[];
93
+ description: string;
94
+ };
95
+ borderFooter: {
96
+ control: "boolean";
97
+ description: string;
98
+ };
99
+ };
100
+ };
101
+ export default meta;
102
+ type Story = StoryObj<ModalProps>;
103
+ export declare const Default: Story;
104
+ export declare const WideModal: Story;
105
+ export declare const NarrowModal: Story;
106
+ export declare const OnlyOKButton: Story;
107
+ export declare const OnlyCancelButton: Story;
108
+ export declare const NoButtons: Story;
109
+ export declare const OKDisabled: Story;
110
+ export declare const NoCloseOnOK: Story;
111
+ export declare const WithActivityOverlay: Story;
112
+ export declare const FormSubmitType: Story;
113
+ export declare const NoBorderFooter: Story;
114
+ export declare const OverflowVisible: Story;
@@ -0,0 +1,139 @@
1
+ import Modal from './Modal.svelte';
2
+ const meta = {
3
+ title: 'Components/Modal',
4
+ component: Modal,
5
+ tags: ['autodocs'],
6
+ argTypes: {
7
+ show: {
8
+ control: 'boolean',
9
+ description: 'Control visibility: value equal to noShowValue hides modal, any other value shows it'
10
+ },
11
+ noShowValue: {
12
+ control: 'text',
13
+ description: 'The value to compare against show to determine if modal should be hidden'
14
+ },
15
+ width: {
16
+ control: 'text',
17
+ description: 'Modal width (CSS value like "40em", "500px", "80%")'
18
+ },
19
+ cancelButton: {
20
+ control: 'text',
21
+ description: 'Cancel button text, or false to hide'
22
+ },
23
+ okButton: {
24
+ control: 'text',
25
+ description: 'OK button text, or false to hide'
26
+ },
27
+ okDisabled: {
28
+ control: 'boolean',
29
+ description: 'Disable the OK button'
30
+ },
31
+ noCloseOnOK: {
32
+ control: 'boolean',
33
+ description: 'Keep modal open after OK click (useful for form validation)'
34
+ },
35
+ disable: {
36
+ control: 'boolean',
37
+ description: 'Disable all interactions (shows activity overlay)'
38
+ },
39
+ okType: {
40
+ control: 'select',
41
+ options: ['submit', 'button'],
42
+ description: 'Button type for form integration'
43
+ },
44
+ overflowY: {
45
+ control: 'select',
46
+ options: ['auto', 'visible', 'hidden'],
47
+ description: 'Body overflow behavior'
48
+ },
49
+ borderFooter: {
50
+ control: 'boolean',
51
+ description: 'Show border above footer'
52
+ }
53
+ }
54
+ };
55
+ export default meta;
56
+ export const Default = {
57
+ args: {
58
+ show: true,
59
+ cancelButton: 'Cancel',
60
+ okButton: 'OK'
61
+ }
62
+ };
63
+ export const WideModal = {
64
+ args: {
65
+ show: true,
66
+ width: '80%',
67
+ cancelButton: 'Cancel',
68
+ okButton: 'Save'
69
+ }
70
+ };
71
+ export const NarrowModal = {
72
+ args: {
73
+ show: true,
74
+ width: '30em',
75
+ cancelButton: 'Cancel',
76
+ okButton: 'Confirm'
77
+ }
78
+ };
79
+ export const OnlyOKButton = {
80
+ args: {
81
+ show: true,
82
+ cancelButton: false,
83
+ okButton: 'Close'
84
+ }
85
+ };
86
+ export const OnlyCancelButton = {
87
+ args: {
88
+ show: true,
89
+ cancelButton: 'Close',
90
+ okButton: false
91
+ }
92
+ };
93
+ export const NoButtons = {
94
+ args: {
95
+ show: true,
96
+ cancelButton: false,
97
+ okButton: false
98
+ }
99
+ };
100
+ export const OKDisabled = {
101
+ args: {
102
+ show: true,
103
+ okButton: 'Save',
104
+ okDisabled: true
105
+ }
106
+ };
107
+ export const NoCloseOnOK = {
108
+ args: {
109
+ show: true,
110
+ okButton: 'Validate',
111
+ noCloseOnOK: true
112
+ }
113
+ };
114
+ export const WithActivityOverlay = {
115
+ args: {
116
+ show: true,
117
+ okButton: 'Processing...',
118
+ disable: true
119
+ }
120
+ };
121
+ export const FormSubmitType = {
122
+ args: {
123
+ show: true,
124
+ okButton: 'Submit',
125
+ okType: 'submit'
126
+ }
127
+ };
128
+ export const NoBorderFooter = {
129
+ args: {
130
+ show: true,
131
+ borderFooter: false
132
+ }
133
+ };
134
+ export const OverflowVisible = {
135
+ args: {
136
+ show: true,
137
+ overflowY: 'visible'
138
+ }
139
+ };
package/dist/Modal.svelte CHANGED
@@ -1,9 +1,40 @@
1
1
  <!--
2
2
  @component
3
+ Full-featured modal dialog with draggable header, keyboard shortcuts, and flexible content slots.
4
+ Replaces native <dialog> element or custom div overlays.
3
5
 
4
- This component presents a modal window using the HTML5 dialog element
5
- @param {any} show A property that determines if the modal should be shown or not
6
- @param {any} noShowValue A property that, if equal to the show property, will hide the modal, otherwise show the modal
6
+ @example
7
+ ```svelte
8
+ <script>
9
+ import { Modal } from 'intelliwaketssveltekitv25';
10
+ let showModal = $state(false);
11
+ </script>
12
+
13
+ <Modal
14
+ bind:show={showModal}
15
+ okButton="Save"
16
+ cancelButton="Cancel"
17
+ >
18
+ {#snippet header()}
19
+ Edit Settings
20
+ {/snippet}
21
+ {#snippet body()}
22
+ <p>Modal content...</p>
23
+ {/snippet}
24
+ </Modal>
25
+ ```
26
+
27
+ @remarks
28
+ - Uses Svelte 5 $bindable rune for two-way binding of show state
29
+ - Draggable: click and drag header to reposition modal
30
+ - Keyboard shortcuts: Enter triggers OK, Escape cancels
31
+ - Backdrop click closes modal (triggers cancel action)
32
+ - Activity overlay support for async operations
33
+ - Multiple Snippet slots for flexible layouts (header, body, leftFooter, centerFooter, rightFooter)
34
+
35
+ @see ModalFormAction - Specialized modal for SvelteKit form actions
36
+ @see ModalPromptControl - Modal with prompt/confirmation patterns
37
+ @see ActivityOverlay - Loading overlay component (used internally)
7
38
  -->
8
39
 
9
40
  <script lang='ts'>
@@ -37,9 +37,41 @@ type $$ComponentProps = {
37
37
  onClose?: () => void;
38
38
  };
39
39
  /**
40
- * This component presents a modal window using the HTML5 dialog element
41
- * @param {any} show A property that determines if the modal should be shown or not
42
- * @param {any} noShowValue A property that, if equal to the show property, will hide the modal, otherwise show the modal
40
+ * Full-featured modal dialog with draggable header, keyboard shortcuts, and flexible content slots.
41
+ * Replaces native <dialog> element or custom div overlays.
42
+ *
43
+ * @example
44
+ * ```svelte
45
+ * <script>
46
+ * import { Modal } from 'intelliwaketssveltekitv25';
47
+ * let showModal = $state(false);
48
+ * </script>
49
+ *
50
+ * <Modal
51
+ * bind:show={showModal}
52
+ * okButton="Save"
53
+ * cancelButton="Cancel"
54
+ * >
55
+ * {#snippet header()}
56
+ * Edit Settings
57
+ * {/snippet}
58
+ * {#snippet body()}
59
+ * <p>Modal content...</p>
60
+ * {/snippet}
61
+ * </Modal>
62
+ * ```
63
+ *
64
+ * @remarks
65
+ * - Uses Svelte 5 $bindable rune for two-way binding of show state
66
+ * - Draggable: click and drag header to reposition modal
67
+ * - Keyboard shortcuts: Enter triggers OK, Escape cancels
68
+ * - Backdrop click closes modal (triggers cancel action)
69
+ * - Activity overlay support for async operations
70
+ * - Multiple Snippet slots for flexible layouts (header, body, leftFooter, centerFooter, rightFooter)
71
+ *
72
+ * @see ModalFormAction - Specialized modal for SvelteKit form actions
73
+ * @see ModalPromptControl - Modal with prompt/confirmation patterns
74
+ * @see ActivityOverlay - Loading overlay component (used internally)
43
75
  */
44
76
  declare const Modal: import("svelte").Component<$$ComponentProps, {}, "show">;
45
77
  type Modal = ReturnType<typeof Modal>;