vanilla-jui 1.7.1 → 1.7.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanilla-jui",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "private": false,
5
5
  "description": "A lightweight, reactive, and fully customizable vanilla JS UI library.",
6
6
  "keywords": [
@@ -21,11 +21,8 @@ import {
21
21
  createCollapseTransition,
22
22
  } from '../core/motion.ts';
23
23
  import { createKeyedElementRefs } from '../utilities/refs.ts';
24
- import {
25
- type ResolveSchema,
26
- resolveProps,
27
- validateParam,
28
- } from '../utilities/types.ts';
24
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
25
+ import { validateParam } from '../utilities/types.ts';
29
26
 
30
27
  type AccordionActive = number | string | Array<number | string> | null;
31
28
  type AccordionDirection = 'vertical' | 'horizontal';
@@ -182,15 +179,12 @@ const ACCORDION_PROPS_SCHEMA = {
182
179
  },
183
180
  className: {
184
181
  default: DEFAULT_CLASS_NAMES,
185
- type: 'object',
186
- normalize: (value: unknown) => ({
187
- ...DEFAULT_CLASS_NAMES,
188
- ...(value && typeof value === 'object' ? value : {}),
189
- }),
182
+ type: 'plainObject',
183
+ merge: 'shallow',
190
184
  },
191
185
  onChange: { default: null, types: ['function', 'null'] },
192
186
  data: { default: [], ...ACCORDION_DATA_RULE },
193
- } satisfies ResolveSchema<AccordionProps>;
187
+ } satisfies ConfigSchema<AccordionProps>;
194
188
 
