@nuralyui/select 0.0.5 → 0.1.1

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/index.d.ts CHANGED
@@ -1,2 +1,17 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ /**
7
+ * Select Component Module
8
+ *
9
+ * Advanced select component with multiple selection modes, validation,
10
+ * keyboard navigation, and accessibility features.
11
+ */
1
12
  export * from './select.component.js';
13
+ export * from './select.types.js';
14
+ export * from './select.constant.js';
15
+ export * from './controllers/index.js';
16
+ export type { SelectHost, SelectBaseController, SelectionController, KeyboardController, DropdownController, FocusController, ValidationController, ErrorHandler } from './interfaces/index.js';
2
17
  //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,2 +1,20 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ /**
7
+ * Select Component Module
8
+ *
9
+ * Advanced select component with multiple selection modes, validation,
10
+ * keyboard navigation, and accessibility features.
11
+ */
12
+ // === Main Component ===
1
13
  export * from './select.component.js';
14
+ // === Types and Interfaces ===
15
+ export * from './select.types.js';
16
+ // === Constants ===
17
+ export * from './select.constant.js';
18
+ // === Controllers (Advanced Usage) ===
19
+ export * from './controllers/index.js';
2
20
  //# sourceMappingURL=index.js.map
package/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/select/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC","sourcesContent":["export * from './select.component.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/components/select/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;GAKG;AAEH,yBAAyB;AACzB,cAAc,uBAAuB,CAAC;AAEtC,+BAA+B;AAC/B,cAAc,mBAAmB,CAAC;AAElC,oBAAoB;AACpB,cAAc,sBAAsB,CAAC;AAErC,uCAAuC;AACvC,cAAc,wBAAwB,CAAC","sourcesContent":["/**\n * @license\n * Copyright 2023 Nuraly, Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\n/**\n * Select Component Module\n * \n * Advanced select component with multiple selection modes, validation, \n * keyboard navigation, and accessibility features.\n */\n\n// === Main Component ===\nexport * from './select.component.js';\n\n// === Types and Interfaces ===\nexport * from './select.types.js';\n\n// === Constants ===\nexport * from './select.constant.js';\n\n// === Controllers (Advanced Usage) ===\nexport * from './controllers/index.js';\n\n// === Controller Interfaces (Type-Only Exports) ===\nexport type { \n SelectHost,\n SelectBaseController,\n SelectionController,\n KeyboardController,\n DropdownController,\n FocusController,\n ValidationController,\n ErrorHandler\n} from './interfaces/index.js';\n"]}
package/package.json CHANGED
@@ -1,9 +1,21 @@
1
1
  {
2
2
  "name": "@nuralyui/select",
3
- "version": "0.0.5",
4
- "description": "",
3
+ "version": "0.1.1",
4
+ "description": "A comprehensive select component with advanced features including multi-selection, keyboard navigation, validation, and accessibility support.",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
+ "keywords": [
8
+ "select",
9
+ "dropdown",
10
+ "combobox",
11
+ "multi-select",
12
+ "web-components",
13
+ "lit-element",
14
+ "typescript",
15
+ "accessibility",
16
+ "validation",
17
+ "keyboard-navigation"
18
+ ],
7
19
  "dependencies": {
8
20
  "dayjs": "^1.11.7"
9
21
  },
@@ -11,5 +23,19 @@
11
23
  "test": "echo \"Error: no test specified\" && exit 1"
12
24
  },
13
25
  "author": "Labidi Aymen",
14
- "license": "ISC"
26
+ "license": "ISC",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./index.js"
30
+ },
31
+ "./bundle": {
32
+ "import": "./bundle.js"
33
+ }
34
+ },
35
+ "files": [
36
+ "bundle.js",
37
+ "*.js",
38
+ "*.d.ts",
39
+ "*.js.map"
40
+ ]
15
41
  }
package/react.d.ts CHANGED
@@ -1,8 +1,19 @@
1
+ import React from 'react';
1
2
  import { HySelectComponent } from './select.component.js';
