@ship-ui/core 0.16.1 → 0.16.3
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/fesm2022/ship-ui-core.mjs +127 -130
- package/fesm2022/ship-ui-core.mjs.map +1 -1
- package/index.d.ts +30 -14
- package/package.json +1 -1
- package/styles/components/ship-menu.scss +12 -5
- package/styles/components/ship-popover.scss +65 -5
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { inject, ElementRef, Renderer2, ChangeDetectionStrategy, Component, signal, DestroyRef, InjectionToken, input, computed, viewChild, effect, HostListener, NgModule, Injectable, DOCUMENT, model, output, ApplicationRef, createComponent, isSignal, OutputEmitterRef, PLATFORM_ID, ViewChild, contentChild, contentChildren, afterNextRender,
|
|
3
|
-
import { isPlatformBrowser, JsonPipe, DatePipe, NgTemplateOutlet } from '@angular/common';
|
|
2
|
+
import { inject, ElementRef, Renderer2, ChangeDetectionStrategy, Component, signal, DestroyRef, InjectionToken, input, computed, viewChild, effect, HostListener, NgModule, Injectable, DOCUMENT, model, output, ApplicationRef, createComponent, isSignal, OutputEmitterRef, PLATFORM_ID, ViewChild, contentChild, contentChildren, afterNextRender, Injector, HostBinding, TemplateRef, runInInjectionContext, Directive, ChangeDetectorRef, viewChildren, ViewContainerRef, EnvironmentInjector } from '@angular/core';
|
|
3
|
+
import { isPlatformBrowser, JsonPipe, DatePipe, isPlatformServer, NgTemplateOutlet } from '@angular/common';
|
|
4
4
|
import { NgModel } from '@angular/forms';
|
|
5
5
|
import { SIGNAL } from '@angular/core/primitives/signals';
|
|
6
6
|
|
|
@@ -493,8 +493,9 @@ class ShipDialogService {
|
|
|
493
493
|
environmentInjector,
|
|
494
494
|
projectableNodes: [[this.insertedCompRef.location.nativeElement]],
|
|
495
495
|
});
|
|
496
|
-
const
|
|
497
|
-
const
|
|
496
|
+
const insertedInstance = this.insertedCompRef.instance;
|
|
497
|
+
const dataField = insertedInstance.data;
|
|
498
|
+
const closedField = insertedInstance.closed;
|
|
498
499
|
if (data) {
|
|
499
500
|
if (isSignal(dataField)) {
|
|
500
501
|
this.insertedCompRef.setInput('data', data);
|
|
@@ -504,13 +505,13 @@ class ShipDialogService {
|
|
|
504
505
|
}
|
|
505
506
|
}
|
|
506
507
|
if (closedField instanceof OutputEmitterRef) {
|
|
507
|
-
this.closedFieldSub = closedField.subscribe((
|
|
508
|
+
this.closedFieldSub = closedField.subscribe((arg) => {
|
|
508
509
|
this.#cleanupRefs();
|
|
509
510
|
if (closingCalled)
|
|
510
511
|
return;
|
|
511
512
|
closingCalled = true;
|
|
512
|
-
closed?.(
|
|
513
|
-
this.compRef?.instance.closed.emit(
|
|
513
|
+
closed?.(arg);
|
|
514
|
+
(this.compRef?.instance.closed).emit(arg);
|
|
514
515
|
});
|
|
515
516
|
}
|
|
516
517
|
this.#appRef.attachView(this.insertedCompRef.hostView);
|
|
@@ -532,6 +533,7 @@ class ShipDialogService {
|
|
|
532
533
|
closed?.(arg);
|
|
533
534
|
}
|
|
534
535
|
return {
|
|
536
|
+
...this.insertedCompRef.instance,
|
|
535
537
|
component: this.insertedCompRef.instance,
|
|
536
538
|
close: closeAction,
|
|
537
539
|
closed: this.compRef.instance.closed,
|
|
@@ -1798,6 +1800,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
1798
1800
|
args: [{
|
|
1799
1801
|
selector: 'sh-chip',
|
|
1800
1802
|
imports: [],
|
|
1803
|
+
standalone: true,
|
|
1801
1804
|
template: '<div><ng-content /></div>',
|
|
1802
1805
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
1803
1806
|
host: {
|
|
@@ -3458,135 +3461,15 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
3458
3461
|
}]
|
|
3459
3462
|
}] });
|
|
3460
3463
|
|
|
3461
|
-
function createInputSignal(input, options) {
|
|
3462
|
-
const injector = options?.injector || (assertInInjectionContext(createInputSignal), inject(Injector));
|
|
3463
|
-
const { debounce = 0, initialValue = undefined, transform = (value) => value, compare = (a, b) => a === b, forceType = undefined, returnPreviousValue = true, } = options || {};
|
|
3464
|
-
const valueSignal = signal(initialValue, ...(ngDevMode ? [{ debugName: "valueSignal" }] : []));
|
|
3465
|
-
const destroyRef = injector.get(DestroyRef);
|
|
3466
|
-
const inputElementRef = computed(() => {
|
|
3467
|
-
const inputElement = input()?.nativeElement;
|
|
3468
|
-
if (!(inputElement instanceof HTMLInputElement || inputElement instanceof HTMLTextAreaElement)) {
|
|
3469
|
-
return;
|
|
3470
|
-
}
|
|
3471
|
-
return createCustomInputEventListener(inputElement);
|
|
3472
|
-
}, ...(ngDevMode ? [{ debugName: "inputElementRef" }] : []));
|
|
3473
|
-
let isUpdating = false;
|
|
3474
|
-
let previousValue;
|
|
3475
|
-
let timeoutId = null;
|
|
3476
|
-
effect(() => {
|
|
3477
|
-
const inputElement = inputElementRef();
|
|
3478
|
-
if (!inputElement) {
|
|
3479
|
-
return valueSignal.set(returnPreviousValue && previousValue ? transform(previousValue) : undefined);
|
|
3480
|
-
}
|
|
3481
|
-
if (initialValue !== undefined && inputElement.value === '') {
|
|
3482
|
-
valueSignal.set(initialValue);
|
|
3483
|
-
}
|
|
3484
|
-
else if (inputElement.value !== '') {
|
|
3485
|
-
syncValueFromInput();
|
|
3486
|
-
}
|
|
3487
|
-
const inputHandler = (e) => {
|
|
3488
|
-
if (timeoutId !== null) {
|
|
3489
|
-
clearTimeout(timeoutId);
|
|
3490
|
-
}
|
|
3491
|
-
timeoutId = setTimeout(() => {
|
|
3492
|
-
timeoutId = null;
|
|
3493
|
-
syncValueFromInput();
|
|
3494
|
-
}, debounce);
|
|
3495
|
-
};
|
|
3496
|
-
inputElement.addEventListener('input', inputHandler);
|
|
3497
|
-
inputElement.addEventListener('inputValueChanged', inputHandler);
|
|
3498
|
-
destroyRef.onDestroy(() => {
|
|
3499
|
-
inputElement.removeEventListener('input', inputHandler);
|
|
3500
|
-
inputElement.removeEventListener('inputValueChanged', inputHandler);
|
|
3501
|
-
if (timeoutId !== null) {
|
|
3502
|
-
clearTimeout(timeoutId);
|
|
3503
|
-
}
|
|
3504
|
-
});
|
|
3505
|
-
}, { injector });
|
|
3506
|
-
effect(() => {
|
|
3507
|
-
const inputElement = inputElementRef();
|
|
3508
|
-
if (!inputElement)
|
|
3509
|
-
return;
|
|
3510
|
-
const currentValue = valueSignal() ?? '';
|
|
3511
|
-
let domValue = currentValue === null || currentValue === undefined ? '' : String(currentValue);
|
|
3512
|
-
if (inputElement.value !== domValue) {
|
|
3513
|
-
previousValue = domValue;
|
|
3514
|
-
inputElement.value = domValue;
|
|
3515
|
-
inputElement.dispatchEvent(new Event('input'));
|
|
3516
|
-
}
|
|
3517
|
-
}, { injector });
|
|
3518
|
-
return valueSignal;
|
|
3519
|
-
function syncValueFromInput() {
|
|
3520
|
-
if (isUpdating)
|
|
3521
|
-
return;
|
|
3522
|
-
isUpdating = true;
|
|
3523
|
-
try {
|
|
3524
|
-
const inputElement = inputElementRef();
|
|
3525
|
-
if (!inputElement)
|
|
3526
|
-
return;
|
|
3527
|
-
const inputValue = inputElement.value;
|
|
3528
|
-
const transformedValue = forceType ? forceTransform(inputValue, forceType) : transform(inputValue);
|
|
3529
|
-
previousValue = inputValue;
|
|
3530
|
-
if (!compare(valueSignal(), transformedValue)) {
|
|
3531
|
-
valueSignal.set(transformedValue);
|
|
3532
|
-
}
|
|
3533
|
-
}
|
|
3534
|
-
finally {
|
|
3535
|
-
isUpdating = false;
|
|
3536
|
-
}
|
|
3537
|
-
}
|
|
3538
|
-
function createCustomInputEventListener(input) {
|
|
3539
|
-
Object.defineProperty(input, 'value', {
|
|
3540
|
-
configurable: true,
|
|
3541
|
-
get() {
|
|
3542
|
-
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value'); // Use Object.getPrototypeOf
|
|
3543
|
-
return descriptor.get.call(this);
|
|
3544
|
-
},
|
|
3545
|
-
set(newVal) {
|
|
3546
|
-
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value'); // Use Object.getPrototypeOf
|
|
3547
|
-
descriptor.set.call(this, newVal);
|
|
3548
|
-
const inputEvent = new CustomEvent('inputValueChanged', {
|
|
3549
|
-
bubbles: true,
|
|
3550
|
-
cancelable: true,
|
|
3551
|
-
detail: {
|
|
3552
|
-
value: newVal,
|
|
3553
|
-
},
|
|
3554
|
-
});
|
|
3555
|
-
this.dispatchEvent(inputEvent);
|
|
3556
|
-
return newVal;
|
|
3557
|
-
},
|
|
3558
|
-
});
|
|
3559
|
-
return input;
|
|
3560
|
-
}
|
|
3561
|
-
function forceTransform(value, type) {
|
|
3562
|
-
switch (type) {
|
|
3563
|
-
case 'string':
|
|
3564
|
-
return value.toString();
|
|
3565
|
-
case 'number':
|
|
3566
|
-
const num = Number(value);
|
|
3567
|
-
return isNaN(num) ? undefined : num;
|
|
3568
|
-
case 'boolean':
|
|
3569
|
-
return (value.toLowerCase() === 'true'
|
|
3570
|
-
? true
|
|
3571
|
-
: value.toLowerCase() === 'false'
|
|
3572
|
-
? false
|
|
3573
|
-
: undefined);
|
|
3574
|
-
default:
|
|
3575
|
-
return value;
|
|
3576
|
-
}
|
|
3577
|
-
}
|
|
3578
|
-
}
|
|
3579
|
-
|
|
3580
3464
|
function observeFirstChild(parentEl, elementTags) {
|
|
3581
3465
|
const elementSignal = signal(null, ...(ngDevMode ? [{ debugName: "elementSignal" }] : []));
|
|
3582
3466
|
const _upperCaseElementTags = elementTags.map((tag) => tag.toUpperCase());
|
|
3583
3467
|
const injector = inject(Injector);
|
|
3584
3468
|
const destroyRef = injector.get(DestroyRef);
|
|
3585
|
-
if (typeof MutationObserver === 'undefined')
|
|
3469
|
+
if (isPlatformServer(injector.get(PLATFORM_ID)) || typeof MutationObserver === 'undefined')
|
|
3586
3470
|
return elementSignal.asReadonly();
|
|
3587
3471
|
const initialElement = _upperCaseElementTags.find((tag) => parentEl.nativeElement.querySelector(tag));
|
|
3588
3472
|
if (initialElement) {
|
|
3589
|
-
console.log('initialElement', initialElement);
|
|
3590
3473
|
elementSignal.set(new ElementRef(parentEl.nativeElement.querySelector(elementTags[0])));
|
|
3591
3474
|
return elementSignal.asReadonly();
|
|
3592
3475
|
}
|
|
@@ -3664,6 +3547,89 @@ function observeChildren(parentEl, elementTags) {
|
|
|
3664
3547
|
};
|
|
3665
3548
|
}
|
|
3666
3549
|
|
|
3550
|
+
function createFormInputSignal(formEl, elementTags = ['input', 'textarea']) {
|
|
3551
|
+
const elementRefSignal = formEl ? formEl : observeFirstChild(inject(ElementRef), elementTags);
|
|
3552
|
+
const valueSignal = signal(undefined, ...(ngDevMode ? [{ debugName: "valueSignal" }] : []));
|
|
3553
|
+
const injector = inject(Injector);
|
|
3554
|
+
const destroyRef = injector.get(DestroyRef);
|
|
3555
|
+
const firstInputEl = signal(null, ...(ngDevMode ? [{ debugName: "firstInputEl" }] : []));
|
|
3556
|
+
effect((onCleanup) => {
|
|
3557
|
+
const elRef = elementRefSignal();
|
|
3558
|
+
if (!elRef)
|
|
3559
|
+
return;
|
|
3560
|
+
const inputEl = elRef.nativeElement;
|
|
3561
|
+
if (!inputEl)
|
|
3562
|
+
return;
|
|
3563
|
+
createCustomInputEventListener(inputEl);
|
|
3564
|
+
firstInputEl.set(inputEl);
|
|
3565
|
+
valueSignal.set(inputEl.value ?? '');
|
|
3566
|
+
onCleanup(() => {
|
|
3567
|
+
firstInputEl.set(null);
|
|
3568
|
+
});
|
|
3569
|
+
}, { injector });
|
|
3570
|
+
let removeListener = null;
|
|
3571
|
+
effect(() => {
|
|
3572
|
+
const inputEl = firstInputEl();
|
|
3573
|
+
if (!inputEl)
|
|
3574
|
+
return;
|
|
3575
|
+
if (removeListener) {
|
|
3576
|
+
removeListener();
|
|
3577
|
+
removeListener = null;
|
|
3578
|
+
}
|
|
3579
|
+
const inputChangedListener = (event) => {
|
|
3580
|
+
valueSignal.set(event.detail.value);
|
|
3581
|
+
};
|
|
3582
|
+
const inputListener = (event) => {
|
|
3583
|
+
valueSignal.set(event.target.value);
|
|
3584
|
+
};
|
|
3585
|
+
inputEl.addEventListener('input', inputListener);
|
|
3586
|
+
inputEl.addEventListener('inputValueChanged', inputChangedListener);
|
|
3587
|
+
valueSignal.set(inputEl.value);
|
|
3588
|
+
removeListener = () => {
|
|
3589
|
+
inputEl.removeEventListener('input', inputListener);
|
|
3590
|
+
inputEl.removeEventListener('inputValueChanged', inputChangedListener);
|
|
3591
|
+
};
|
|
3592
|
+
destroyRef.onDestroy(() => {
|
|
3593
|
+
if (removeListener)
|
|
3594
|
+
removeListener();
|
|
3595
|
+
});
|
|
3596
|
+
}, { injector });
|
|
3597
|
+
effect(() => {
|
|
3598
|
+
const inputEl = firstInputEl();
|
|
3599
|
+
if (!inputEl)
|
|
3600
|
+
return;
|
|
3601
|
+
const inputValue = valueSignal();
|
|
3602
|
+
if (!inputValue)
|
|
3603
|
+
return;
|
|
3604
|
+
inputEl.value = inputValue;
|
|
3605
|
+
inputEl.dispatchEvent(new Event('input'));
|
|
3606
|
+
}, { injector });
|
|
3607
|
+
return valueSignal;
|
|
3608
|
+
}
|
|
3609
|
+
function createCustomInputEventListener(input) {
|
|
3610
|
+
Object.defineProperty(input, 'value', {
|
|
3611
|
+
configurable: true,
|
|
3612
|
+
get() {
|
|
3613
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value');
|
|
3614
|
+
return descriptor.get.call(this);
|
|
3615
|
+
},
|
|
3616
|
+
set(newVal) {
|
|
3617
|
+
const descriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(input), 'value');
|
|
3618
|
+
descriptor.set.call(this, newVal);
|
|
3619
|
+
const inputEvent = new CustomEvent('inputValueChanged', {
|
|
3620
|
+
bubbles: true,
|
|
3621
|
+
cancelable: true,
|
|
3622
|
+
detail: {
|
|
3623
|
+
value: newVal,
|
|
3624
|
+
},
|
|
3625
|
+
});
|
|
3626
|
+
this.dispatchEvent(inputEvent);
|
|
3627
|
+
return newVal;
|
|
3628
|
+
},
|
|
3629
|
+
});
|
|
3630
|
+
return input;
|
|
3631
|
+
}
|
|
3632
|
+
|
|
3667
3633
|
class ShipMenu {
|
|
3668
3634
|
constructor() {
|
|
3669
3635
|
this.#document = inject(DOCUMENT);
|
|
@@ -3682,7 +3648,7 @@ class ShipMenu {
|
|
|
3682
3648
|
this.optionsRef = viewChild('optionsRef', ...(ngDevMode ? [{ debugName: "optionsRef" }] : []));
|
|
3683
3649
|
this.options = observeChildren(this.optionsRef, this.customOptionElementSelectors);
|
|
3684
3650
|
this.optionsEl = computed(() => this.options.signal().filter((x) => !x.disabled), ...(ngDevMode ? [{ debugName: "optionsEl" }] : []));
|
|
3685
|
-
this.inputValue =
|
|
3651
|
+
this.inputValue = createFormInputSignal(this.inputRef);
|
|
3686
3652
|
this.abortController = null;
|
|
3687
3653
|
this.optionsEffect = effect(() => {
|
|
3688
3654
|
if (this.abortController !== null) {
|
|
@@ -6375,6 +6341,37 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
6375
6341
|
}]
|
|
6376
6342
|
}], propDecorators: { viewportRef: [{ type: i0.ViewChild, args: ['viewport', { isSignal: true }] }], itemElements: [{ type: i0.ViewChildren, args: ['item', { isSignal: true }] }] } });
|
|
6377
6343
|
|
|
6344
|
+
class ShipFormFieldExperimental {
|
|
6345
|
+
constructor() {
|
|
6346
|
+
this.firstInput = createFormInputSignal();
|
|
6347
|
+
this.hello = effect(() => {
|
|
6348
|
+
console.log('hello', this.firstInput());
|
|
6349
|
+
}, ...(ngDevMode ? [{ debugName: "hello" }] : []));
|
|
6350
|
+
}
|
|
6351
|
+
myClick() {
|
|
6352
|
+
this.firstInput.update((x) => x + 'hello');
|
|
6353
|
+
}
|
|
6354
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ShipFormFieldExperimental, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
6355
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.3.9", type: ShipFormFieldExperimental, isStandalone: true, selector: "sh-form-field-experimental", ngImport: i0, template: `
|
|
6356
|
+
<ng-content></ng-content>
|
|
6357
|
+
|
|
6358
|
+
<button (click)="myClick()">hello</button>
|
|
6359
|
+
`, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
6360
|
+
}
|
|
6361
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: ShipFormFieldExperimental, decorators: [{
|
|
6362
|
+
type: Component,
|
|
6363
|
+
args: [{
|
|
6364
|
+
selector: 'sh-form-field-experimental',
|
|
6365
|
+
imports: [],
|
|
6366
|
+
template: `
|
|
6367
|
+
<ng-content></ng-content>
|
|
6368
|
+
|
|
6369
|
+
<button (click)="myClick()">hello</button>
|
|
6370
|
+
`,
|
|
6371
|
+
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
6372
|
+
}]
|
|
6373
|
+
}] });
|
|
6374
|
+
|
|
6378
6375
|
class ShipFileDragDrop {
|
|
6379
6376
|
constructor() {
|
|
6380
6377
|
this.filesOver = signal(false, ...(ngDevMode ? [{ debugName: "filesOver" }] : []));
|
|
@@ -6728,5 +6725,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
|
|
|
6728
6725
|
* Generated bundle index. Do not edit.
|
|
6729
6726
|
*/
|
|
6730
6727
|
|
|
6731
|
-
export { GridSortable, SHIP_CONFIG, ShipAlert, ShipAlertContainer, ShipAlertModule, ShipAlertService, ShipBlueprint, ShipButton, ShipButtonGroup, ShipCard, ShipCheckbox, ShipChip, ShipColorPicker, ShipDatepicker, ShipDatepickerInput, ShipDaterangeInput, ShipDialog, ShipDialogService, ShipDivider, ShipEventCard, ShipFileDragDrop, ShipFileUpload, ShipFormField, ShipIcon, ShipInputMask, ShipList, ShipMenu, ShipPopover, ShipPreventWheel, ShipProgressBar, ShipRadio, ShipRangeSlider, ShipResize, ShipSelect, ShipSidenav, ShipSort, ShipSortable, ShipSpinner, ShipStepper, ShipStickyColumns, ShipTable, ShipTabs, ShipToggle, ShipToggleCard, ShipTooltip, ShipTooltipWrapper, ShipVirtualScroll, TEST_NODES, moveIndex, watchHostClass };
|
|
6728
|
+
export { GridSortable, SHIP_CONFIG, ShipAlert, ShipAlertContainer, ShipAlertModule, ShipAlertService, ShipBlueprint, ShipButton, ShipButtonGroup, ShipCard, ShipCheckbox, ShipChip, ShipColorPicker, ShipDatepicker, ShipDatepickerInput, ShipDaterangeInput, ShipDialog, ShipDialogService, ShipDivider, ShipEventCard, ShipFileDragDrop, ShipFileUpload, ShipFormField, ShipFormFieldExperimental, ShipIcon, ShipInputMask, ShipList, ShipMenu, ShipPopover, ShipPreventWheel, ShipProgressBar, ShipRadio, ShipRangeSlider, ShipResize, ShipSelect, ShipSidenav, ShipSort, ShipSortable, ShipSpinner, ShipStepper, ShipStickyColumns, ShipTable, ShipTabs, ShipToggle, ShipToggleCard, ShipTooltip, ShipTooltipWrapper, ShipVirtualScroll, TEST_NODES, moveIndex, watchHostClass };
|
|
6732
6729
|
//# sourceMappingURL=ship-ui-core.mjs.map
|