195
189
  function isActiveValue(value: unknown): value is number | string {
196
190
  if (typeof value === 'number') return Number.isInteger(value) && value >= 0;
@@ -198,7 +192,7 @@ function isActiveValue(value: unknown): value is number | string {
198
192
  }
199
193
 
200
194
  function normalizeProps(props: AccordionProps): ResolvedAccordionProps {
201
- const resolved = resolveProps(
195
+ const resolved = resolveConfig(
202
196
  props,
203
197
  ACCORDION_PROPS_SCHEMA,
204
198
  'Accordion.props'
@@ -7,11 +7,9 @@ import {
7
7
  import { asRenderable, type RenderableContent } from '../utilities/dom.ts';
8
8
  import { randomId } from '../utilities/id.ts';
9
9
  import { isPlainObject } from '../utilities/object.ts';
10
- import {
11
- type ResolveSchema,
12
- resolveProps,
13
- validateParam,
14
- } from '../utilities/types.ts';
10
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
11
+ import { mergeShallowConfig } from '../utilities/merge.ts';
12
+ import { validateParam } from '../utilities/types.ts';
15
13
  import { translate } from '../utilities/locale.ts';
16
14
 
17
15
  export type FlowData = Record<string, unknown>;
@@ -382,15 +380,11 @@ function cloneSteps(steps: unknown): FlowStep[] {
382
380
 
383
381
  function normalizeClassNames(value: unknown): FlowClassNames {
384
382
  if (typeof value === 'string') {
385
- return {
386
- ...DEFAULT_CLASS_NAMES,
383
+ return mergeShallowConfig(DEFAULT_CLASS_NAMES, {
387
384
  root: [DEFAULT_CLASS_NAMES.root, value.trim()].filter(Boolean).join(' '),
388
- };
385
+ }) as FlowClassNames;
389
386
  }
390
- return {
391
- ...DEFAULT_CLASS_NAMES,
392
- ...(isPlainObject(value) ? (value as FlowClassNameConfig) : {}),
393
- };
387
+ return value as FlowClassNames;
394
388
  }
395
389
 
396
390
  function normalizeStepResult(
@@ -434,22 +428,19 @@ const FLOW_PROPS_SCHEMA = {
434
428
  showNext: { default: true, type: 'boolean' },
435
429
  showReset: { default: false, type: 'boolean' },
436
430
  text: {
437
- default: {},
431
+ defaultFactory: () => ({
432
+ back: translate('b'),
433
+ next: translate('Next'),
434
+ finish: translate('Finish'),
435
+ reset: translate('Reset'),
436
+ }),
438
437
  type: 'plainObject',
439
- normalize: (value: unknown) => {
440
- const text = isPlainObject(value) ? (value as Partial<FlowText>) : {};
441
- return {
442
- back: typeof text.back === 'string' ? text.back : translate('b'),
443
- next: typeof text.next === 'string' ? text.next : translate('Next'),
444
- finish:
445
- typeof text.finish === 'string' ? text.finish : translate('Finish'),
446
- reset: typeof text.reset === 'string' ? text.reset : translate('Reset'),
447
- };
448
- },
438
+ merge: 'shallow',
449
439
  },
450
440
  className: {
451
441
  default: DEFAULT_CLASS_NAMES,
452
- types: ['object', 'string'],
442
+ types: ['plainObject', 'string'],
443
+ merge: 'shallow',
453
444
  normalize: normalizeClassNames,
454
445
  },
455
446
  renderHeader: {
@@ -473,10 +464,10 @@ const FLOW_PROPS_SCHEMA = {
473
464
  onFinish: { default: null, types: ['function', 'null'] },
474
465
  onError: { default: null, types: ['function', 'null'] },
475
466
  onBusy: { default: null, types: ['function', 'null'] },
476
- } satisfies ResolveSchema<FlowProps>;
467
+ } satisfies ConfigSchema<FlowProps>;
477
468
 
478
469
  function normalizeProps(input: FlowProps): ResolvedFlowProps {
479
- const props = resolveProps(input, FLOW_PROPS_SCHEMA, 'Flow.props');
470
+ const props = resolveConfig(input, FLOW_PROPS_SCHEMA, 'Flow.props');
480
471
  return {
481
472
  id: props.id as string,
482
473
  steps: cloneSteps(props.steps),
@@ -21,11 +21,8 @@ import {
21
21
  } from '../utilities/dom.ts';
22
22
  import { randomId } from '../utilities/id.ts';
23
23
  import { isPlainObject } from '../utilities/object.ts';
24
- import {
25
- type ResolveSchema,
26
- resolveProps,
27
- validateParam,
28
- } from '../utilities/types.ts';
24
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
25
+ import { validateParam } from '../utilities/types.ts';
29
26
  import {
30
27
  createValidator,
31
28
  type ValidatorClassNameConfig,
@@ -261,18 +258,18 @@ const FORM_PROPS_SCHEMA = {
261
258
  buttonsPosition: { default: 'start', type: 'string' },
262
259
  text: {
263
260
  default: DEFAULT_TEXT,
264
- type: 'object',
265
- normalize: (value: unknown) => resolveText(value),
261
+ type: 'plainObject',
262
+ merge: 'shallow',
266
263
  },
267
264
  className: {
268
265
  default: DEFAULT_CLASS_NAMES,
269
- type: 'object',
270
- normalize: (value: unknown) => resolveClassNames(value),
266
+ type: 'plainObject',
267
+ merge: 'shallow',
271
268
  },
272
- validator: { default: {}, type: 'object' },
269
+ validator: { default: {}, type: 'plainObject' },
273
270
  onSubmit: { default: null, types: ['function', 'null'] },
274
271
  onReset: { default: null, types: ['function', 'null'] },
275
- } satisfies ResolveSchema<FormProps>;
272
+ } satisfies ConfigSchema<FormProps>;
276
273
 
277
274
  function cloneOptions(
278
275
  options: readonly FieldOption[] | undefined
@@ -380,20 +377,6 @@ function fieldIsRequired(
380
377
  return !!field.required || !!rules?.[field.name]?.required;
381
378
  }
382
379
 
383
- function resolveClassNames(value: unknown): FormClassNames {
384
- return {
385
- ...DEFAULT_CLASS_NAMES,
386
- ...(isPlainObject(value) ? (value as Partial<FormClassNames>) : {}),
387
- } as FormClassNames;
388
- }
389
-
390
- function resolveText(value: unknown): FormText {
391
- return {
392
- ...DEFAULT_TEXT,
393
- ...(isPlainObject(value) ? (value as FormTextConfig) : {}),
394
- } as FormText;
395
- }
396
-
397
380
  function renderFormText(
398
381
  content: RenderableContent<Form>,
399
382
  form: Form
@@ -441,7 +424,7 @@ function cloneValidator(validator: unknown): FormValidatorConfig {
441
424
  }
442
425
 
443
426
  function normalizeProps(input: FormProps): ResolvedFormProps {
444
- const props = resolveProps(input, FORM_PROPS_SCHEMA, 'Form.props');
427
+ const props = resolveConfig(input, FORM_PROPS_SCHEMA, 'Form.props');
445
428
  const fields = cloneFields(props.fields as readonly FormItem<FormField>[]);
446
429
  return {
447
430
  ...props,
@@ -453,8 +436,8 @@ function normalizeProps(input: FormProps): ResolvedFormProps {
453
436
  fields,
454
437
  buttons: props.buttons as FormButtons,
455
438
  buttonsPosition: props.buttonsPosition as string,
456
- text: resolveText(props.text),
457
- className: resolveClassNames(props.className),
439
+ text: props.text as FormText,
440
+ className: props.className as FormClassNames,
458
441
  validator: cloneValidator(props.validator),
459
442
  onSubmit: props.onSubmit as ResolvedFormProps['onSubmit'],
460
443
  onReset: props.onReset as ResolvedFormProps['onReset'],
@@ -18,11 +18,8 @@ import { icon } from '../primitives/icons.ts';
18
18
  import { joinClasses } from '../utilities/dom.ts';
19
19
  import { createEventManager } from '../utilities/events.ts';
20
20
  import { randomId } from '../utilities/id.ts';
21
- import {
22
- type ResolveSchema,
23
- resolveProps,
24
- validateParam,
25
- } from '../utilities/types.ts';
21
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
22
+ import { validateParam } from '../utilities/types.ts';
26
23
 
27
24
  export type MenuType = string | undefined;
28
25
  export type MenuItemId = string | number;
@@ -123,13 +120,10 @@ const MENU_PROPS_SCHEMA = {
123
120
  backText: { default: translate('b'), type: 'string' },
124
121
  className: {
125
122
  default: DEFAULT_CLASS_NAMES,
126
- type: 'object',
127
- normalize: (value: unknown) => ({
128
- ...DEFAULT_CLASS_NAMES,
129
- ...(value && typeof value === 'object' ? value : {}),
130
- }),
123
+ type: 'plainObject',
124
+ merge: 'shallow',
131
125
  },
132
- } satisfies ResolveSchema<MenuProps>;
126
+ } satisfies ConfigSchema<MenuProps>;
133
127
 
134
128
  const MENU_STATE_SCHEMA = {
135
129
  user: { type: 'number' },
@@ -138,7 +132,7 @@ const MENU_STATE_SCHEMA = {
138
132
  };
139
133
 
140
134
  function normalizeProps(input: MenuProps = {}): ResolvedMenuProps {
141
- const props = resolveProps(
135
+ const props = resolveConfig(
142
136
  input,
143
137
  MENU_PROPS_SCHEMA,
144
138
  'Menu.props'
@@ -148,7 +142,7 @@ function normalizeProps(input: MenuProps = {}): ResolvedMenuProps {
148
142
  ...props,
149
143
  user: props.user,
150
144
  data: props.data,
151
- className: { ...props.className },
145
+ className: props.className,
152
146
  };
153
147
  }
154
148
 
@@ -23,13 +23,13 @@ import {
23
23
  } from '../utilities/dom.ts';
24
24
  import { randomId } from '../utilities/id.ts';
25
25
  import { createMotionGroup, createTransition } from '../core/motion.ts';
26
- import { isPlainObject } from '../utilities/object.ts';
27
26
  import { createPresence } from '../core/presence.ts';
28
27
  import {
29
- type ResolveSchema,
30
- resolveProps,
31
- validateParam,
32
- } from '../utilities/types.ts';
28
+ type ConfigRule,
29
+ type ConfigSchema,
30
+ resolveConfig,
31
+ } from '../utilities/config.ts';
32
+ import { validateParam } from '../utilities/types.ts';
33
33
 
34
34
  type ModalTextInput = Partial<ModalText> & Record<string, unknown>;
35
35
  type ModalContentResult = RenderableContent<Modal>;
@@ -142,6 +142,14 @@ const DEFAULT_CLASS_NAMES: ModalClassNames = {
142
142
  confirmBtn: 'is-primary',
143
143
  };
144
144
 
145
+ function createDefaultText(): ModalText {
146
+ return {
147
+ title: translate('Tip'),
148
+ confirm: translate('Confirm'),
149
+ cancel: translate('Cancel'),
150
+ };
151
+ }
152
+
145
153
  function cloneProps(props: ResolvedModalProps): ResolvedModalProps {
146
154
  return {
147
155
  ...props,
@@ -172,21 +180,28 @@ const MODAL_CONTENT_RULE = {
172
180
  };
173
181
 
174
182
  const MODAL_TEXT_RULE = {
175
- default: {},
176
- type: 'object',
177
- plain: true,
178
- normalize: (value: unknown) => {
179
- const text = (isPlainObject(value) ? value : {}) as ModalTextInput;
180
- return {
181
- ...text,
182
- title: typeof text.title === 'string' ? text.title : translate('Tip'),
183
- confirm:
184
- typeof text.confirm === 'string' ? text.confirm : translate('Confirm'),
185
- cancel:
186
- typeof text.cancel === 'string' ? text.cancel : translate('Cancel'),
187
- };
183
+ defaultFactory: createDefaultText,
184
+ type: 'plainObject',
185
+ merge: 'shallow',
186
+ schema: {
187
+ title: 'string',
188
+ confirm: 'string',
189
+ cancel: 'string',
188
190
  },
189
- };
191
+ } satisfies ConfigRule<ModalProps>;
192
+
193
+ const MODAL_CLASS_NAMES_SCHEMA = {
194
+ layout: 'string',
195
+ modal: 'string',
196
+ header: 'string',
197
+ body: 'string',
198
+ footer: 'string',
199
+ title: 'string',
200
+ closeBtn: 'string',
201
+ cancelBtn: 'string',
202
+ confirmBtn: 'string',
203
+ button: 'string',
204
+ } satisfies ConfigSchema;
190
205
 
191
206
  const MODAL_PROPS_SCHEMA = {
192
207
  content: { default: '', ...MODAL_CONTENT_RULE },
@@ -196,6 +211,7 @@ const MODAL_PROPS_SCHEMA = {
196
211
  showCancel: { default: true, type: 'boolean' },
197
212
  showClose: { default: true, type: 'boolean' },
198
213
  fullscreen: { default: false, type: 'boolean' },
214
+ style: { default: null, types: ['string', 'plainObject', 'null'] },
199
215
  text: MODAL_TEXT_RULE,
200
216
  onShow: { default: null, types: ['function', 'null'] },
201
217
  onShown: { default: null, types: ['function', 'null'] },
@@ -221,13 +237,11 @@ const MODAL_PROPS_SCHEMA = {
221
237
  bgClose: { default: false, type: 'boolean' },
222
238
  className: {
223
239
  default: DEFAULT_CLASS_NAMES,
224
- type: 'object',
225
- normalize: (value: unknown) => ({
226
- ...DEFAULT_CLASS_NAMES,
227
- ...(value && typeof value === 'object' ? value : {}),
228
- }),
240
+ type: 'plainObject',
241
+ merge: 'shallow',
242
+ schema: MODAL_CLASS_NAMES_SCHEMA,
229
243
  },
230
- } satisfies ResolveSchema<ModalProps>;
244
+ } satisfies ConfigSchema<ModalProps>;
231
245
 
232
246
  const MODAL_STATE_SCHEMA = {
233
247
  content: MODAL_PROPS_SCHEMA.content,
@@ -241,7 +255,7 @@ const MODAL_UPDATE_RULE = {
241
255
  };
242
256
 
243
257
  function normalizeProps(input: ModalProps): ResolvedModalProps {
244
- const props = resolveProps(input, MODAL_PROPS_SCHEMA, 'Modal');
258
+ const props = resolveConfig(input, MODAL_PROPS_SCHEMA, 'Modal');
245
259
  return {
246
260
  content: props.content as ModalContent,
247
261
  cache: props.cache as boolean,
@@ -19,11 +19,8 @@ import { createEventManager } from '../utilities/events.ts';
19
19
  import { createMotionGroup, createTransition } from '../core/motion.ts';
20
20
  import { createPresence } from '../core/presence.ts';
21
21
  import { createElementRef } from '../utilities/refs.ts';
22
- import {
23
- type ResolveSchema,
24
- resolveProps,
25
- validateParam,
26
- } from '../utilities/types.ts';
22
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
23
+ import { validateParam } from '../utilities/types.ts';
27
24
 
28
25
  export type OffcanvasDirection = 'top' | 'right' | 'bottom' | 'left';
29
26
  export type OffcanvasAnimate = string;
@@ -147,17 +144,14 @@ const OFFCANVAS_PROPS_SCHEMA = {
147
144
  },
148
145
  className: {
149
146
  default: DEFAULT_CLASS_NAMES,
150
- type: 'object',
151
- normalize: (value: unknown) => ({
152
- ...DEFAULT_CLASS_NAMES,
153
- ...(value && typeof value === 'object' ? value : {}),
154
- }),
147
+ type: 'plainObject',
148
+ merge: 'shallow',
155
149
  },
156
150
  onShow: { default: null, types: ['function', 'null'] },
157
151
  onShown: { default: null, types: ['function', 'null'] },
158
152
  onHide: { default: null, types: ['function', 'null'] },
159
153
  onHidden: { default: null, types: ['function', 'null'] },
160
- } satisfies ResolveSchema<OffcanvasProps>;
154
+ } satisfies ConfigSchema<OffcanvasProps>;
161
155
 
162
156
  const OFFCANVAS_STATE_SCHEMA = {
163
157
  content: OFFCANVAS_PROPS_SCHEMA.content,
@@ -170,7 +164,7 @@ function normalizeTtl(ttl: number): number {
170
164
  }
171
165
 
172
166
  function normalizeProps(input: OffcanvasProps): ResolvedOffcanvasProps {
173
- const props = resolveProps(input, OFFCANVAS_PROPS_SCHEMA, 'Offcanvas');
167
+ const props = resolveConfig(input, OFFCANVAS_PROPS_SCHEMA, 'Offcanvas');
174
168
  return {
175
169
  content: props.content as OffcanvasContent,
176
170
  overlay: props.overlay as boolean,
@@ -13,11 +13,8 @@ import {
13
13
  } from '../core/component.ts';
14
14
  import { icon } from '../primitives/icons.ts';
15
15
  import { isPlainObject } from '../utilities/object.ts';
16
- import {
17
- type ResolveSchema,
18
- resolveProps,
19
- validateParam,
20
- } from '../utilities/types.ts';
16
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
17
+ import { validateParam } from '../utilities/types.ts';
21
18
  import { translate } from '../utilities/locale.ts';
22
19
  import { createLoading } from '../primitives/loading.ts';
23
20
 
@@ -137,34 +134,23 @@ const COUNT_RULE = {
137
134
  const PAGINATION_PROPS_SCHEMA = {
138
135
  total: TOTAL_RULE,
139
136
  page: {
140
- default: () => ({ ...DEFAULT_PAGE }),
141
- factory: true,
142
- normalize: (value: unknown) => ({
143
- ...DEFAULT_PAGE,
144
- ...(value && typeof value === 'object' ? value : {}),
145
- }),
137
+ default: DEFAULT_PAGE,
138
+ merge: 'shallow',
146
139
  ...PAGE_RULE,
147
140
  },
148
141
  count: {
149
- default: () => ({ ...DEFAULT_COUNT }),
150
- factory: true,
151
- normalize: (value: unknown) => ({
152
- ...DEFAULT_COUNT,
153
- ...(value && typeof value === 'object' ? value : {}),
154
- }),
142
+ default: DEFAULT_COUNT,
143
+ merge: 'shallow',
155
144
  ...COUNT_RULE,
156
145
  },
157
146
  lock: { default: true, type: 'boolean' },
158
147
  onChange: { default: null, types: ['function', 'null'] },
159
148
  className: {
160
149
  default: DEFAULT_CLASS_NAMES,
161
- type: 'object',
162
- normalize: (value: unknown) => ({
163
- ...DEFAULT_CLASS_NAMES,
164
- ...(value && typeof value === 'object' ? value : {}),
165
- }),
150
+ type: 'plainObject',
151
+ merge: 'shallow',
166
152
  },
167
- } satisfies ResolveSchema<PaginationProps>;
153
+ } satisfies ConfigSchema<PaginationProps>;
168
154
 
169
155
  const PAGINATION_STATE_SCHEMA = {
170
156
  total: TOTAL_RULE,
@@ -190,7 +176,7 @@ function cloneCount(count: PaginationCount): PaginationCount {
190
176
  }
191
177
 
192
178
  function normalizeProps(input: PaginationProps = {}): ResolvedPaginationProps {
193
- const props = resolveProps(
179
+ const props = resolveConfig(
194
180
  input,
195
181
  PAGINATION_PROPS_SCHEMA,
196
182
  'Pagination.props'
@@ -23,11 +23,8 @@ import {
23
23
  import { createEventManager } from '../utilities/events.ts';
24
24
  import { randomId } from '../utilities/id.ts';
25
25
  import { createScheduledTask } from '../core/scheduler.ts';
26
- import {
27
- type ResolveSchema,
28
- resolveProps,
29
- validateParam,
30
- } from '../utilities/types.ts';
26
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
27
+ import { validateParam } from '../utilities/types.ts';
31
28
 
32
29
  const SWIPE_THRESHOLD = 6;
33
30
  const AUTOPLAY_DELAY_FLOOR = 16;
@@ -217,13 +214,10 @@ const SWIPER_OPTIONS_SCHEMA = {
217
214
  preventClick: { default: true, type: 'boolean' },
218
215
  className: {
219
216
  default: DEFAULT_CLASS_NAMES,
220
- type: 'object',
221
- normalize: (value: unknown) => ({
222
- ...DEFAULT_CLASS_NAMES,
223
- ...(value && typeof value === 'object' ? value : {}),
224
- }),
217
+ type: 'plainObject',
218
+ merge: 'shallow',
225
219
  },
226
- } satisfies ResolveSchema<SwiperProps>;
220
+ } satisfies ConfigSchema<SwiperProps>;
227
221
 
228
222
  const SWIPER_DATA_ITEM_RULE = {
229
223
  type: 'plainObject',
@@ -270,7 +264,7 @@ function cloneDataSource(source: SwiperDataSource): SwiperDataSource {
270
264
  }
271
265
 
272
266
  function normalizeProps(input: SwiperProps = {}): ResolvedSwiperProps {
273
- const props = resolveProps(
267
+ const props = resolveConfig(
274
268
  input,
275
269
  SWIPER_OPTIONS_SCHEMA,
276
270
  'Swiper.props'
@@ -279,7 +273,7 @@ function normalizeProps(input: SwiperProps = {}): ResolvedSwiperProps {
279
273
  ...props,
280
274
  id: props.id?.trim() || null,
281
275
  data: cloneDataSource(props.data),
282
- className: { ...props.className },
276
+ className: props.className as SwiperClassNames,
283
277
  };
284
278
  }
285
279
 
@@ -23,11 +23,8 @@ import { createEventManager } from '../utilities/events.ts';
23
23
  import { randomId } from '../utilities/id.ts';
24
24
  import { createElementRef, createKeyedElementRefs } from '../utilities/refs.ts';
25
25
  import { createScheduledTask } from '../core/scheduler.ts';
26
- import {
27
- type ResolveSchema,
28
- resolveProps,
29
- validateParam,
30
- } from '../utilities/types.ts';
26
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
27
+ import { validateParam } from '../utilities/types.ts';
31
28
 
32
29
  export type TabsDirection = 'top' | 'bottom' | 'left' | 'right';
33
30
  export type TabsValue = number | string;
@@ -160,13 +157,10 @@ const TABS_PROPS_SCHEMA = {
160
157
  data: { default: [], type: 'array' },
161
158
  className: {
162
159
  default: DEFAULT_CLASS_NAMES,
163
- type: 'object',
164
- normalize: (value: unknown) => ({
165
- ...DEFAULT_CLASS_NAMES,
166
- ...(value && typeof value === 'object' ? value : {}),
167
- }),
160
+ type: 'plainObject',
161
+ merge: 'shallow',
168
162
  },
169
- } satisfies ResolveSchema<TabsProps>;
163
+ } satisfies ConfigSchema<TabsProps>;
170
164
 
171
165
  const TAB_CONFIG_RULE = {
172
166
  type: 'plainObject',
@@ -217,7 +211,7 @@ function normalizeDisabled(disabled: TabsDisabled): TabsDisabled {
217
211
  }
218
212
 
219
213
  function normalizeProps(input: TabsProps): ResolvedTabsProps {
220
- const props = resolveProps(input, TABS_PROPS_SCHEMA, 'Tabs.props');
214
+ const props = resolveConfig(input, TABS_PROPS_SCHEMA, 'Tabs.props');
221
215
  return {
222
216
  id: props.id as string,
223
217
  direction: props.direction as TabsDirection,
@@ -18,7 +18,7 @@ import {
18
18
  } from '../utilities/dom.ts';
19
19
  import { createEventManager } from '../utilities/events.ts';
20
20
  import { randomId } from '../utilities/id.ts';
21
- import { type ResolveSchema, resolveProps } from '../utilities/types.ts';
21
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
22
22
 
23
23
  interface TocClassNames {
24
24
  toc: string;
@@ -110,19 +110,16 @@ const TOC_PROPS_SCHEMA = {
110
110
  reactive: { default: false, type: 'boolean' },
111
111
  className: {
112
112
  default: DEFAULT_CLASS_NAMES,
113
- type: 'object',
114
- normalize: (value: unknown) => ({
115
- ...DEFAULT_CLASS_NAMES,
116
- ...(value && typeof value === 'object' ? value : {}),
117
- }),
113
+ type: 'plainObject',
114
+ merge: 'shallow',
118
115
  },
119
116
  onChange: { default: null, types: ['function', 'null'] },
120
- } satisfies ResolveSchema<TocProps>;
117
+ } satisfies ConfigSchema<TocProps>;
121
118
 
122
119
  const ACTIVE_OFFSET_TOLERANCE = 1;
123
120
 
124
121
  function normalizeProps(input: TocProps): ResolvedTocProps {
125
- const props = resolveProps(input, TOC_PROPS_SCHEMA, 'Toc.props');
122
+ const props = resolveConfig(input, TOC_PROPS_SCHEMA, 'Toc.props');
126
123
  return {
127
124
  target: props.target as DOMReference,
128
125
  headings: props.headings as string,
package/src/index.ts CHANGED
@@ -7,10 +7,13 @@ export * from './utilities/id.ts';
7
7
  export * from './utilities/dom.ts';
8
8
  export * from './utilities/events.ts';
9
9
  export * from './utilities/http.ts';
10
- export * from './utilities/locale.ts';
10
+ // do not export any function from locale.ts
11
+ // export * from './utilities/locale.ts';
11
12
  export * from './utilities/object.ts';
12
13
  export * from './utilities/timer.ts';
13
14
  export * from './utilities/types.ts';
15
+ export * from './utilities/merge.ts';
16
+ export * from './utilities/config.ts';
14
17
  export * from './utilities/state.ts';
15
18
  export * from './utilities/refs.ts';
16
19
  export * from './utilities/validator.ts';
@@ -8,7 +8,7 @@ import {
8
8
  } from '../utilities/dom.ts';
9
9
  import { createEventManager } from '../utilities/events.ts';
10
10
  import { randomId } from '../utilities/id.ts';
11
- import { type ResolveSchema, resolveProps } from '../utilities/types.ts';
11
+ import { type ConfigSchema, resolveConfig } from '../utilities/config.ts';
12
12
  import { createLoading } from './loading.ts';
13
13
 
14
14
  type DropMode = 'hover' | 'click';
@@ -144,11 +144,8 @@ const DROP_PROPS_SCHEMA = {
144
144
  },
145
145
  className: {
146
146
  default: DEFAULT_CLASS_NAMES,
147
- type: 'object',
148
- normalize: (value: unknown) => ({
149
- ...DEFAULT_CLASS_NAMES,
150
- ...(value && typeof value === 'object' ? value : {}),
151
- }),
147
+ type: 'plainObject',
148
+ merge: 'shallow',
152
149
  },
153
150
  id: {
154
151
  default: null,
@@ -166,10 +163,10 @@ const DROP_PROPS_SCHEMA = {
166
163
  hoverIntent: { default: true, type: 'boolean' },
167
164
  onShown: { default: null, types: ['function', 'null'] },
168
165
  onHidden: { default: null, types: ['function', 'null'] },
169
- } satisfies ResolveSchema<DropProps>;
166
+ } satisfies ConfigSchema<DropProps>;
170
167
 
171
168
  function normalizeProps(input: DropProps): ResolvedDropProps {
172
- const props = resolveProps(input, DROP_PROPS_SCHEMA, 'Drop');
169
+ const props = resolveConfig(input, DROP_PROPS_SCHEMA, 'Drop');
173
170
  return {
174
171
  name: props.name as string | null,
175
172
  mode: props.mode as DropMode,