3
+ /**
4
+ * React wrapper for the HySelectComponent
5
+ * Provides React-compatible props and event handling
6
+ */
2
7
  export declare const HySelect: import("@lit-labs/react").ReactWebComponent<HySelectComponent, {
3
8
  onChange: string;
4
- onInput: string;
9
+ onChanged: string;
5
10
  onFocus: string;
6
11
  onBlur: string;
12
+ onDropdownOpen: string;
13
+ onDropdownClose: string;
14
+ onValidation: string;
15
+ onSelectError: string;
16
+ onSelectFocus: string;
7
17
  }>;
18
+ export declare type HySelectProps = React.ComponentProps<typeof HySelect>;
8
19
  //# sourceMappingURL=react.d.ts.map
package/react.js CHANGED
@@ -1,15 +1,26 @@
1
- import * as React from 'react';
1
+ import React from 'react';
2
2
  import { createComponent } from '@lit-labs/react';
3
3
  import { HySelectComponent } from './select.component.js';
4
+ /**
5
+ * React wrapper for the HySelectComponent
6
+ * Provides React-compatible props and event handling
7
+ */
4
8
  export const HySelect = createComponent({
5
9
  tagName: 'hy-select',
6
10
  elementClass: HySelectComponent,
7
11
  react: React,
8
12
  events: {
13
+ // Standard events
9
14
  onChange: 'change',
10
- onInput: 'input',
15
+ onChanged: 'changed',
11
16
  onFocus: 'focus',
12
17
  onBlur: 'blur',
18
+ // Select-specific events
19
+ onDropdownOpen: 'dropdown-open',
20
+ onDropdownClose: 'dropdown-close',
21
+ onValidation: 'validation',
22
+ onSelectError: 'select-error',
23
+ onSelectFocus: 'select-focus',
13
24
  },
14
25
  });
15
26
  //# sourceMappingURL=react.js.map
