selective-ui 1.4.0 → 1.4.2
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/dist/selective-ui.css +2 -2
- package/dist/selective-ui.css.map +1 -1
- package/dist/selective-ui.esm.js +407 -573
- package/dist/selective-ui.esm.js.map +1 -1
- package/dist/selective-ui.esm.min.js +2 -2
- package/dist/selective-ui.esm.min.js.br +0 -0
- package/dist/selective-ui.min.css +1 -1
- package/dist/selective-ui.min.css.br +0 -0
- package/dist/selective-ui.min.js +2 -2
- package/dist/selective-ui.min.js.br +0 -0
- package/dist/selective-ui.umd.js +409 -575
- package/dist/selective-ui.umd.js.map +1 -1
- package/package.json +12 -12
- package/src/css/views/option-view.css +2 -2
- package/src/ts/adapter/mixed-adapter.ts +149 -71
- package/src/ts/components/accessorybox.ts +14 -11
- package/src/ts/components/directive.ts +1 -1
- package/src/ts/components/option-handle.ts +12 -9
- package/src/ts/components/placeholder.ts +5 -5
- package/src/ts/components/popup/empty-state.ts +5 -5
- package/src/ts/components/popup/loading-state.ts +5 -5
- package/src/ts/components/popup/popup.ts +138 -76
- package/src/ts/components/searchbox.ts +17 -13
- package/src/ts/components/selectbox.ts +260 -84
- package/src/ts/core/base/adapter.ts +61 -14
- package/src/ts/core/base/fenwick.ts +3 -2
- package/src/ts/core/base/lifecycle.ts +14 -4
- package/src/ts/core/base/model.ts +17 -15
- package/src/ts/core/base/recyclerview.ts +7 -5
- package/src/ts/core/base/view.ts +10 -5
- package/src/ts/core/base/virtual-recyclerview.ts +178 -45
- package/src/ts/core/model-manager.ts +48 -21
- package/src/ts/core/search-controller.ts +174 -56
- package/src/ts/global.ts +5 -8
- package/src/ts/index.ts +2 -2
- package/src/ts/models/group-model.ts +33 -8
- package/src/ts/models/option-model.ts +88 -20
- package/src/ts/services/dataset-observer.ts +6 -3
- package/src/ts/services/ea-observer.ts +1 -1
- package/src/ts/services/effector.ts +22 -12
- package/src/ts/services/refresher.ts +14 -4
- package/src/ts/services/resize-observer.ts +24 -11
- package/src/ts/services/select-observer.ts +2 -2
- package/src/ts/types/components/popup.type.ts +18 -1
- package/src/ts/types/components/searchbox.type.ts +43 -30
- package/src/ts/types/components/state.box.type.ts +1 -1
- package/src/ts/types/core/base/adapter.type.ts +13 -5
- package/src/ts/types/core/base/lifecycle.type.ts +1 -2
- package/src/ts/types/core/base/model.type.ts +3 -3
- package/src/ts/types/core/base/recyclerview.type.ts +7 -5
- package/src/ts/types/core/base/view.type.ts +6 -6
- package/src/ts/types/core/base/virtual-recyclerview.type.ts +45 -46
- package/src/ts/types/core/search-controller.type.ts +18 -2
- package/src/ts/types/css.d.ts +1 -0
- package/src/ts/types/plugins/plugin.type.ts +2 -2
- package/src/ts/types/services/effector.type.ts +25 -25
- package/src/ts/types/services/resize-observer.type.ts +23 -12
- package/src/ts/types/utils/callback-scheduler.type.ts +2 -2
- package/src/ts/types/utils/ievents.type.ts +1 -1
- package/src/ts/types/utils/istorage.type.ts +62 -60
- package/src/ts/types/utils/libs.type.ts +19 -17
- package/src/ts/types/utils/selective.type.ts +6 -3
- package/src/ts/types/views/view.group.type.ts +9 -5
- package/src/ts/types/views/view.option.type.ts +39 -17
- package/src/ts/utils/callback-scheduler.ts +12 -7
- package/src/ts/utils/ievents.ts +12 -5
- package/src/ts/utils/istorage.ts +5 -3
- package/src/ts/utils/libs.ts +122 -43
- package/src/ts/utils/selective.ts +15 -8
- package/src/ts/views/group-view.ts +11 -9
- package/src/ts/views/option-view.ts +37 -18
|
@@ -2,7 +2,10 @@ import { Libs } from "./libs";
|
|
|
2
2
|
import { iEvents } from "./ievents";
|
|
3
3
|
import { SelectBox } from "../components/selectbox";
|
|
4
4
|
import { ElementAdditionObserver } from "../services/ea-observer";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
SelectiveActionApi,
|
|
7
|
+
SelectiveOptions,
|
|
8
|
+
} from "../types/utils/selective.type";
|
|
6
9
|
import { BinderMap, PropertiesType } from "../types/utils/istorage.type";
|
|
7
10
|
import { Lifecycle } from "../core/base/lifecycle";
|
|
8
11
|
import { LifecycleState } from "../types/core/base/lifecycle.type";
|
|
@@ -172,7 +175,9 @@ export class Selective extends Lifecycle {
|
|
|
172
175
|
|
|
173
176
|
// Ensure hooks exist
|
|
174
177
|
merged.on = merged.on ?? {};
|
|
175
|
-
merged.on.load = (merged.on.load ?? []) as Array<
|
|
178
|
+
merged.on.load = (merged.on.load ?? []) as Array<
|
|
179
|
+
(...args: any[]) => void
|
|
180
|
+
>;
|
|
176
181
|
|
|
177
182
|
this.bindedQueries.set(query, merged);
|
|
178
183
|
|
|
@@ -531,7 +536,11 @@ export class Selective extends Lifecycle {
|
|
|
531
536
|
* @returns {void}
|
|
532
537
|
*/
|
|
533
538
|
private destroyElement(selectElement: HTMLSelectElement): void {
|
|
534
|
-
const bindMap = Libs.getBinderMap<BinderMap<
|
|
539
|
+
const bindMap = Libs.getBinderMap<BinderMap<
|
|
540
|
+
{ element: HTMLElement },
|
|
541
|
+
Record<string, any>,
|
|
542
|
+
SelectBox
|
|
543
|
+
> | null>(selectElement);
|
|
535
544
|
if (!bindMap) return;
|
|
536
545
|
|
|
537
546
|
const selfBox = bindMap.self;
|
|
@@ -543,7 +552,8 @@ export class Selective extends Lifecycle {
|
|
|
543
552
|
|
|
544
553
|
bindMap.self?.deInit?.();
|
|
545
554
|
|
|
546
|
-
const wrapper =
|
|
555
|
+
const wrapper =
|
|
556
|
+
bindMap.container?.element ?? selectElement.parentElement;
|
|
547
557
|
|
|
548
558
|
selectElement.style.display = "";
|
|
549
559
|
selectElement.style.visibility = "";
|
|
@@ -627,10 +637,7 @@ export class Selective extends Lifecycle {
|
|
|
627
637
|
}
|
|
628
638
|
|
|
629
639
|
const SEID = Libs.randomString(8);
|
|
630
|
-
const options_cfg = Libs.buildConfig(
|
|
631
|
-
selectElement,
|
|
632
|
-
options,
|
|
633
|
-
);
|
|
640
|
+
const options_cfg = Libs.buildConfig(selectElement, options);
|
|
634
641
|
|
|
635
642
|
options_cfg.SEID = SEID;
|
|
636
643
|
options_cfg.SEID_LIST = `seui-${SEID}-optionlist`;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { View } from "../core/base/view";
|
|
2
2
|
import { Libs } from "../utils/libs";
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
GroupViewTags,
|
|
5
|
+
GroupViewResult,
|
|
6
|
+
} from "../types/views/view.group.type";
|
|
4
7
|
import { SelectiveOptions } from "../types/utils/selective.type";
|
|
5
8
|
|
|
6
9
|
/**
|
|
@@ -53,7 +56,6 @@ import { SelectiveOptions } from "../types/utils/selective.type";
|
|
|
53
56
|
* @see {@link View}
|
|
54
57
|
*/
|
|
55
58
|
export class GroupView extends View<GroupViewTags> {
|
|
56
|
-
|
|
57
59
|
/**
|
|
58
60
|
* Strongly-typed reference to the mounted group view structure.
|
|
59
61
|
*
|
|
@@ -67,7 +69,7 @@ export class GroupView extends View<GroupViewTags> {
|
|
|
67
69
|
*
|
|
68
70
|
* @public
|
|
69
71
|
*/
|
|
70
|
-
public view
|
|
72
|
+
public view?: GroupViewResult;
|
|
71
73
|
|
|
72
74
|
/**
|
|
73
75
|
* Parsed configuration (bound from the `<select>` element via binder map).
|
|
@@ -77,7 +79,7 @@ export class GroupView extends View<GroupViewTags> {
|
|
|
77
79
|
*
|
|
78
80
|
* @internal
|
|
79
81
|
*/
|
|
80
|
-
private options
|
|
82
|
+
private options?: SelectiveOptions;
|
|
81
83
|
|
|
82
84
|
/**
|
|
83
85
|
* Creates a new GroupView bound to the given parent element.
|
|
@@ -190,10 +192,10 @@ export class GroupView extends View<GroupViewTags> {
|
|
|
190
192
|
* - Safe to call multiple times with same value (idempotent).
|
|
191
193
|
*
|
|
192
194
|
* @public
|
|
193
|
-
* @param {string
|
|
195
|
+
* @param {string} [label=null] - New label to display; `null` preserves current label.
|
|
194
196
|
* @returns {void}
|
|
195
197
|
*/
|
|
196
|
-
public updateLabel(label
|
|
198
|
+
public updateLabel(label?: string): void {
|
|
197
199
|
if (!this.view) return;
|
|
198
200
|
|
|
199
201
|
const headerEl = this.view.tags.GroupHeader;
|
|
@@ -243,7 +245,7 @@ export class GroupView extends View<GroupViewTags> {
|
|
|
243
245
|
|
|
244
246
|
const items = this.view.tags.GroupItems;
|
|
245
247
|
const visibleItems = Array.from(items.children).filter(
|
|
246
|
-
child => !child.classList.contains("hide")
|
|
248
|
+
(child) => !child.classList.contains("hide"),
|
|
247
249
|
);
|
|
248
250
|
|
|
249
251
|
this.view.view.classList.toggle("hide", visibleItems.length === 0);
|
|
@@ -275,7 +277,7 @@ export class GroupView extends View<GroupViewTags> {
|
|
|
275
277
|
this.view.view.classList.toggle("collapsed", collapsed);
|
|
276
278
|
this.view.tags.GroupHeader.setAttribute(
|
|
277
279
|
"aria-expanded",
|
|
278
|
-
collapsed ? "false" : "true"
|
|
280
|
+
collapsed ? "false" : "true",
|
|
279
281
|
);
|
|
280
282
|
}
|
|
281
|
-
}
|
|
283
|
+
}
|
|
@@ -4,7 +4,7 @@ import type {
|
|
|
4
4
|
OptionViewTags,
|
|
5
5
|
OptionViewResult,
|
|
6
6
|
OptionConfig,
|
|
7
|
-
OptionConfigPatch
|
|
7
|
+
OptionConfigPatch,
|
|
8
8
|
} from "../types/views/view.option.type";
|
|
9
9
|
import { SelectiveOptions } from "../types/utils/selective.type";
|
|
10
10
|
|
|
@@ -77,7 +77,6 @@ import { SelectiveOptions } from "../types/utils/selective.type";
|
|
|
77
77
|
* @see {@link View}
|
|
78
78
|
*/
|
|
79
79
|
export class OptionView extends View<OptionViewTags> {
|
|
80
|
-
|
|
81
80
|
/**
|
|
82
81
|
* Strongly-typed reference to the mounted option view structure.
|
|
83
82
|
*
|
|
@@ -91,7 +90,7 @@ export class OptionView extends View<OptionViewTags> {
|
|
|
91
90
|
*
|
|
92
91
|
* @public
|
|
93
92
|
*/
|
|
94
|
-
public view
|
|
93
|
+
public view?: OptionViewResult;
|
|
95
94
|
|
|
96
95
|
/**
|
|
97
96
|
* Parsed configuration (bound from the `<select>` element via binder map).
|
|
@@ -101,7 +100,7 @@ export class OptionView extends View<OptionViewTags> {
|
|
|
101
100
|
*
|
|
102
101
|
* @internal
|
|
103
102
|
*/
|
|
104
|
-
private options
|
|
103
|
+
private options?: SelectiveOptions;
|
|
105
104
|
|
|
106
105
|
/**
|
|
107
106
|
* Internal configuration object (Proxy target).
|
|
@@ -116,7 +115,7 @@ export class OptionView extends View<OptionViewTags> {
|
|
|
116
115
|
*
|
|
117
116
|
* @private
|
|
118
117
|
*/
|
|
119
|
-
private config
|
|
118
|
+
private config?: OptionConfig;
|
|
120
119
|
|
|
121
120
|
/**
|
|
122
121
|
* Reactive Proxy wrapper around {@link config}.
|
|
@@ -131,7 +130,7 @@ export class OptionView extends View<OptionViewTags> {
|
|
|
131
130
|
*
|
|
132
131
|
* @private
|
|
133
132
|
*/
|
|
134
|
-
private configProxy
|
|
133
|
+
private configProxy?: OptionConfig;
|
|
135
134
|
|
|
136
135
|
/**
|
|
137
136
|
* Flag indicating whether the initial render has completed.
|
|
@@ -324,7 +323,7 @@ export class OptionView extends View<OptionViewTags> {
|
|
|
324
323
|
* - Each changed property triggers {@link applyPartialChange} individually.
|
|
325
324
|
*
|
|
326
325
|
* @public
|
|
327
|
-
* @param {OptionConfigPatch
|
|
326
|
+
* @param {OptionConfigPatch} config - Partial configuration patch; `null` is no-op.
|
|
328
327
|
* @returns {void}
|
|
329
328
|
*/
|
|
330
329
|
public set optionConfig(config: OptionConfigPatch | null) {
|
|
@@ -332,22 +331,40 @@ export class OptionView extends View<OptionViewTags> {
|
|
|
332
331
|
|
|
333
332
|
const changes: OptionConfigPatch = {};
|
|
334
333
|
|
|
335
|
-
if (
|
|
334
|
+
if (
|
|
335
|
+
config.imageWidth !== undefined &&
|
|
336
|
+
config.imageWidth !== this.config.imageWidth
|
|
337
|
+
)
|
|
336
338
|
changes.imageWidth = config.imageWidth;
|
|
337
339
|
|
|
338
|
-
if (
|
|
340
|
+
if (
|
|
341
|
+
config.imageHeight !== undefined &&
|
|
342
|
+
config.imageHeight !== this.config.imageHeight
|
|
343
|
+
)
|
|
339
344
|
changes.imageHeight = config.imageHeight;
|
|
340
345
|
|
|
341
|
-
if (
|
|
346
|
+
if (
|
|
347
|
+
config.imageBorderRadius !== undefined &&
|
|
348
|
+
config.imageBorderRadius !== this.config.imageBorderRadius
|
|
349
|
+
)
|
|
342
350
|
changes.imageBorderRadius = config.imageBorderRadius;
|
|
343
351
|
|
|
344
|
-
if (
|
|
352
|
+
if (
|
|
353
|
+
config.imagePosition !== undefined &&
|
|
354
|
+
config.imagePosition !== this.config.imagePosition
|
|
355
|
+
)
|
|
345
356
|
changes.imagePosition = config.imagePosition;
|
|
346
357
|
|
|
347
|
-
if (
|
|
358
|
+
if (
|
|
359
|
+
config.labelValign !== undefined &&
|
|
360
|
+
config.labelValign !== this.config.labelValign
|
|
361
|
+
)
|
|
348
362
|
changes.labelValign = config.labelValign;
|
|
349
363
|
|
|
350
|
-
if (
|
|
364
|
+
if (
|
|
365
|
+
config.labelHalign !== undefined &&
|
|
366
|
+
config.labelHalign !== this.config.labelHalign
|
|
367
|
+
)
|
|
351
368
|
changes.labelHalign = config.labelHalign;
|
|
352
369
|
|
|
353
370
|
if (Object.keys(changes).length > 0) {
|
|
@@ -485,7 +502,7 @@ export class OptionView extends View<OptionViewTags> {
|
|
|
485
502
|
private applyPartialChange<K extends keyof OptionConfig>(
|
|
486
503
|
prop: K,
|
|
487
504
|
newValue: OptionConfig[K],
|
|
488
|
-
oldValue: OptionConfig[K]
|
|
505
|
+
oldValue: OptionConfig[K],
|
|
489
506
|
): void {
|
|
490
507
|
const v = this.view;
|
|
491
508
|
if (!v || !v.view) return;
|
|
@@ -540,9 +557,11 @@ export class OptionView extends View<OptionViewTags> {
|
|
|
540
557
|
const img = v.tags?.OptionImage;
|
|
541
558
|
if (img) {
|
|
542
559
|
const styleProp =
|
|
543
|
-
prop === "imageWidth"
|
|
544
|
-
|
|
545
|
-
|
|
560
|
+
prop === "imageWidth"
|
|
561
|
+
? "width"
|
|
562
|
+
: prop === "imageHeight"
|
|
563
|
+
? "height"
|
|
564
|
+
: "borderRadius";
|
|
546
565
|
|
|
547
566
|
img.style[styleProp] = String(newValue);
|
|
548
567
|
}
|
|
@@ -609,4 +628,4 @@ export class OptionView extends View<OptionViewTags> {
|
|
|
609
628
|
|
|
610
629
|
v.tags.OptionImage = image;
|
|
611
630
|
}
|
|
612
|
-
}
|
|
631
|
+
}
|