intelliwaketssveltekitv25 1.0.82 → 1.0.84

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,215 @@
1
+ # Integration Guide
2
+
3
+ Complete setup requirements for integrating the IntelliWakeTSSvelteKitV2.5 component library into your SvelteKit project.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install intelliwaketssveltekitv25
9
+ ```
10
+
11
+ ## Required Peer Dependencies
12
+
13
+ ```json
14
+ {
15
+ "@solidbasisventures/intelliwaketsfoundation": "^5.13.57",
16
+ "@sveltejs/kit": "^2.49.2",
17
+ "svelte": "^5.46.1"
18
+ }
19
+ ```
20
+
21
+ Install peer dependencies:
22
+
23
+ ```bash
24
+ npm install @solidbasisventures/intelliwaketsfoundation @sveltejs/kit svelte
25
+ ```
26
+
27
+ ## CSS Import (Required)
28
+
29
+ Import the library CSS in your root layout or app.css:
30
+
31
+ ```typescript
32
+ // src/routes/+layout.svelte or src/app.css
33
+ import 'intelliwaketssveltekitv25/dist/app.css';
34
+ ```
35
+
36
+ ## Tailwind CSS Configuration (Required)
37
+
38
+ Your project **MUST** define these custom Tailwind colors in your `tailwind.config.js`:
39
+
40
+ ```javascript
41
+ export default {
42
+ theme: {
43
+ extend: {
44
+ colors: {
45
+ primary: {
46
+ main: '#your-color', // Main primary color
47
+ face: '#your-color', // Text color on primary background
48
+ hover: '#your-color', // Hover state color
49
+ light: '#your-color', // Light variant
50
+ selected: '#your-color' // Selected state color
51
+ },
52
+ secondary: {
53
+ main: '#your-color', // Main secondary color
54
+ light: '#your-color' // Light variant
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ ### Example Color Configuration
63
+
64
+ ```javascript
65
+ colors: {
66
+ primary: {
67
+ main: '#3b82f6', // Blue-500
68
+ face: '#ffffff', // White
69
+ hover: '#2563eb', // Blue-600
70
+ light: '#dbeafe', // Blue-100
71
+ selected: '#bfdbfe' // Blue-200
72
+ },
73
+ secondary: {
74
+ main: '#64748b', // Slate-500
75
+ light: '#e2e8f0' // Slate-200
76
+ }
77
+ }
78
+ ```
79
+
80
+ ### Required Custom CSS Classes
81
+
82
+ Define these custom classes in your `app.css` or Tailwind config:
83
+
84
+ ```css
85
+ /* Master-Detail Layout Horizontal Rules */
86
+ .mdMasterHR {
87
+ /* Styling for MasterDetailLayout master section header HR */
88
+ @apply border-gray-300 my-2;
89
+ }
90
+
91
+ .mdDetailHR {
92
+ /* Styling for MasterDetailLayout detail section header HR */
93
+ @apply border-gray-400 my-2;
94
+ }
95
+ ```
96
+
97
+ ## Component Import
98
+
99
+ Import components as needed:
100
+
101
+ ```svelte
102
+ <script>
103
+ import { Switch, InputNumber, Modal, ArrayTable } from 'intelliwaketssveltekitv25';
104
+
105
+ let enabled = $state(false);
106
+ let price = $state(29.99);
107
+ </script>
108
+
109
+ <Switch bind:checked={enabled}>Enable Feature</Switch>
110
+ <InputNumber bind:value={price} currency />
111
+ ```
112
+
113
+ ## TypeScript Support
114
+
115
+ The library is fully typed. Import types as needed:
116
+
117
+ ```typescript
118
+ import type {
119
+ IArrayStructure,
120
+ IArrayColumn,
121
+ IDDAction,
122
+ IFAProps
123
+ } from 'intelliwaketssveltekitv25';
124
+ ```
125
+
126
+ ## FontAwesome Icons
127
+
128
+ Many components support FontAwesome icons via the `IFAProps` interface:
129
+
130
+ ```bash
131
+ npm install @fortawesome/free-solid-svg-icons
132
+ ```
133
+
134
+ ```svelte
135
+ <script>
136
+ import { DropDown } from 'intelliwaketssveltekitv25';
137
+ import { faEdit, faTrash } from '@fortawesome/free-solid-svg-icons';
138
+
139
+ const actions = [
140
+ { title: 'Edit', faProps: { icon: faEdit }, action: () => {} },
141
+ { title: 'Delete', faProps: { icon: faTrash }, action: () => {} }
142
+ ];
143
+ </script>
144
+
145
+ <DropDown buttonTitle="Actions" ddActions={actions} />
146
+ ```
147
+
148
+ ## SvelteKit Configuration
149
+
150
+ The library uses Svelte 5 experimental features. Your `svelte.config.ts` should include:
151
+
152
+ ```typescript
153
+ import adapter from '@sveltejs/adapter-auto';
154
+
155
+ export default {
156
+ kit: {
157
+ adapter: adapter(),
158
+ experimental: {
159
+ remoteFunctions: true
160
+ }
161
+ },
162
+ compilerOptions: {
163
+ experimental: {
164
+ async: true
165
+ }
166
+ }
167
+ };
168
+ ```
169
+
170
+ ## CSS Variables
171
+
172
+ The library defines these CSS variables (in `dist/app.css`):
173
+
174
+ ```css
175
+ :root {
176
+ --red-color: red;
177
+ --color-danger: #fb2c36;
178
+ }
179
+ ```
180
+
181
+ ## Global Styles
182
+
183
+ The library includes global button and input styles. To opt-out on specific elements:
184
+
185
+ ```svelte
186
+ <!-- Skip global button styles -->
187
+ <button class="btnClean">Custom Styled Button</button>
188
+
189
+ <!-- Skip global input formatting -->
190
+ <input class="noFormat" type="text" />
191
+ ```
192
+
193
+ ## Troubleshooting
194
+
195
+ ### Colors Not Showing
196
+
197
+ Ensure you've defined all required Tailwind colors in your `tailwind.config.js`.
198
+
199
+ ### CSS Not Loading
200
+
201
+ Verify you've imported `intelliwaketssveltekitv25/dist/app.css` in your root layout.
202
+
203
+ ### TypeScript Errors
204
+
205
+ Install all peer dependencies and ensure TypeScript version is 5.0+.
206
+
207
+ ### Components Not Rendering
208
+
209
+ Check browser console for errors related to missing dependencies or CSS.
210
+
211
+ ## Next Steps
212
+
213
+ - Explore [Svelte 5 Patterns](Svelte-5-Patterns) used in the library
214
+ - Browse component documentation starting with [Switch](Switch)
215
+ - Run Storybook: `pnpm storybook` for interactive examples
package/docs/Modal.md ADDED
@@ -0,0 +1,207 @@
1
+ # Modal Component
2
+
3
+ **Replaces:** Native `<dialog>` element or custom div overlays with manual JavaScript
4
+
5
+ **Purpose:** Full-featured modal dialog with draggable header, keyboard shortcuts, and flexible content slots
6
+
7
+ **When to Use:**
8
+ - Confirmation dialogs (delete, save, cancel operations)
9
+ - Forms that need to overlay the main content
10
+ - Multi-step workflows in a focused view
11
+ - Detail views that shouldn't navigate away from current page
12
+ - Any overlay content that requires user interaction before proceeding
13
+
14
+ ## Key Props
15
+
16
+ - `show: unknown` ($bindable) - Control visibility: value equal to `noShowValue` hides modal, any other value shows it
17
+ - `noShowValue?: unknown` (default: false) - The value to compare against `show` to determine if modal should be hidden
18
+ - `forceNoShow?: boolean` - Force modal to be hidden regardless of `show` value
19
+ - `width?: string` (default: '40em') - Modal width (CSS value like '40em', '500px', '80%')
20
+ - `cancelButton?: string | false` (default: 'Cancel') - Cancel button text, or `false` to hide
21
+ - `okButton?: string | false` (default: 'OK') - OK button text, or `false` to hide
22
+ - `okDisabled?: boolean` - Disable the OK button
23
+ - `okColor?: TDefaultColorPalate | null` - Color theme for OK button
24
+ - `okFAProps?: IFAProps` - FontAwesome icon props for OK button
25
+ - `okType?: 'submit' | 'button'` (default: 'button') - Button type for form integration
26
+ - `okActionNotOnEnter?: boolean` - Prevent Enter key from triggering OK action
27
+ - `noCloseOnOK?: boolean` (default: true) - Keep modal open after OK click (useful for form validation)
28
+ - `overflowY?: 'auto' | 'visible' | 'hidden'` (default: 'auto') - Body overflow behavior
29
+ - `disable?: boolean` - Disable all interactions (shows activity overlay)
30
+ - `marginForStickyHeader?: boolean` - Add margin to body for sticky header support
31
+ - `okButtonWrap?: boolean` - Allow OK/Cancel button text to wrap
32
+ - `borderFooter?: boolean` (default: true) - Show border above footer
33
+ - `class?: string` - Additional CSS classes for dialog element
34
+ - `color?: TDefaultColorPalate | null` - Overall color theme
35
+ - `classHeader?: string` - CSS classes for header section
36
+ - `classBody?: string` - CSS classes for body section
37
+ - `classFooter?: string` - CSS classes for footer section
38
+ - `classButton?: string` - CSS classes for OK button
39
+ - `onOK?: () => void` - Callback when OK button clicked (synchronous)
40
+ - `onOKPromise?: () => Promise<unknown>` - Async callback for OK button (awaits promise before closing)
41
+ - `onCancel?: () => void` - Callback when Cancel button clicked or modal dismissed
42
+ - `onClose?: () => void` - Callback when modal closes (any reason)
43
+
44
+ ## Snippets
45
+
46
+ - `header?: Snippet` - Header content (displays in colored bar with close button)
47
+ - `body?: Snippet` - Main body content
48
+ - `leftFooter?: Snippet` - Content in footer left section
49
+ - `centerFooter?: Snippet` - Content in footer center section
50
+ - `rightFooter?: Snippet` - Content in footer right section
51
+
52
+ ## Special Features
53
+
54
+ - **Draggable:** Click and drag the header to reposition the modal
55
+ - **Keyboard shortcuts:** Enter key triggers OK, Escape key cancels
56
+ - **Activity overlay:** Automatically disables interaction when `disable` is true
57
+ - **Backdrop click:** Clicking outside modal closes it (triggers cancel action)
58
+
59
+ ## Usage Examples
60
+
61
+ ```svelte
62
+ <script>
63
+ import { Modal } from 'intelliwaketssveltekitv25';
64
+ let showConfirmDelete = $state(false);
65
+ let showEditForm = $state(null); // null = hidden, object = shown with data
66
+ let isProcessing = $state(false);
67
+ </script>
68
+
69
+ <!-- Simple confirmation dialog -->
70
+ <Modal
71
+ bind:show={showConfirmDelete}
72
+ width="30em"
73
+ okButton="Delete"
74
+ cancelButton="Cancel"
75
+ onOK={() => {
76
+ performDelete();
77
+ showConfirmDelete = false;
78
+ }}
79
+ >
80
+ {#snippet header()}
81
+ Confirm Deletion
82
+ {/snippet}
83
+ {#snippet body()}
84
+ Are you sure you want to delete this item? This action cannot be undone.
85
+ {/snippet}
86
+ </Modal>
87
+
88
+ <!-- Form in modal with validation -->
89
+ <Modal
90
+ bind:show={showEditForm}
91
+ width="50em"
92
+ okButton="Save Changes"
93
+ okType="submit"
94
+ noCloseOnOK={true}
95
+ onOKPromise={async () => {
96
+ // Validate and save
97
+ const result = await saveForm(showEditForm);
98
+ if (result.success) {
99
+ showEditForm = null; // Close on success
100
+ } else {
101
+ // Stay open on validation failure
102
+ throw new Error(result.error);
103
+ }
104
+ }}
105
+ >
106
+ {#snippet header()}
107
+ Edit User Profile
108
+ {/snippet}
109
+ {#snippet body()}
110
+ <form id="editForm">
111
+ <!-- Form fields here -->
112
+ <input type="text" name="name" value={showEditForm?.name} />
113
+ <input type="email" name="email" value={showEditForm?.email} />
114
+ </form>
115
+ {/snippet}
116
+ </Modal>
117
+
118
+ <!-- Modal with custom footer content -->
119
+ <Modal
120
+ bind:show={showDetails}
121
+ okButton={false}
122
+ cancelButton="Close"
123
+ >
124
+ {#snippet header()}
125
+ Item Details
126
+ {/snippet}
127
+ {#snippet body()}
128
+ <p>Detailed information here...</p>
129
+ {/snippet}
130
+ {#snippet leftFooter()}
131
+ <button type="button" onclick={() => printDetails()}>
132
+ Print
133
+ </button>
134
+ {/snippet}
135
+ {#snippet rightFooter()}
136
+ <button type="button" onclick={() => exportDetails()}>
137
+ Export
138
+ </button>
139
+ {/snippet}
140
+ </Modal>
141
+
142
+ <!-- Modal with activity overlay during async operation -->
143
+ <Modal
144
+ bind:show={showImport}
145
+ disable={isProcessing}
146
+ okButton="Import Data"
147
+ onOKPromise={async () => {
148
+ isProcessing = true;
149
+ try {
150
+ await importData();
151
+ showImport = false;
152
+ } finally {
153
+ isProcessing = false;
154
+ }
155
+ }}
156
+ >
157
+ {#snippet header()}
158
+ Import Data
159
+ {/snippet}
160
+ {#snippet body()}
161
+ <input type="file" accept=".csv" />
162
+ {/snippet}
163
+ </Modal>
164
+
165
+ <!-- Using noShowValue for object-based visibility -->
166
+ <Modal
167
+ bind:show={selectedUser}
168
+ noShowValue={null}
169
+ okButton="Save"
170
+ >
171
+ {#snippet header()}
172
+ Edit {selectedUser?.name}
173
+ {/snippet}
174
+ {#snippet body()}
175
+ <!-- Edit form -->
176
+ {/snippet}
177
+ </Modal>
178
+ <!-- To show: selectedUser = {name: 'John', ...} -->
179
+ <!-- To hide: selectedUser = null -->
180
+ ```
181
+
182
+ ## Common Mistakes
183
+
184
+ - ❌ Not binding `show` prop: `<Modal show={x}>`
185
+ ✅ Correct: `<Modal bind:show={x}>` (for two-way binding)
186
+
187
+ - ❌ Unclear `noShowValue` usage: `show={item}` with `noShowValue={null}` but forgetting to set `item = null` to close
188
+ ✅ Correct: Always set `show = noShowValue` to close the modal
189
+
190
+ - ❌ Using `noCloseOnOK={false}` with `onOKPromise` without handling errors
191
+ ✅ Correct: Use `noCloseOnOK={true}` and manually close in promise, or handle all errors
192
+
193
+ - ❌ Forgetting to prevent Enter key when using forms: Modal submits unexpectedly
194
+ ✅ Correct: Use `okActionNotOnEnter={true}` or `okType="submit"` with proper form handling
195
+
196
+ - ❌ Not using `onOKPromise` for async operations, causing modal to close immediately
197
+ ✅ Correct: Use `onOKPromise` for async operations, not `onOK`
198
+
199
+ ## Related Components
200
+
201
+ - `ModalFormAction` - Specialized modal for SvelteKit form actions
202
+ - `ModalPromptControl` - Modal with prompt/confirmation patterns
203
+ - `ActivityOverlay` - Loading overlay (used internally by Modal)
204
+
205
+ ## Storybook
206
+
207
+ See `Components/Modal` stories