package/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/components/select/react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAElD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC;IACtC,OAAO,EAAE,WAAW;IACpB,YAAY,EAAE,iBAAiB;IAC/B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE;QACN,QAAQ,EAAE,QAAQ;QAClB,OAAO,EAAE,OAAO;QAChB,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,MAAM;KACf;CACF,CAAC,CAAC","sourcesContent":["import * as React from 'react';\nimport { createComponent } from '@lit-labs/react';\n\nimport { HySelectComponent } from './select.component.js';\n\nexport const HySelect = createComponent({\n tagName: 'hy-select',\n elementClass: HySelectComponent,\n react: React,\n events: {\n onChange: 'change',\n onInput: 'input',\n onFocus: 'focus',\n onBlur: 'blur',\n },\n});"]}
1
+ {"version":3,"file":"react.js","sourceRoot":"","sources":["../../../src/components/select/react.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,eAAe,CAAC;IACtC,OAAO,EAAE,WAAW;IACpB,YAAY,EAAE,iBAAiB;IAC/B,KAAK,EAAE,KAAK;IACZ,MAAM,EAAE;QACN,kBAAkB;QAClB,QAAQ,EAAE,QAAQ;QAClB,SAAS,EAAE,SAAS;QACpB,OAAO,EAAE,OAAO;QAChB,MAAM,EAAE,MAAM;QAEd,yBAAyB;QACzB,cAAc,EAAE,eAAe;QAC/B,eAAe,EAAE,gBAAgB;QACjC,YAAY,EAAE,YAAY;QAC1B,aAAa,EAAE,cAAc;QAC7B,aAAa,EAAE,cAAc;KAC9B;CACF,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport { createComponent } from '@lit-labs/react';\nimport { HySelectComponent } from './select.component.js';\n\n/**\n * React wrapper for the HySelectComponent\n * Provides React-compatible props and event handling\n */\nexport const HySelect = createComponent({\n tagName: 'hy-select',\n elementClass: HySelectComponent,\n react: React,\n events: {\n // Standard events\n onChange: 'change',\n onChanged: 'changed', // Legacy event for backward compatibility\n onFocus: 'focus',\n onBlur: 'blur',\n \n // Select-specific events\n onDropdownOpen: 'dropdown-open',\n onDropdownClose: 'dropdown-close',\n onValidation: 'validation',\n onSelectError: 'select-error',\n onSelectFocus: 'select-focus',\n },\n});\n\n// Export type for React props\nexport type HySelectProps = React.ComponentProps<typeof HySelect>;"]}
@@ -1,28 +1,313 @@
1
- import { LitElement, PropertyValues } from 'lit';
2
- import { IOption, OptionSelectionMode, OptionSize, OptionStatus, OptionType } from './select.types.js';
3
- export declare class HySelectComponent extends LitElement {
1
+ /**
2
+ * @license
3
+ * Copyright 2023 Nuraly, Laabidi Aymen
4
+ * SPDX-License-Identifier: MIT
5
+ */
6
+ import { LitElement } from 'lit';
7
+ import { SelectOption, SelectType, SelectSize, SelectStatus } from './select.types.js';
8
+ import { SelectHost } from './interfaces/index.js';
9
+ declare const HySelectComponent_base: (new (...args: any[]) => import("../../shared/dependency-mixin.js").DependencyAware) & (new (...args: any[]) => import("../../shared/theme-mixin.js").ThemeAware) & (new (...args: any[]) => import("../../shared/event-handler-mixin.js").EventHandlerCapable) & typeof LitElement;
10
+ /**
11
+ * Advanced select component with multiple selection modes, validation, and accessibility features.
12
+ *
13
+ * Supports single and multiple selection, custom rendering, validation states, keyboard navigation,
14
+ * and various display types including default, inline, button, and slot-based configurations.
15
+ *
16
+ * @example
17
+ * ```html
18
+ * <!-- Basic select -->
19
+ * <hy-select placeholder="Choose an option">
20
+ * <option value="1">Option 1</option>
21
+ * <option value="2">Option 2</option>
22
+ * </hy-select>
23
+ *
24
+ * <!-- Multiple selection -->
25
+ * <hy-select multiple placeholder="Choose multiple options"></hy-select>
26
+ *
27
+ * <!-- With validation -->
28
+ * <hy-select required status="error"></hy-select>
29
+ *
30
+ * <!-- Button style -->
31
+ * <hy-select type="button"></hy-select>
32
+ *
33
+ * <!-- With search functionality -->
34
+ * <hy-select searchable search-placeholder="Search options..."></hy-select>
35
+ * ```
36
+ *
37
+ * @fires nr-change - Selection changed
38
+ * @fires nr-focus - Component focused
39
+ * @fires nr-blur - Component blurred
40
+ * @fires nr-dropdown-open - Dropdown opened
41
+ * @fires nr-dropdown-close - Dropdown closed
42
+ * @fires nr-validation - Validation state changed
43
+ *
44
+ * @slot label - Select label content
45
+ * @slot helper-text - Helper text below select
46
+ * @slot trigger - Custom trigger content (slot type only)
47
+ *
48
+ * @cssproperty --select-border-color - Border color
49
+ * @cssproperty --select-background - Background color
50
+ * @cssproperty --select-text-color - Text color
51
+ * @cssproperty --select-focus-color - Focus indicator color
52
+ * @cssproperty --select-dropdown-shadow - Dropdown shadow
53
+ * @cssproperty --select-no-options-color - No options message text color
54
+ * @cssproperty --select-no-options-icon-color - No options icon color
55
+ * @cssproperty --select-no-options-padding - Padding for no options message
56
+ * @cssproperty --select-no-options-gap - Gap between icon and text
57
+ * @cssproperty --select-search-border - Search input border
58
+ * @cssproperty --select-search-background - Search input background
59
+ * @cssproperty --select-search-padding - Search input padding
60
+ */
61
+ export declare class HySelectComponent extends HySelectComponent_base implements SelectHost {
4
62
  static styles: import("lit").CSSResult;
5
- options: IOption[];
6
- defaultSelected: string[];
63
+ requiredComponents: string[];
64
+ /** Array of options to display in the select dropdown */
65
+ options: SelectOption[];
66
+ /** Default selected values (for initialization) */
67
+ defaultValue: string[];
68
+ /** Placeholder text shown when no option is selected */
7
69
  placeholder: string;
70
+ /** Disables the select component */
8
71
  disabled: boolean;
9
- type: OptionType;
10
- selectionMode: OptionSelectionMode;
72
+ /** Select display type (default, inline, button, slot) */
73
+ type: SelectType;
74
+ /** Enables multiple option selection */
75
+ multiple: boolean;
76
+ /** Controls dropdown visibility */
11
77
  show: boolean;
12
- status: OptionStatus;
13
- size: OptionSize;
14
- selected: IOption[];
78
+ /** Validation status (default, warning, error, success) */
79
+ status: SelectStatus;
80
+ /** Select size (small, medium, large) */
81
+ size: SelectSize;
82
+ /** Makes the select required for form validation */
83
+ required: boolean;
84
+ /** Form field name */
85
+ name: string;
86
+ /** Current selected value(s) */
87
+ value: string | string[];
88
+ /** Message to display when no options are available */
89
+ noOptionsMessage: string;
90
+ /** Icon to display with the no options message */
91
+ noOptionsIcon: string;
92
+ /** Enable search/filter functionality */
93
+ searchable: boolean;
94
+ /** Placeholder text for the search input */
95
+ searchPlaceholder: string;
96
+ /** Current search query */
97
+ searchQuery: string;
98
+ /** Options dropdown container element */
15
99
  optionsElement: HTMLElement;
100
+ /** Main wrapper element */
16
101
  wrapper: HTMLElement;
17
- protected updated(_changedProperties: PropertyValues): void;
18
- private toggleOptions;
19
- private calculateOptionsPosition;
20
- private initOptionsPosition;
21
- private selectOption;
22
- private unselectAll;
23
- private unselectOne;
24
- private dispatchChangeEvent;
25
- private onBlur;
26
- protected render(): unknown;
102
+ /** Search input element */
103
+ searchInput?: HTMLInputElement;
104
+ /** Handles option selection logic */
105
+ private selectionController;
106
+ /** Manages dropdown visibility and positioning */
107
+ private dropdownController;
108
+ /** Handles keyboard navigation */
109
+ private keyboardController;
110
+ /** Manages focus states */
111
+ private focusController;
112
+ /** Handles validation logic */
113
+ private validationController;
114
+ /** Handles search/filter functionality */
115
+ private searchController;
116
+ /** Handles all event management */
117
+ private eventController;
118
+ /**
119
+ * Component connected to DOM - initialize base functionality
120
+ */
121
+ connectedCallback(): void;
122
+ /**
123
+ * Component disconnected from DOM - cleanup event listeners
124
+ */
125
+ disconnectedCallback(): void;
126
+ /**
127
+ * First render complete - setup controllers and initialize state
128
+ */
129
+ firstUpdated(changedProperties: any): void;
130
+ /**
131
+ * Gets the currently selected options
132
+ * @returns Array of selected options
133
+ */
134
+ get selectedOptions(): SelectOption[];
135
+ /**
136
+ * Gets the first selected option (for single selection mode)
137
+ * @returns Selected option or undefined if none selected
138
+ */
139
+ get selectedOption(): SelectOption | undefined;
140
+ /**
141
+ * Selects an option programmatically
142
+ * @param option - The option to select
143
+ */
144
+ selectOption(option: SelectOption): void;
145
+ /**
146
+ * Unselects an option programmatically
147
+ * @param option - The option to unselect
148
+ */
149
+ unselectOption(option: SelectOption): void;
150
+ /**
151
+ * Clears all current selections
152
+ */
153
+ clearSelection(): void;
154
+ /**
155
+ * Checks if a specific option is currently selected
156
+ * @param option - The option to check
157
+ * @returns True if the option is selected
158
+ */
159
+ isOptionSelected(option: SelectOption): boolean;
160
+ /**
161
+ * Toggles the dropdown visibility
162
+ */
163
+ toggleDropdown(): void;
164
+ /**
165
+ * Opens the dropdown programmatically
166
+ */
167
+ openDropdown(): void;
168
+ /**
169
+ * Closes the dropdown programmatically
170
+ */
171
+ closeDropdown(): void;
172
+ /**
173
+ * Focuses the select component
174
+ */
175
+ focus(): void;
176
+ /**
177
+ * Removes focus from the select component
178
+ */
179
+ blur(): void;
180
+ /**
181
+ * Validates the current selection according to component rules
182
+ * @returns True if valid, false otherwise
183
+ */
184
+ validate(): boolean;
185
+ /**
186
+ * Checks if the current selection is valid without showing validation UI
187
+ * @returns True if valid, false otherwise
188
+ */
189
+ checkValidity(): boolean;
190
+ /**
191
+ * Reports the current validation state and shows validation UI if invalid
192
+ * @returns True if valid, false otherwise
193
+ */
194
+ reportValidity(): boolean;
195
+ /**
196
+ * Sets a custom validation message
197
+ * @param message - Custom validation message (empty string to clear)
198
+ */
199
+ setCustomValidity(message: string): void;
200
+ /**
201
+ * Searches for options with the given query
202
+ * @param query - Search query string
203
+ */
204
+ searchOptions(query: string): void;
205
+ /**
206
+ * Clears the current search query
207
+ */
208
+ clearSearch(): void;
209
+ /**
210
+ * Gets the filtered options based on current search
211
+ * @returns Array of filtered options
212
+ */
213
+ getSearchFilteredOptions(): SelectOption[];
214
+ /**
215
+ * Gets the current search query
216
+ * @returns Current search query string
217
+ */
218
+ getCurrentSearchQuery(): string;
219
+ /**
220
+ * Manually trigger setup of global event listeners
221
+ */
222
+ setupGlobalEventListeners(): void;
223
+ /**
224
+ * Manually trigger removal of global event listeners
225
+ */
226
+ removeGlobalEventListeners(): void;
227
+ /**
228
+ * Handles clicks on the select trigger element
229
+ */
230
+ private handleTriggerClick;
231
+ /**
232
+ * Handles clicks on individual options
233
+ */
234
+ private handleOptionClick;
235
+ /**
236
+ * Handles removal of selected tags in multiple selection mode
237
+ */
238
+ private handleTagRemove;
239
+ /**
240
+ * Handles the clear all selections button
241
+ */
242
+ private handleClearAll;
243
+ /**
244
+ * Handles keyboard navigation and interactions
245
+ */
246
+ private handleKeyDown;
247
+ /**
248
+ * Handles focus events
249
+ */
250
+ private handleFocus;
251
+ /**
252
+ * Handles blur events
253
+ */
254
+ private handleBlur;
255
+ /**
256
+ * Filters options based on search query
257
+ */
258
+ private getFilteredOptions;
259
+ /**
260
+ * Sets up global event listeners (called when dropdown opens)
261
+ */
262
+ setupEventListeners(): void;
263
+ /**
264
+ * Removes global event listeners (called on disconnect or dropdown close)
265
+ */
266
+ removeEventListeners(): void;
267
+ /**
268
+ * Main render method that delegates to specific type renderers
269
+ */
270
+ protected render(): import("lit").TemplateResult<1>;
271
+ /**
272
+ * Renders the default select appearance with full features
273
+ */
274
+ private renderDefault;
275
+ /**
276
+ * Renders inline select with integrated label and helper text
277
+ */
278
+ private renderInline;
279
+ /**
280
+ * Renders select as a button-style component
281
+ */
282
+ private renderButton;
283
+ /**
284
+ * Renders select with custom trigger content via slots
285
+ */
286
+ private renderSlot;
287
+ /**
288
+ * Renders the selected content in the trigger area
289
+ */
290
+ private renderSelectedContent;
291
+ /**
292
+ * Renders status/validation icons based on current status
293
+ */
294
+ private renderStatusIcon;
295
+ /**
296
+ * Renders the clear all selections button when applicable
297
+ */
298
+ private renderClearButton;
299
+ /**
300
+ * Renders all available options in the dropdown
301
+ */
302
+ private renderSelectOptions;
303
+ /**
304
+ * Renders the search input when searchable is enabled
305
+ */
306
+ private renderSearchInput;
307
+ /**
308
+ * Renders validation message when present
309
+ */
310
+ private renderValidationMessage;
27
311
  }
312
+ export {};
28
313
  //# sourceMappingURL=select.component.d.ts.map