jb-select 7.0.1 → 7.0.4
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 +3 -2
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.br +0 -0
- package/dist/index.cjs.js.gz +0 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.br +0 -0
- package/dist/index.js.gz +0 -0
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.br +0 -0
- package/dist/index.umd.js.gz +0 -0
- package/dist/index.umd.js.map +1 -1
- package/dist/jb-select.d.ts +2 -1
- package/dist/jb-select.d.ts.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/lib/jb-select.css +42 -20
- package/lib/jb-select.ts +47 -64
- package/lib/types.ts +5 -1
- package/lib/variables.css +55 -0
- package/package.json +5 -4
- package/react/dist/JBSelect.d.ts +8 -7
- package/react/dist/attributes-hook.d.ts +5 -4
- package/react/dist/events-hook.d.ts +1 -1
- package/react/dist/index.cjs.js +1 -1
- package/react/dist/index.cjs.js.map +1 -1
- package/react/dist/index.js +1 -1
- package/react/dist/index.js.map +1 -1
- package/react/dist/index.umd.js +1 -1
- package/react/dist/index.umd.js.map +1 -1
- package/react/lib/JBSelect.tsx +12 -13
- package/react/lib/attributes-hook.ts +21 -9
- package/react/lib/events-hook.ts +1 -1
package/lib/jb-select.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type {
|
|
|
8
8
|
ValidationValue,
|
|
9
9
|
} from "./types";
|
|
10
10
|
import { type ShowValidationErrorParameters, ValidationHelper, type ValidationItem, type ValidationResult, type WithValidation } from "jb-validation";
|
|
11
|
-
import { isMobile } from "jb-core";
|
|
11
|
+
import { createInputEvent, createKeyboardEvent, isMobile } from "jb-core";
|
|
12
12
|
import type { JBFormInputStandards } from 'jb-form';
|
|
13
13
|
// eslint-disable-next-line no-duplicate-imports
|
|
14
14
|
import { JBOptionWebComponent } from "./jb-option/jb-option";
|
|
@@ -17,6 +17,7 @@ import { renderHTML } from "./render";
|
|
|
17
17
|
import { dictionary } from "./i18n";
|
|
18
18
|
import { i18n } from "jb-core/i18n";
|
|
19
19
|
import type { JBButtonWebComponent } from "jb-button";
|
|
20
|
+
import { JBPopoverWebComponent } from "jb-popover";
|
|
20
21
|
|
|
21
22
|
//TODO: add clean button to empty the select box after value selection
|
|
22
23
|
//TODO: add IncludeInputInList or freeSolo so user can select item that he wrote without even it exist in select list
|
|
@@ -31,7 +32,7 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
31
32
|
return true;
|
|
32
33
|
}
|
|
33
34
|
// we keep selected option here by option but we return TValue when user demand
|
|
34
|
-
#value: TValue;
|
|
35
|
+
#value: TValue| null;
|
|
35
36
|
#textValue = "";
|
|
36
37
|
// if user set value and current option list is not contain the option.
|
|
37
38
|
// we hold it in _notFoundedValue and select value when option value get updated
|
|
@@ -42,13 +43,13 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
42
43
|
callbacks: JBSelectCallbacks<TValue> = {}
|
|
43
44
|
elements!: JBSelectElements;
|
|
44
45
|
get value(): TValue {
|
|
45
|
-
if (this.#value) {
|
|
46
|
+
if (this.#value !== null && this.#value !== undefined) {
|
|
46
47
|
return this.#value;
|
|
47
48
|
} else {
|
|
48
49
|
return null;
|
|
49
50
|
}
|
|
50
51
|
}
|
|
51
|
-
set value(value: TValue) {
|
|
52
|
+
set value(value: TValue | null | undefined) {
|
|
52
53
|
this.#setValueFromOutside(value);
|
|
53
54
|
}
|
|
54
55
|
get textValue() {
|
|
@@ -120,10 +121,10 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
120
121
|
this.#disabled = value;
|
|
121
122
|
this.elements.input.disabled = value;
|
|
122
123
|
if (value) {
|
|
123
|
-
|
|
124
|
+
this.#internals.states?.add("disabled");
|
|
124
125
|
this.#internals.ariaDisabled = "true";
|
|
125
126
|
} else {
|
|
126
|
-
|
|
127
|
+
this.#internals.states?.delete("disabled");
|
|
127
128
|
this.#internals.ariaDisabled = "false";
|
|
128
129
|
}
|
|
129
130
|
}
|
|
@@ -142,11 +143,18 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
142
143
|
*/
|
|
143
144
|
get isAutoValidationDisabled(): boolean {
|
|
144
145
|
//currently we only support disable-validation in attribute and only in initiate time but later we can add support for change of this
|
|
145
|
-
return this.getAttribute('disable-auto-validation') === '' || this.getAttribute('disable-auto-validation') === 'true'
|
|
146
|
+
return !!(this.getAttribute('disable-auto-validation') === '' || this.getAttribute('disable-auto-validation') === 'true');
|
|
146
147
|
}
|
|
147
148
|
get name() {
|
|
148
149
|
return this.getAttribute('name') || '';
|
|
149
150
|
}
|
|
151
|
+
set name(value: string) {
|
|
152
|
+
if(value){
|
|
153
|
+
this.setAttribute('name', value);
|
|
154
|
+
}else{
|
|
155
|
+
this.removeAttribute('name');
|
|
156
|
+
}
|
|
157
|
+
}
|
|
150
158
|
initialValue: TValue | null = null;
|
|
151
159
|
get isDirty(): boolean {
|
|
152
160
|
return this.value !== this.initialValue;
|
|
@@ -162,9 +170,17 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
162
170
|
this.#initProp();
|
|
163
171
|
}
|
|
164
172
|
connectedCallback() {
|
|
165
|
-
// standard web component event that called when all of dom is
|
|
173
|
+
// standard web component event that called when all of dom is bound
|
|
166
174
|
this.#callOnLoadEvent();
|
|
167
175
|
this.#callOnInitEvent();
|
|
176
|
+
if (this.elements.optionListWrapper instanceof JBPopoverWebComponent) {
|
|
177
|
+
this.#setupPopover();
|
|
178
|
+
} else {
|
|
179
|
+
customElements.whenDefined("jb-popover").then(() =>this.#setupPopover())
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
#setupPopover(){
|
|
183
|
+
this.elements.optionListWrapper.bindTarget(this.elements.selectBox);
|
|
168
184
|
}
|
|
169
185
|
#callOnInitEvent() {
|
|
170
186
|
const event = new CustomEvent("init", { bubbles: true, composed: true });
|
|
@@ -201,6 +217,7 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
201
217
|
emptyListPlaceholder: shadowRoot.querySelector(".empty-list-placeholder")!,
|
|
202
218
|
mobileSearchInputWrapper: shadowRoot.querySelector(".mobile-search-input-wrapper"),
|
|
203
219
|
frontBox: shadowRoot.querySelector(".front-box"),
|
|
220
|
+
selectBox: shadowRoot.querySelector(".select-box")
|
|
204
221
|
};
|
|
205
222
|
this.#registerEventListener();
|
|
206
223
|
this.#updateListEmptyPlaceholder();
|
|
@@ -210,7 +227,7 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
210
227
|
* place code that change on select resize between mobile & desktop
|
|
211
228
|
*/
|
|
212
229
|
#setupDeviceRelates() {
|
|
213
|
-
const onResize = ()=> {
|
|
230
|
+
const onResize = () => {
|
|
214
231
|
if (isMobile()) {
|
|
215
232
|
this.elements.mobileSearchInputWrapper.appendChild(this.elements.input)
|
|
216
233
|
} else {
|
|
@@ -247,6 +264,7 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
247
264
|
return [
|
|
248
265
|
"label",
|
|
249
266
|
"message",
|
|
267
|
+
"hide-clear",
|
|
250
268
|
"value",
|
|
251
269
|
"required",
|
|
252
270
|
"placeholder",
|
|
@@ -293,6 +311,13 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
293
311
|
case "error":
|
|
294
312
|
this.reportValidity();
|
|
295
313
|
break;
|
|
314
|
+
case 'hide-clear':
|
|
315
|
+
if(value === '' || value === 'true'){
|
|
316
|
+
this.elements.clearButton.style.display = 'none'
|
|
317
|
+
}else{
|
|
318
|
+
this.elements.clearButton.style.display = 'block'
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
296
321
|
}
|
|
297
322
|
}
|
|
298
323
|
/**
|
|
@@ -306,7 +331,7 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
306
331
|
this.elements.emptyListPlaceholder.classList.add("--show");
|
|
307
332
|
}
|
|
308
333
|
}
|
|
309
|
-
#onOptionSlotChange(
|
|
334
|
+
#onOptionSlotChange(_e: Event) {
|
|
310
335
|
this.#setValueOnOptionListChanged();
|
|
311
336
|
this.#updateListEmptyPlaceholder();
|
|
312
337
|
}
|
|
@@ -326,7 +351,7 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
326
351
|
}
|
|
327
352
|
}
|
|
328
353
|
//when user set value by attribute or value prop directly we call this function
|
|
329
|
-
#setValueFromOutside(value: TValue): boolean {
|
|
354
|
+
#setValueFromOutside(value: TValue | null | undefined): boolean {
|
|
330
355
|
if (value === null || value === undefined) {
|
|
331
356
|
this.#setValue(null, null);
|
|
332
357
|
return true;
|
|
@@ -387,31 +412,15 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
387
412
|
this.focus();
|
|
388
413
|
}
|
|
389
414
|
}
|
|
390
|
-
#onClearButtonClick(e:MouseEvent) {
|
|
415
|
+
#onClearButtonClick(e: MouseEvent) {
|
|
391
416
|
e.stopPropagation();
|
|
392
417
|
e.preventDefault();
|
|
393
|
-
this.#setValue(null,null);
|
|
418
|
+
this.#setValue(null, null);
|
|
394
419
|
this.#checkValidity(true);
|
|
395
420
|
this.#dispatchOnChangeEvent();
|
|
396
421
|
}
|
|
397
422
|
#onInputKeyPress(e: KeyboardEvent) {
|
|
398
|
-
const
|
|
399
|
-
altKey: e.altKey,
|
|
400
|
-
bubbles: e.bubbles,
|
|
401
|
-
cancelable: e.cancelable,
|
|
402
|
-
code: e.code,
|
|
403
|
-
composed: e.composed,
|
|
404
|
-
ctrlKey: e.ctrlKey,
|
|
405
|
-
detail: e.detail,
|
|
406
|
-
isComposing: e.isComposing,
|
|
407
|
-
key: e.key,
|
|
408
|
-
location: e.location,
|
|
409
|
-
metaKey: e.metaKey,
|
|
410
|
-
view: e.view,
|
|
411
|
-
repeat: e.repeat,
|
|
412
|
-
shiftKey: e.shiftKey
|
|
413
|
-
};
|
|
414
|
-
const event = new KeyboardEvent("keypress", eventOptions);
|
|
423
|
+
const event = createKeyboardEvent("keypress", e, {})
|
|
415
424
|
this.dispatchEvent(event);
|
|
416
425
|
}
|
|
417
426
|
#onInputBeforeInput(_e: InputEvent) {
|
|
@@ -427,18 +436,7 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
427
436
|
this.#updateListEmptyPlaceholder();
|
|
428
437
|
}
|
|
429
438
|
#dispatchInputEvent(e: InputEvent) {
|
|
430
|
-
const event =
|
|
431
|
-
bubbles: e.bubbles,
|
|
432
|
-
cancelable: e.cancelable,
|
|
433
|
-
composed: e.composed,
|
|
434
|
-
data: e.data,
|
|
435
|
-
dataTransfer: e.dataTransfer,
|
|
436
|
-
detail: e.detail,
|
|
437
|
-
inputType: e.inputType,
|
|
438
|
-
isComposing: e.isComposing,
|
|
439
|
-
targetRanges: e.getTargetRanges(),
|
|
440
|
-
view: e.view,
|
|
441
|
-
});
|
|
439
|
+
const event = createInputEvent("input", e, {});
|
|
442
440
|
this.dispatchEvent(event);
|
|
443
441
|
}
|
|
444
442
|
#onInputKeyup(e: KeyboardEvent) {
|
|
@@ -459,24 +457,8 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
459
457
|
}
|
|
460
458
|
}
|
|
461
459
|
#triggerOnInputKeyup(e: KeyboardEvent) {
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
bubbles: e.bubbles,
|
|
465
|
-
cancelable: e.cancelable,
|
|
466
|
-
code: e.code,
|
|
467
|
-
ctrlKey: e.ctrlKey,
|
|
468
|
-
detail: e.detail,
|
|
469
|
-
key: e.key,
|
|
470
|
-
shiftKey: e.shiftKey,
|
|
471
|
-
charCode: e.charCode,
|
|
472
|
-
location: e.location,
|
|
473
|
-
composed: e.composed,
|
|
474
|
-
isComposing: e.isComposing,
|
|
475
|
-
metaKey: e.metaKey,
|
|
476
|
-
repeat: e.repeat,
|
|
477
|
-
keyCode: e.keyCode,
|
|
478
|
-
view: e.view,
|
|
479
|
-
});
|
|
460
|
+
|
|
461
|
+
const event = createKeyboardEvent('keyup', e, {})
|
|
480
462
|
this.dispatchEvent(event);
|
|
481
463
|
}
|
|
482
464
|
#onInputChange(e: Event) {
|
|
@@ -484,10 +466,11 @@ export class JBSelectWebComponent<TValue = any> extends HTMLElement implements W
|
|
|
484
466
|
//here is the rare time we update _text_value directly because we want trigger event that may read value directly from dom
|
|
485
467
|
this.#textValue = inputText;
|
|
486
468
|
}
|
|
487
|
-
#onSelectFocus() {
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
469
|
+
#onSelectFocus(e: FocusEvent) {
|
|
470
|
+
if (e.composedPath().find(x => x == this.elements.clearButton)) {
|
|
471
|
+
// we don't want focus when user click on clear button
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
491
474
|
this.focus();
|
|
492
475
|
}
|
|
493
476
|
#onInputBlur(e: FocusEvent) {
|
package/lib/types.ts
CHANGED
|
@@ -23,7 +23,8 @@ export type JBSelectElements = {
|
|
|
23
23
|
},
|
|
24
24
|
emptyListPlaceholder: HTMLDivElement,
|
|
25
25
|
mobileSearchInputWrapper:HTMLDivElement,
|
|
26
|
-
frontBox:HTMLDivElement
|
|
26
|
+
frontBox:HTMLDivElement,
|
|
27
|
+
selectBox:HTMLDivElement
|
|
27
28
|
}
|
|
28
29
|
export type ValidationValue<TValue> = {
|
|
29
30
|
selectedOption:JBOptionWebComponent<TValue> | null,
|
|
@@ -32,3 +33,6 @@ export type ValidationValue<TValue> = {
|
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
export type JBSelectEventType<TEvent> = EventTypeWithTarget<TEvent,JBSelectWebComponent>
|
|
36
|
+
|
|
37
|
+
/* Variants */
|
|
38
|
+
export type SizeVariants = 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
package/lib/variables.css
CHANGED
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
--border-width: var(--jb-select-border-width, 1px);
|
|
9
9
|
--border-bottom-width: var(--jb-select-border-bottom-width, var(--jb-select-border-width, 3px));
|
|
10
10
|
--base-z-index: 1;
|
|
11
|
+
--selected-value-font-size:var(--jb-select-selected-value-font-size, 1rem);
|
|
12
|
+
--input-font-size:var(--jb-select-input-font-size, 1rem);
|
|
13
|
+
--selected-value-padding:var(--jb-select-selected-value-padding, 0.125rem 0.75rem 0 0.75rem);
|
|
14
|
+
--inline-slots-padding:0.375rem 0.625rem;
|
|
15
|
+
--clear-icon-size: 1rem;
|
|
11
16
|
/* put message and label forward base on border radius*/
|
|
12
17
|
--inline-space: calc(var(--rounded) / 1.75);
|
|
13
18
|
--label-margin: var(--jb-select-label-margin, 0.125rem var(--inline-space));
|
|
@@ -31,4 +36,54 @@
|
|
|
31
36
|
|
|
32
37
|
:host(:focus-within) {
|
|
33
38
|
--border-color: var(--jb-select-border-color-focus, var(--jb-neutral));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/*Size*/
|
|
42
|
+
:host([size="xs"]){
|
|
43
|
+
--height:var(--jb-select-height-xs, 1.5rem);
|
|
44
|
+
--selected-value-font-size:var(--jb-select-selected-value-font-size-xs, 0.75rem);
|
|
45
|
+
--input-font-size:var(--jb-select-input-font-size-xs, 0.75rem);
|
|
46
|
+
--label-font-size:var(--jb-select-label-font-size-xs, 0.6rem);
|
|
47
|
+
/*0.7 - (0.0875 *2) */
|
|
48
|
+
--message-font-size:var(--jb-select-message-font-size-xs, 0.525rem);
|
|
49
|
+
/* 0.375 = radius-xs - (0.25*radius-xs) */
|
|
50
|
+
--selected-value-padding:var(--jb-select-selected-value-padding-xs, 0.125rem 0.375rem 0 0.375rem);
|
|
51
|
+
--rounded: var(--jb-select-rounded-xs, var(--jb-radius-xs));
|
|
52
|
+
--inline-slots-padding:0.125rem 0.25rem;
|
|
53
|
+
--clear-icon-size: 0.5rem;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
:host([size="sm"]){
|
|
57
|
+
--height: var(--jb-select-height-sm, 2rem);
|
|
58
|
+
--selected-value-font-size:var(--jb-select-selected-value-font-size-sm, 0.875rem);
|
|
59
|
+
--input-font-size:var(--jb-select-input-font-size-sm, 0.875rem);
|
|
60
|
+
--label-font-size:var(--jb-select-label-font-size-sm, 0.7rem);
|
|
61
|
+
--message-font-size:var(--jb-select-message-font-size-sm, 0.6125rem);
|
|
62
|
+
--selected-value-padding:var(--jb-select-selected-value-padding-sm, 0.125rem 0.5625rem 0 0.5625rem);
|
|
63
|
+
--rounded: var(--jb-select-rounded-sm, var(--jb-radius-sm));
|
|
64
|
+
--inline-slots-padding:0.25rem 0.5rem;
|
|
65
|
+
--clear-icon-size: 0.75rem;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
:host([size="lg"]){
|
|
69
|
+
--height: var(--jb-select-height-lg, 3rem);
|
|
70
|
+
--selected-value-font-size:var(--jb-select-selected-value-font-size-lg, 1.125rem);
|
|
71
|
+
--input-font-size:var(--jb-select-input-font-size-lg, 1.125rem);
|
|
72
|
+
--label-font-size:var(--jb-select-label-font-size-lg, 0.9rem);
|
|
73
|
+
/*0.7 + 0.0875*/
|
|
74
|
+
--message-font-size:var(--jb-select-message-font-size-lg, 0.7875rem);
|
|
75
|
+
--selected-value-padding:var(--jb-select-selected-value-padding-lg, 0.125rem 0.9375rem 0 0.9375rem);
|
|
76
|
+
--rounded: var(--jb-select-rounded-lg, var(--jb-radius-lg));
|
|
77
|
+
--inline-slots-padding:0.5rem 0.75rem;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
:host([size="xl"]){
|
|
81
|
+
--height: var(--jb-select-height-xl, 4rem);
|
|
82
|
+
--selected-value-font-size:var(--jb-select-selected-value-font-size-xl, 1.25rem);
|
|
83
|
+
--input-font-size:var(--jb-select-input-font-size-xl, 1.25rem);
|
|
84
|
+
--label-font-size:var(--jb-select-label-font-size-xl, 1rem);
|
|
85
|
+
--message-font-size:var(--jb-select-message-font-size-xl, 0.875rem);
|
|
86
|
+
--selected-value-padding:var(--jb-select-selected-value-padding-xl, 0.125rem 1.125rem 0 1.125rem);
|
|
87
|
+
--rounded: var(--jb-select-rounded-xl, var(--jb-radius-xl));
|
|
88
|
+
--inline-slots-padding:0.75rem 1rem;
|
|
34
89
|
}
|
package/package.json
CHANGED
|
@@ -16,8 +16,9 @@
|
|
|
16
16
|
"web component",
|
|
17
17
|
"react component"
|
|
18
18
|
],
|
|
19
|
-
"version": "7.0.
|
|
19
|
+
"version": "7.0.4",
|
|
20
20
|
"bugs": "https://github.com/javadbat/jb-select/issues",
|
|
21
|
+
"homepage": "https://javadbat.github.io/design-system/?path=/story/components-form-elements-jbselect",
|
|
21
22
|
"license": "MIT",
|
|
22
23
|
"files": [
|
|
23
24
|
"LICENSE",
|
|
@@ -35,9 +36,9 @@
|
|
|
35
36
|
},
|
|
36
37
|
"dependencies": {
|
|
37
38
|
"jb-validation": ">=0.4.0",
|
|
38
|
-
"jb-button": ">=3.
|
|
39
|
-
"jb-popover": ">=1.
|
|
40
|
-
"jb-core":">=0.
|
|
39
|
+
"jb-button": ">=3.8.0",
|
|
40
|
+
"jb-popover": ">=1.6.0",
|
|
41
|
+
"jb-core":">=0.24.0"
|
|
41
42
|
},
|
|
42
43
|
"devDependencies": {
|
|
43
44
|
"jb-form":">=0.7.1"
|
package/react/dist/JBSelect.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { type PropsWithChildren } from 'react';
|
|
2
2
|
import 'jb-select';
|
|
3
|
-
import { JBSelectWebComponent } from 'jb-select';
|
|
4
|
-
import { EventProps } from './events-hook.js';
|
|
3
|
+
import type { JBSelectWebComponent, SizeVariants } from 'jb-select';
|
|
4
|
+
import { type EventProps } from './events-hook.js';
|
|
5
5
|
import { type JBSelectAttributes } from './attributes-hook.js';
|
|
6
|
+
import type { JBElementStandardProps } from 'jb-core/react';
|
|
6
7
|
export type JBSelectEventType<T> = T & {
|
|
7
8
|
target: JBSelectWebComponent;
|
|
8
9
|
};
|
|
@@ -18,6 +19,8 @@ declare module "react" {
|
|
|
18
19
|
required?: string | boolean;
|
|
19
20
|
message?: string;
|
|
20
21
|
tabindex?: string;
|
|
22
|
+
size?: string;
|
|
23
|
+
"hide-clean"?: string;
|
|
21
24
|
}
|
|
22
25
|
}
|
|
23
26
|
}
|
|
@@ -25,9 +28,7 @@ export declare function JBSelect<TValue>(props: Props<TValue>): React.JSX.Elemen
|
|
|
25
28
|
export declare namespace JBSelect {
|
|
26
29
|
var displayName: string;
|
|
27
30
|
}
|
|
28
|
-
export type Props<TValue> = EventProps & JBSelectAttributes<TValue
|
|
31
|
+
export type Props<TValue> = PropsWithChildren<EventProps & JBSelectAttributes<TValue>> & JBElementStandardProps<JBSelectWebComponent, keyof EventProps & JBSelectAttributes<TValue>> & {
|
|
29
32
|
ref?: React.RefObject<JBSelectWebComponent>;
|
|
30
|
-
|
|
31
|
-
className?: string;
|
|
32
|
-
children?: React.ReactNode;
|
|
33
|
+
size?: SizeVariants;
|
|
33
34
|
};
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import { JBSelectWebComponent,
|
|
2
|
-
import {
|
|
3
|
-
import { RefObject } from "react";
|
|
1
|
+
import type { JBSelectWebComponent, ValidationValue } from "jb-select";
|
|
2
|
+
import type { ValidationItem } from "jb-validation";
|
|
3
|
+
import { type RefObject } from "react";
|
|
4
4
|
export type JBSelectAttributes<TValue> = {
|
|
5
5
|
validationList?: ValidationItem<ValidationValue<TValue>>[];
|
|
6
6
|
name?: string;
|
|
7
7
|
label?: string;
|
|
8
8
|
error?: string;
|
|
9
|
-
value?:
|
|
9
|
+
value?: TValue;
|
|
10
10
|
message?: string;
|
|
11
11
|
placeholder?: string;
|
|
12
12
|
searchPlaceholder?: string;
|
|
13
13
|
required?: boolean;
|
|
14
|
+
hideClear?: boolean;
|
|
14
15
|
getSelectedValueDOM?: (option: any) => HTMLElement;
|
|
15
16
|
};
|
|
16
17
|
export declare function useJBSelectAttribute<TValue>(element: RefObject<JBSelectWebComponent>, props: JBSelectAttributes<TValue>): void;
|
package/react/dist/index.cjs.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,r=Object.getOwnPropertyDescriptor,u=Object.getOwnPropertyNames,l=Object.getPrototypeOf,n=Object.prototype.hasOwnProperty,c=(e,l,c,a)=>{if(l&&"object"==typeof l||"function"==typeof l)for(var o,i=u(l),s=0,f=i.length;s<f;s++)o=i[s],n.call(e,o)||o===c||t(e,o,{get:(e=>l[e]).bind(null,o),enumerable:!(a=r(l,o))||a.enumerable});return e},a=(r,u,n)=>(n=null!=r?e(l(r)):{},c(!u&&r&&r.__esModule?n:t(n,"default",{value:r,enumerable:!0}),r));const o=a(require("react"));require("jb-select");const i=a(require("jb-core/react")),s=o.default.forwardRef((e,t)=>{let r=(0,o.useRef)(null);return(0,o.useImperativeHandle)(t,()=>r?r.current:void 0,[r]),(0,o.useEffect)(()=>{r.current&&Array.isArray(e.optionList)&&(r.current.optionList=e.optionList)},[e.optionList,r]),(0,o.useEffect)(()=>{r.current&&"function"==typeof e.getTitle&&r.current.setCallback("getTitle",e.getTitle)},[e.getTitle,r]),(0,o.useEffect)(()=>{r.current&&"function"==typeof e.getValue&&r.current.setCallback("getValue",e.getValue)},[e.getValue,r]),(0,o.useEffect)(()=>{r.current&&"function"==typeof e.getContentDOM&&r.current.setCallback("getContentDOM",e.getContentDOM)},[e.getContentDOM,r]),o.default.createElement("jb-option-list",{ref:r})});function f(e){var t,r;let u=(0,o.useRef)(null);(0,o.useImperativeHandle)(e.ref,()=>u?u.current:void 0,[u]);let{onChange:l,onInit:n,onInput:c,onKeyUp:a,onLoad:s,error:f,getSelectedValueDOM:d,label:p,name:b,required:v,message:m,placeholder:g,searchPlaceholder:h,validationList:E,value:O,hideClear:y,...A}=e;return t={onChange:l,onInit:n,onInput:c,onKeyUp:a,onLoad:s},(0,i.useEvent)(u,"load",t.onLoad,!0),(0,i.useEvent)(u,"init",t.onInit,!0),(0,i.useEvent)(u,"keyup",t.onKeyUp),(0,i.useEvent)(u,"change",t.onChange),(0,i.useEvent)(u,"input",t.onInput),r={error:f,getSelectedValueDOM:d,label:p,name:b,required:v,message:m,placeholder:g,searchPlaceholder:h,validationList:E,value:O,hideClear:y},(0,o.useEffect)(()=>{null!==r.message&&void 0!==r.message?u.current?.setAttribute("message",r.message):u.current?.removeAttribute("message")},[r.message]),(0,o.useEffect)(()=>{u?.current&&(u.current.validation.list=r.validationList||[])},[u.current,r.validationList]),(0,o.useEffect)(()=>{null!==r.label&&void 0!==r.label?u.current?.setAttribute("label",r.label):u.current?.removeAttribute("label")},[r.label,u.current]),(0,o.useEffect)(()=>{null!==r.required&&void 0!==r.required?u.current?.setAttribute("required",""):u.current?.removeAttribute("required")},[r.required,u]),(0,o.useEffect)(()=>{null!==r.hideClear&&void 0!==r.hideClear?u.current?.setAttribute("hide-clear",""):u.current?.removeAttribute("hide-clear")},[r.hideClear,u]),(0,o.useEffect)(()=>{null!==r.placeholder&&void 0!==r.placeholder&&u.current?.setAttribute("placeholder",r.placeholder)},[r.placeholder,u]),(0,o.useEffect)(()=>{null!==r.searchPlaceholder&&void 0!==r.searchPlaceholder&&u.current?.setAttribute("search-placeholder",r.searchPlaceholder)},[r.searchPlaceholder]),(0,o.useEffect)(()=>{r.error?u?.current?.setAttribute("error",r.error):u?.current?.removeAttribute("error")},[r.error]),(0,o.useEffect)(()=>{r.name?u?.current?.setAttribute("name",r.name||""):u?.current?.removeAttribute("name")},[r.name]),(0,o.useEffect)(()=>{u.current&&(u.current.value=r.value)},[r.value]),(0,o.useEffect)(()=>{"function"==typeof r.getSelectedValueDOM&&u.current&&u.current&&(u.current.callbacks.getSelectedValueDOM=r.getSelectedValueDOM)},[r.getSelectedValueDOM]),o.default.createElement("jb-select",{ref:u,...A},e.children)}s.displayName="JBOptionList",f.displayName="JBSelect";const d=o.default.forwardRef((e,t)=>{let r=(0,o.useRef)(null),{value:u,children:l,className:n,...c}=e;return(0,o.useImperativeHandle)(t,()=>r?r.current:void 0,[r]),(0,o.useEffect)(()=>{r.current&&void 0!==u&&(r.current.value=u)},[u,r]),o.default.createElement("jb-option",{class:n,ref:r,...c},l)});d.displayName="JBOption",exports.JBOption=d,exports.JBOptionList=s,exports.JBSelect=f;
|
|
2
2
|
//# sourceMappingURL=index.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","names":[],"sources":["../lib/JBOptionList.tsx","../lib/events-hook.ts","../lib/attributes-hook.ts","../lib/JBSelect.tsx","../lib/JBOption.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAY,+BAAuB,cAAA,WAAqB,CAAA,OAAM,QAAO;CAkBrE,MAAO,UAAM,kBAAY,KAAG;AAC1B,gCAAgB,KAAkD,MAAK,UAAA,QAAA,kBAAA,CACvE,OAKA,EAAA;sBACM,MAAA;MACF,QAAQ,WAAQ,MAAA,QAAa,MAAM,WAAU,CAC/C,SAAA,QAAA,aAAA,MAAA;CAEF,GAAA,CACE,MAAI;AAGN,sBAAU,MAAA;AACV,MAAA,QAAe,kBAAA,MAAA,YAAA,WACT,SAAQ,QAAO,YAAW,YAAc,MAAI,SAAU;KAGxD,MAAM,UACV;sBAEI,MAAA;AACF,MAAA,QAAA,kBAAA,MAAA,YAAA,WACE,SAAM,QAAa,YAAW,YAAA,MAAA,SAAA;CAKlC,GAAA,CAQF,MAAa;;;;;;;;;;AC1Cb,SAAgB,UAAU,SAA0C,OAAiB;AACnF,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,SAA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A,YAAA,GAAA;AAC3D,WAAA,SAAA;EACA;EAKF;EAAC;EAMO;;;;;;;;;;;;;;;;;;;;;;;;;ACjDR,MAAY,2BAAuB,cAAA,WAAmB,CAAqC,OAAM,QAAO;CAgBxG,MAAO,UAAM,kBAAW,KAAM;CAC5B,MAAM,EAAA,OAAO,UAAwC,UAAK,GAAA,MAAA,GAAA;AAC1D,gCAAa,KAAS,MAAA,UAAc,QAAK,kBAAQ,CACjD,OAMA,EAAA;sBACM,MAAA;MACF,QAAQ,WAAQ,iBAClB,SAAA,QAAA,QAAA;CAGF,GAAA,CAKA,OAOM"}
|
package/react/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import e,{useEffect as t,useImperativeHandle as r,useRef as l}from"react";import"jb-select";import{useEvent as n}from"jb-core/react";let
|
|
1
|
+
import e,{useEffect as t,useImperativeHandle as r,useRef as l}from"react";import"jb-select";import{useEvent as n}from"jb-core/react";let u=e.forwardRef((n,u)=>{let a=l(null);return r(u,()=>a?a.current:void 0,[a]),t(()=>{a.current&&Array.isArray(n.optionList)&&(a.current.optionList=n.optionList)},[n.optionList,a]),t(()=>{a.current&&"function"==typeof n.getTitle&&a.current.setCallback("getTitle",n.getTitle)},[n.getTitle,a]),t(()=>{a.current&&"function"==typeof n.getValue&&a.current.setCallback("getValue",n.getValue)},[n.getValue,a]),t(()=>{a.current&&"function"==typeof n.getContentDOM&&a.current.setCallback("getContentDOM",n.getContentDOM)},[n.getContentDOM,a]),e.createElement("jb-option-list",{ref:a})});function a(u){var a,i;let c=l(null);r(u.ref,()=>c?c.current:void 0,[c]);let{onChange:o,onInit:s,onInput:d,onKeyUp:p,onLoad:b,error:m,getSelectedValueDOM:g,label:v,name:h,required:f,message:A,placeholder:O,searchPlaceholder:y,validationList:C,value:L,hideClear:D,...M}=u;return n(c,"load",(a={onChange:o,onInit:s,onInput:d,onKeyUp:p,onLoad:b}).onLoad,!0),n(c,"init",a.onInit,!0),n(c,"keyup",a.onKeyUp),n(c,"change",a.onChange),n(c,"input",a.onInput),i={error:m,getSelectedValueDOM:g,label:v,name:h,required:f,message:A,placeholder:O,searchPlaceholder:y,validationList:C,value:L,hideClear:D},t(()=>{null!==i.message&&void 0!==i.message?c.current?.setAttribute("message",i.message):c.current?.removeAttribute("message")},[i.message]),t(()=>{c?.current&&(c.current.validation.list=i.validationList||[])},[c.current,i.validationList]),t(()=>{null!==i.label&&void 0!==i.label?c.current?.setAttribute("label",i.label):c.current?.removeAttribute("label")},[i.label,c.current]),t(()=>{null!==i.required&&void 0!==i.required?c.current?.setAttribute("required",""):c.current?.removeAttribute("required")},[i.required,c]),t(()=>{null!==i.hideClear&&void 0!==i.hideClear?c.current?.setAttribute("hide-clear",""):c.current?.removeAttribute("hide-clear")},[i.hideClear,c]),t(()=>{null!==i.placeholder&&void 0!==i.placeholder&&c.current?.setAttribute("placeholder",i.placeholder)},[i.placeholder,c]),t(()=>{null!==i.searchPlaceholder&&void 0!==i.searchPlaceholder&&c.current?.setAttribute("search-placeholder",i.searchPlaceholder)},[i.searchPlaceholder]),t(()=>{i.error?c?.current?.setAttribute("error",i.error):c?.current?.removeAttribute("error")},[i.error]),t(()=>{i.name?c?.current?.setAttribute("name",i.name||""):c?.current?.removeAttribute("name")},[i.name]),t(()=>{c.current&&(c.current.value=i.value)},[i.value]),t(()=>{"function"==typeof i.getSelectedValueDOM&&c.current&&c.current&&(c.current.callbacks.getSelectedValueDOM=i.getSelectedValueDOM)},[i.getSelectedValueDOM]),e.createElement("jb-select",{ref:c,...M},u.children)}u.displayName="JBOptionList",a.displayName="JBSelect";let i=e.forwardRef((n,u)=>{let a=l(null),{value:i,children:c,className:o,...s}=n;return r(u,()=>a?a.current:void 0,[a]),t(()=>{a.current&&void 0!==i&&(a.current.value=i)},[i,a]),e.createElement("jb-option",{class:o,ref:a,...s},c)});i.displayName="JBOption";export{i as JBOption,u as JBOptionList,a as JBSelect};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/react/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../lib/JBOptionList.tsx","../lib/events-hook.ts","../lib/attributes-hook.ts","../lib/JBSelect.tsx","../lib/JBOption.tsx"],"sourcesContent":[],"mappings":";;;;;AAEA,MAAY,+BAAuB,MAAA,WAAqB,CAAA,OAAM,QAAO;CAkBrE,MAAO,UAAM,OAAY,KAAG;AAC1B,qBAAgB,KAAkD,MAAK,UAAA,QAAA,kBAAA,CACvE,OAKA,EAAA;WACM,MAAA;MACF,QAAQ,WAAQ,MAAA,QAAa,MAAM,WAAU,CAC/C,SAAA,QAAA,aAAA,MAAA;CAEF,GAAA,CACE,MAAI;AAGN,WAAU,MAAA;AACV,MAAA,QAAe,kBAAA,MAAA,YAAA,WACT,SAAQ,QAAO,YAAW,YAAc,MAAI,SAAU;KAGxD,MAAM,UACV;WAEI,MAAA;AACF,MAAA,QAAA,kBAAA,MAAA,YAAA,WACE,SAAM,QAAa,YAAW,YAAA,MAAA,SAAA;CAKlC,GAAA,CAQF,MAAa;;;;;;;;;;AC1Cb,SAAgB,UAAU,SAA0C,OAAiB;AACnF,UAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,UAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,UAAS,SAAS,SAAS,MAAM,QAAQ;AACzC,UAAS,SAAS,UAAU,MAAM,SAAS;AAC3C,UAAS,SAAS,SAAS,MAAM,QAAQ;AAC3C;;;;
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../lib/JBOptionList.tsx","../lib/events-hook.ts","../lib/attributes-hook.ts","../lib/JBSelect.tsx","../lib/JBOption.tsx"],"sourcesContent":[],"mappings":";;;;;AAEA,MAAY,+BAAuB,MAAA,WAAqB,CAAA,OAAM,QAAO;CAkBrE,MAAO,UAAM,OAAY,KAAG;AAC1B,qBAAgB,KAAkD,MAAK,UAAA,QAAA,kBAAA,CACvE,OAKA,EAAA;WACM,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){var u=Object.create,n=Object.defineProperty,c=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,
|
|
1
|
+
var e,t;e=this,t=function(e,t,r,l){var u=Object.create,n=Object.defineProperty,c=Object.getOwnPropertyDescriptor,a=Object.getOwnPropertyNames,o=Object.getPrototypeOf,i=Object.prototype.hasOwnProperty,s=(e,t,r,l)=>{if(t&&"object"==typeof t||"function"==typeof t)for(var u,o=a(t),s=0,f=o.length;s<f;s++)u=o[s],i.call(e,u)||u===r||n(e,u,{get:(e=>t[e]).bind(null,u),enumerable:!(l=c(t,u))||l.enumerable});return e},f=(e,t,r)=>(r=null!=e?u(o(e)):{},s(!t&&e&&e.__esModule?r:n(r,"default",{value:e,enumerable:!0}),e));t=f(t),l=f(l);let d=t.default.forwardRef((e,r)=>{let l=(0,t.useRef)(null);return(0,t.useImperativeHandle)(r,()=>l?l.current:void 0,[l]),(0,t.useEffect)(()=>{l.current&&Array.isArray(e.optionList)&&(l.current.optionList=e.optionList)},[e.optionList,l]),(0,t.useEffect)(()=>{l.current&&"function"==typeof e.getTitle&&l.current.setCallback("getTitle",e.getTitle)},[e.getTitle,l]),(0,t.useEffect)(()=>{l.current&&"function"==typeof e.getValue&&l.current.setCallback("getValue",e.getValue)},[e.getValue,l]),(0,t.useEffect)(()=>{l.current&&"function"==typeof e.getContentDOM&&l.current.setCallback("getContentDOM",e.getContentDOM)},[e.getContentDOM,l]),t.default.createElement("jb-option-list",{ref:l})});function p(e){var r,u;let n=(0,t.useRef)(null);(0,t.useImperativeHandle)(e.ref,()=>n?n.current:void 0,[n]);let{onChange:c,onInit:a,onInput:o,onKeyUp:i,onLoad:s,error:f,getSelectedValueDOM:d,label:p,name:b,required:v,message:m,placeholder:g,searchPlaceholder:h,validationList:E,value:y,hideClear:O,...A}=e;return r={onChange:c,onInit:a,onInput:o,onKeyUp:i,onLoad:s},(0,l.useEvent)(n,"load",r.onLoad,!0),(0,l.useEvent)(n,"init",r.onInit,!0),(0,l.useEvent)(n,"keyup",r.onKeyUp),(0,l.useEvent)(n,"change",r.onChange),(0,l.useEvent)(n,"input",r.onInput),u={error:f,getSelectedValueDOM:d,label:p,name:b,required:v,message:m,placeholder:g,searchPlaceholder:h,validationList:E,value:y,hideClear:O},(0,t.useEffect)(()=>{null!==u.message&&void 0!==u.message?n.current?.setAttribute("message",u.message):n.current?.removeAttribute("message")},[u.message]),(0,t.useEffect)(()=>{n?.current&&(n.current.validation.list=u.validationList||[])},[n.current,u.validationList]),(0,t.useEffect)(()=>{null!==u.label&&void 0!==u.label?n.current?.setAttribute("label",u.label):n.current?.removeAttribute("label")},[u.label,n.current]),(0,t.useEffect)(()=>{null!==u.required&&void 0!==u.required?n.current?.setAttribute("required",""):n.current?.removeAttribute("required")},[u.required,n]),(0,t.useEffect)(()=>{null!==u.hideClear&&void 0!==u.hideClear?n.current?.setAttribute("hide-clear",""):n.current?.removeAttribute("hide-clear")},[u.hideClear,n]),(0,t.useEffect)(()=>{null!==u.placeholder&&void 0!==u.placeholder&&n.current?.setAttribute("placeholder",u.placeholder)},[u.placeholder,n]),(0,t.useEffect)(()=>{null!==u.searchPlaceholder&&void 0!==u.searchPlaceholder&&n.current?.setAttribute("search-placeholder",u.searchPlaceholder)},[u.searchPlaceholder]),(0,t.useEffect)(()=>{u.error?n?.current?.setAttribute("error",u.error):n?.current?.removeAttribute("error")},[u.error]),(0,t.useEffect)(()=>{u.name?n?.current?.setAttribute("name",u.name||""):n?.current?.removeAttribute("name")},[u.name]),(0,t.useEffect)(()=>{n.current&&(n.current.value=u.value)},[u.value]),(0,t.useEffect)(()=>{"function"==typeof u.getSelectedValueDOM&&n.current&&n.current&&(n.current.callbacks.getSelectedValueDOM=u.getSelectedValueDOM)},[u.getSelectedValueDOM]),t.default.createElement("jb-select",{ref:n,...A},e.children)}d.displayName="JBOptionList",p.displayName="JBSelect";let b=t.default.forwardRef((e,r)=>{let l=(0,t.useRef)(null),{value:u,children:n,className:c,...a}=e;return(0,t.useImperativeHandle)(r,()=>l?l.current:void 0,[l]),(0,t.useEffect)(()=>{l.current&&void 0!==u&&(l.current.value=u)},[u,l]),t.default.createElement("jb-option",{class:c,ref:l,...a},n)});b.displayName="JBOption",e.JBOption=b,e.JBOptionList=d,e.JBSelect=p},"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("jb-select"),require("jb-core/react")):"function"==typeof define&&define.amd?define(["exports","react","jb-select","jb-core/react"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).JBSelectReact={},e.React,e.JBSelect,e.JBCoreReact);
|
|
2
2
|
//# sourceMappingURL=index.umd.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.umd.js","names":[],"sources":["../lib/JBOptionList.tsx","../lib/events-hook.ts","../lib/attributes-hook.ts","../lib/JBSelect.tsx","../lib/JBOption.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAY,+BAAuB,cAAA,WAAqB,CAAA,OAAM,QAAO;CAkBrE,MAAO,UAAM,kBAAY,KAAG;AAC1B,gCAAgB,KAAkD,MAAK,UAAA,QAAA,kBAAA,CACvE,OAKA,EAAA;sBACM,MAAA;MACF,QAAQ,WAAQ,MAAA,QAAa,MAAM,WAAU,CAC/C,SAAA,QAAA,aAAA,MAAA;CAEF,GAAA,CACE,MAAI;AAGN,sBAAU,MAAA;AACV,MAAA,QAAe,kBAAA,MAAA,YAAA,WACT,SAAQ,QAAO,YAAW,YAAc,MAAI,SAAU;KAGxD,MAAM,UACV;sBAEI,MAAA;AACF,MAAA,QAAA,kBAAA,MAAA,YAAA,WACE,SAAM,QAAa,YAAW,YAAA,MAAA,SAAA;CAKlC,GAAA,CAQF,MAAa;;;;;;;;;;AC1Cb,SAAgB,UAAU,SAA0C,OAAiB;AACnF,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,SAAS,MAAM,QAAQ;AACzC,6BAAS,SAAS,UAAU,MAAM,SAAS;AAC3C,6BAAS,SAAS,SAAS,MAAM,QAAQ;AAC3C;;;;
|
|
1
|
+
{"version":3,"file":"index.umd.js","names":[],"sources":["../lib/JBOptionList.tsx","../lib/events-hook.ts","../lib/attributes-hook.ts","../lib/JBSelect.tsx","../lib/JBOption.tsx"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAY,+BAAuB,cAAA,WAAqB,CAAA,OAAM,QAAO;CAkBrE,MAAO,UAAM,kBAAY,KAAG;AAC1B,gCAAgB,KAAkD,MAAK,UAAA,QAAA,kBAAA,CACvE,OAKA,EAAA;sBACM,MAAA;MACF,QAAQ,WAAQ,MAAA,QAAa,MAAM,WAAU,CAC/C,SAAA,QAAA,aAAA,MAAA;CAEF,GAAA,CACE,MAAI;AAGN,sBAAU,MAAA;AACV,MAAA,QAAe,kBAAA,MAAA,YAAA,WACT,SAAQ,QAAO,YAAW,YAAc,MAAI,SAAU;KAGxD,MAAM,UACV;sBAEI,MAAA;AACF,MAAA,QAAA,kBAAA,MAAA,YAAA,WACE,SAAM,QAAa,YAAW,YAAA,MAAA,SAAA;CAKlC,GAAA,CAQF,MAAa;;;;;;;;;;AC1Cb,SAAgB,UAAU,SAA0C,OAAiB;AACnF,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,QAAQ,MAAM,QAAQ,KAAK;AAC7C,6BAAS,SAAS,SAAS,MAAM,QAAQ;AACzC,6BAAS,SAAS,UAAU,MAAM,SAAS;AAC3C,6BAAS,SAAS,SAAS,MAAM,QAAQ;AAC3C;;;;ACLA,SAAgB,qBAA6B,SAA0C,OAAiC;AACtH,sBAAU,MAAG;AACX,MAAI,MAAM,YAAY,QAAQ,MAAM,mBAClC,SAAQ,SAAS,aAAa,WAAW,MAAM,QAAQ;eAClD,SAAA,gBAAA,UAAA;KAGL,MA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A,OAAA,UAAA,GAAA,YAAA,GAAA;AAC3D,WAAA,SAAA;EACA;EAKF;EAAC;EAMO;;;;;;;;;;;;;;;;;;;;;;;;;ACjDR,MAAY,2BAAuB,cAAA,WAAmB,CAAqC,OAAM,QAAO;CAgBxG,MAAO,UAAM,kBAAW,KAAM;CAC5B,MAAM,EAAA,OAAO,UAAwC,UAAK,GAAA,MAAA,GAAA;AAC1D,gCAAa,KAAS,MAAA,UAAc,QAAK,kBAAQ,CACjD,OAMA,EAAA;sBACM,MAAA;MACF,QAAQ,WAAQ,iBAClB,SAAA,QAAA,QAAA;CAGF,GAAA,CAKA,OAOM"}
|
package/react/lib/JBSelect.tsx
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
/* eslint-disable react/display-name */
|
|
3
|
-
import React, { useRef, useImperativeHandle,
|
|
3
|
+
import React, { useRef, useImperativeHandle, type PropsWithChildren } from 'react';
|
|
4
4
|
import 'jb-select';
|
|
5
5
|
// eslint-disable-next-line no-duplicate-imports
|
|
6
|
-
import { JBSelectWebComponent } from 'jb-select';
|
|
7
|
-
import { EventProps, useEvents } from './events-hook.js';
|
|
6
|
+
import type { JBSelectWebComponent, SizeVariants } from 'jb-select';
|
|
7
|
+
import { type EventProps, useEvents } from './events-hook.js';
|
|
8
8
|
import { useJBSelectAttribute, type JBSelectAttributes } from './attributes-hook.js';
|
|
9
|
+
import type { JBElementStandardProps } from 'jb-core/react';
|
|
9
10
|
export type JBSelectEventType<T> = T & {
|
|
10
11
|
target: JBSelectWebComponent
|
|
11
12
|
}
|
|
@@ -22,7 +23,8 @@ declare module "react" {
|
|
|
22
23
|
required?:string | boolean,
|
|
23
24
|
message?:string,
|
|
24
25
|
tabindex?:string,
|
|
25
|
-
|
|
26
|
+
size?:string,
|
|
27
|
+
"hide-clean"?:string,
|
|
26
28
|
}
|
|
27
29
|
}
|
|
28
30
|
}
|
|
@@ -33,21 +35,18 @@ export function JBSelect<TValue>(props:Props<TValue>) {
|
|
|
33
35
|
() => (element ? element.current : undefined),
|
|
34
36
|
[element],
|
|
35
37
|
);
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
useJBSelectAttribute(element,props);
|
|
38
|
+
const {onChange,onInit,onInput,onKeyUp,onLoad,error,getSelectedValueDOM,label,name,required,message,placeholder,searchPlaceholder,validationList,value, hideClear, ...otherProps} = props;
|
|
39
|
+
useEvents(element,{onChange,onInit,onInput,onKeyUp,onLoad});
|
|
40
|
+
useJBSelectAttribute(element,{error,getSelectedValueDOM,label,name,required,message,placeholder,searchPlaceholder,validationList,value,hideClear});
|
|
40
41
|
return (
|
|
41
|
-
<jb-select
|
|
42
|
+
<jb-select ref={element} {...otherProps}>
|
|
42
43
|
{props.children}
|
|
43
44
|
</jb-select>
|
|
44
45
|
);
|
|
45
46
|
};
|
|
46
47
|
|
|
47
|
-
export type Props<TValue> = EventProps & JBSelectAttributes<TValue
|
|
48
|
+
export type Props<TValue> = PropsWithChildren<EventProps & JBSelectAttributes<TValue>> & JBElementStandardProps<JBSelectWebComponent, keyof EventProps & JBSelectAttributes<TValue>> & {
|
|
48
49
|
ref?: React.RefObject<JBSelectWebComponent>,
|
|
49
|
-
|
|
50
|
-
className?: string,
|
|
51
|
-
children?:React.ReactNode,
|
|
50
|
+
size?: SizeVariants,
|
|
52
51
|
}
|
|
53
52
|
JBSelect.displayName = 'JBSelect';
|