@smilodon/core 1.4.3 → 1.4.5
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 +31 -0
- package/dist/index.cjs +260 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +260 -8
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/index.umd.js +260 -8
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/components/enhanced-select.d.ts +12 -1
- package/dist/types/src/config/global-config.d.ts +21 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/types.d.ts +5 -0
- package/dist/types/src/utils/csp-styles.d.ts +1 -1
- package/package.json +1 -1
|
@@ -30,16 +30,20 @@ export declare class EnhancedSelect extends HTMLElement {
|
|
|
30
30
|
private _errorMessage;
|
|
31
31
|
private _boundArrowClick;
|
|
32
32
|
private _arrowContainer?;
|
|
33
|
+
private _clearControl?;
|
|
34
|
+
private _clearControlIcon?;
|
|
33
35
|
private _pendingFirstRenderMark;
|
|
34
36
|
private _pendingSearchRenderMark;
|
|
35
37
|
private _rangeAnchorIndex;
|
|
36
38
|
private _optionRenderer?;
|
|
39
|
+
private _classMap?;
|
|
37
40
|
private _rendererHelpers;
|
|
38
41
|
private _customOptionBoundElements;
|
|
39
42
|
private _mirrorGlobalStylesForCustomOptions;
|
|
40
43
|
private _globalStylesObserver;
|
|
41
44
|
private _globalStylesContainer;
|
|
42
|
-
classMap
|
|
45
|
+
get classMap(): ClassMap | undefined;
|
|
46
|
+
set classMap(map: ClassMap | undefined);
|
|
43
47
|
constructor();
|
|
44
48
|
connectedCallback(): void;
|
|
45
49
|
disconnectedCallback(): void;
|
|
@@ -54,6 +58,7 @@ export declare class EnhancedSelect extends HTMLElement {
|
|
|
54
58
|
private _createOptionsContainer;
|
|
55
59
|
private _createLiveRegion;
|
|
56
60
|
private _createArrowContainer;
|
|
61
|
+
private _createClearControl;
|
|
57
62
|
private _assembleDOM;
|
|
58
63
|
private _initializeStyles;
|
|
59
64
|
private _attachEventListeners;
|
|
@@ -123,6 +128,10 @@ export declare class EnhancedSelect extends HTMLElement {
|
|
|
123
128
|
* Clear all selections
|
|
124
129
|
*/
|
|
125
130
|
clear(): void;
|
|
131
|
+
/**
|
|
132
|
+
* Clear search query and restore full option list
|
|
133
|
+
*/
|
|
134
|
+
clearSearch(): void;
|
|
126
135
|
/**
|
|
127
136
|
* Open dropdown
|
|
128
137
|
*/
|
|
@@ -135,6 +144,8 @@ export declare class EnhancedSelect extends HTMLElement {
|
|
|
135
144
|
* Update component configuration
|
|
136
145
|
*/
|
|
137
146
|
updateConfig(config: Partial<GlobalSelectConfig>): void;
|
|
147
|
+
private _handleClearControlClick;
|
|
148
|
+
private _syncClearControlState;
|
|
138
149
|
/**
|
|
139
150
|
* Set error state
|
|
140
151
|
*/
|
|
@@ -44,6 +44,20 @@ export interface ExpandableConfig {
|
|
|
44
44
|
/** Label for the collapse button */
|
|
45
45
|
collapseLabel?: string;
|
|
46
46
|
}
|
|
47
|
+
export interface ClearControlConfig {
|
|
48
|
+
/** Enable clear control button inside input container */
|
|
49
|
+
enabled: boolean;
|
|
50
|
+
/** Clear selected values when button is clicked */
|
|
51
|
+
clearSelection?: boolean;
|
|
52
|
+
/** Clear search query when button is clicked */
|
|
53
|
+
clearSearch?: boolean;
|
|
54
|
+
/** Hide clear control when there is nothing to clear */
|
|
55
|
+
hideWhenEmpty?: boolean;
|
|
56
|
+
/** Accessible label for clear control */
|
|
57
|
+
ariaLabel?: string;
|
|
58
|
+
/** Text/icon content shown inside the clear control */
|
|
59
|
+
icon?: string;
|
|
60
|
+
}
|
|
47
61
|
export interface SelectionConfig {
|
|
48
62
|
/** Single or multi-select mode */
|
|
49
63
|
mode: 'single' | 'multi';
|
|
@@ -134,6 +148,11 @@ export interface CallbackConfig {
|
|
|
134
148
|
onLoadMore?: (page: number) => void;
|
|
135
149
|
/** Called when selection changes */
|
|
136
150
|
onChange?: (selectedItems: unknown[], selectedValues: unknown[]) => void;
|
|
151
|
+
/** Called when clear control is used */
|
|
152
|
+
onClear?: (detail: {
|
|
153
|
+
clearedSelection: boolean;
|
|
154
|
+
clearedSearch: boolean;
|
|
155
|
+
}) => void;
|
|
137
156
|
/** Called on error */
|
|
138
157
|
onError?: (error: Error) => void;
|
|
139
158
|
}
|
|
@@ -154,6 +173,8 @@ export interface GlobalSelectConfig {
|
|
|
154
173
|
infiniteScroll: InfiniteScrollConfig;
|
|
155
174
|
/** Expandable dropdown configuration */
|
|
156
175
|
expandable: ExpandableConfig;
|
|
176
|
+
/** Clear control button configuration */
|
|
177
|
+
clearControl: ClearControlConfig;
|
|
157
178
|
/** Callbacks */
|
|
158
179
|
callbacks: CallbackConfig;
|
|
159
180
|
/** Enable/disable entire component */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './types.js';
|
|
2
|
-
export type { SelectEventDetail, OpenEventDetail, CloseEventDetail, SearchEventDetail, ChangeEventDetail, LoadMoreEventDetail, RemoveEventDetail, ErrorEventDetail, PageLoadedEventDetail, GroupedItem, RemoteConfig, Placement, Strategy, NativeSelectOptions, RendererHelpers, SelectEventsDetailMap, SelectEventName } from './types.js';
|
|
2
|
+
export type { SelectEventDetail, OpenEventDetail, CloseEventDetail, SearchEventDetail, ChangeEventDetail, LoadMoreEventDetail, RemoveEventDetail, ClearEventDetail, ErrorEventDetail, PageLoadedEventDetail, GroupedItem, RemoteConfig, Placement, Strategy, NativeSelectOptions, RendererHelpers, SelectEventsDetailMap, SelectEventName } from './types.js';
|
|
3
3
|
export type { CustomOptionContract, CustomOptionContext, CustomOptionFactory, ExtendedSelectItem, OptionRendererMode, CustomOptionConfig, CustomOptionEvents } from './types/custom-option.js';
|
|
4
4
|
export * from './renderers/contracts.js';
|
|
5
5
|
export * from './components/native-select.js';
|
|
@@ -55,6 +55,10 @@ export interface RemoveEventDetail {
|
|
|
55
55
|
item: unknown;
|
|
56
56
|
index: number;
|
|
57
57
|
}
|
|
58
|
+
export interface ClearEventDetail {
|
|
59
|
+
clearedSelection: boolean;
|
|
60
|
+
clearedSearch: boolean;
|
|
61
|
+
}
|
|
58
62
|
export interface SelectEventsDetailMap {
|
|
59
63
|
select: SelectEventDetail;
|
|
60
64
|
open: OpenEventDetail;
|
|
@@ -65,6 +69,7 @@ export interface SelectEventsDetailMap {
|
|
|
65
69
|
change: ChangeEventDetail;
|
|
66
70
|
loadMore: LoadMoreEventDetail;
|
|
67
71
|
remove: RemoveEventDetail;
|
|
72
|
+
clear: ClearEventDetail;
|
|
68
73
|
}
|
|
69
74
|
export type SelectEventName = keyof SelectEventsDetailMap;
|
|
70
75
|
export interface RendererHelpers {
|
|
@@ -58,7 +58,7 @@ export declare function applyDefaultTheme(element: HTMLElement): void;
|
|
|
58
58
|
* This CSS is CSP-safe because it's defined at build time as a string constant,
|
|
59
59
|
* not generated at runtime.
|
|
60
60
|
*/
|
|
61
|
-
export declare const shadowDOMStyles = "\n:host {\n display: block;\n box-sizing: border-box;\n font-family: var(--ns-font-family, system-ui, -apple-system, sans-serif);\n font-size: var(--ns-font-size, 14px);\n}\n\n* {\n box-sizing: border-box;\n}\n\n.ns-list {\n position: relative;\n overflow: auto;\n max-height: var(--ns-max-height, 300px);\n border: 1px solid var(--ns-border-color, #ccc);\n border-radius: var(--ns-border-radius, 4px);\n background: var(--ns-bg, white);\n outline: none;\n}\n\n.ns-list:focus {\n outline: var(--ns-focus-outline, 2px solid #0066cc);\n outline-offset: -2px;\n}\n\n.ns-item {\n padding: var(--ns-item-padding, 8px 12px);\n min-height: var(--ns-item-height, 40px);\n color: var(--ns-item-color, inherit);\n background: var(--ns-item-bg, transparent);\n cursor: pointer;\n user-select: none;\n display: flex;\n align-items: center;\n transition: background-color 0.15s ease;\n}\n\n.ns-item:hover {\n background: var(--ns-item-hover-bg, rgba(0, 0, 0, 0.05));\n}\n\n.ns-item[aria-selected=\"true\"] {\n background: var(--ns-item-selected-bg, rgba(0, 102, 204, 0.1));\n color: var(--ns-item-selected-color, #0066cc);\n}\n\n.ns-item[data-active=\"true\"] {\n background: var(--ns-item-active-bg, rgba(0, 102, 204, 0.2));\n}\n\n.ns-item[aria-disabled=\"true\"] {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.ns-viewport {\n position: relative;\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n}\n\n.ns-spacer {\n position: absolute;\n top: 0;\n left: 0;\n width: 1px;\n pointer-events: none;\n}\n\n/* Screen reader only */\n.ns-sr-only {\n position: absolute;\n left: -9999px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n}\n\n/* Portal mode (teleported outside shadow DOM) */\n.ns-portal {\n position: fixed;\n z-index: var(--ns-portal-z-index, 9999);\n}\n\n/* CSP warning banner (only shown in development) */\n.ns-csp-warning {\n padding: 8px;\n background: #fff3cd;\n border: 1px solid #ffc107;\n border-radius: 4px;\n color: #856404;\n font-size: 12px;\n margin-bottom: 8px;\n}\n";
|
|
61
|
+
export declare const shadowDOMStyles = "\n:host {\n display: block;\n box-sizing: border-box;\n font-family: var(--ns-font-family, system-ui, -apple-system, sans-serif);\n font-size: var(--ns-font-size, 14px);\n}\n\n* {\n box-sizing: border-box;\n}\n\n.ns-list {\n position: relative;\n overflow: auto;\n max-height: var(--ns-max-height, 300px);\n border: 1px solid var(--ns-border-color, #ccc);\n border-radius: var(--ns-border-radius, 4px);\n background: var(--ns-bg, white);\n outline: none;\n}\n\n.ns-list:focus {\n outline: var(--ns-focus-outline, 2px solid #0066cc);\n outline-offset: -2px;\n}\n\n.ns-item {\n padding: var(--ns-item-padding, 8px 12px);\n min-height: var(--ns-item-height, 40px);\n color: var(--ns-item-color, inherit);\n background: var(--ns-item-bg, transparent);\n cursor: pointer;\n user-select: none;\n display: flex;\n align-items: center;\n transition: background-color 0.15s ease;\n}\n\n.ns-item:hover {\n background: var(--ns-item-hover-bg, rgba(0, 0, 0, 0.05));\n}\n\n.ns-item[aria-selected=\"true\"] {\n background: var(--ns-item-selected-bg, rgba(0, 102, 204, 0.1));\n color: var(--ns-item-selected-color, #0066cc);\n}\n\n.ns-item[data-active=\"true\"]:not([aria-selected=\"true\"]) {\n background: var(--ns-item-active-bg, rgba(0, 102, 204, 0.2));\n}\n\n.ns-item[aria-selected=\"true\"][data-active=\"true\"] {\n background: var(--ns-item-selected-active-bg, var(--ns-item-selected-bg, rgba(0, 102, 204, 0.1)));\n color: var(--ns-item-selected-active-color, var(--ns-item-selected-color, #0066cc));\n outline: var(--ns-item-selected-active-outline, 2px solid #0066cc);\n outline-offset: -2px;\n}\n\n.ns-item[aria-disabled=\"true\"] {\n opacity: 0.5;\n cursor: not-allowed;\n}\n\n.ns-viewport {\n position: relative;\n overflow: auto;\n -webkit-overflow-scrolling: touch;\n}\n\n.ns-spacer {\n position: absolute;\n top: 0;\n left: 0;\n width: 1px;\n pointer-events: none;\n}\n\n/* Screen reader only */\n.ns-sr-only {\n position: absolute;\n left: -9999px;\n width: 1px;\n height: 1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n}\n\n/* Portal mode (teleported outside shadow DOM) */\n.ns-portal {\n position: fixed;\n z-index: var(--ns-portal-z-index, 9999);\n}\n\n/* CSP warning banner (only shown in development) */\n.ns-csp-warning {\n padding: 8px;\n background: #fff3cd;\n border: 1px solid #ffc107;\n border-radius: 4px;\n color: #856404;\n font-size: 12px;\n margin-bottom: 8px;\n}\n";
|
|
62
62
|
/**
|
|
63
63
|
* Inject static styles into shadow root (CSP-safe).
|
|
64
64
|
* Only called once during component initialization.
|
package/package.json
CHANGED