@hoci/core 0.5.6 → 0.5.7

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/index.cjs CHANGED
@@ -187,15 +187,20 @@ const selectionEmits = shared.defineHookEmits([
187
187
  "update:modelValue",
188
188
  "change",
189
189
  "load",
190
- "unload"
190
+ "unload",
191
+ "reject"
191
192
  ]);
192
193
  const HiSelectionContextSymbol = Symbol("[hi-selection]context");
193
194
  function useSelectionContext() {
194
195
  const sharedConfig = shared.useSharedConfig();
195
196
  return vue.inject(HiSelectionContextSymbol, {
196
197
  isActive: () => false,
198
+ activate: () => {
199
+ },
197
200
  changeActive: () => {
198
201
  },
202
+ reject: () => {
203
+ },
199
204
  activeClass: "active",
200
205
  unactiveClass: "unactive",
201
206
  disabledClass: "disabled",
@@ -243,7 +248,7 @@ const useSelectionList = shared.defineHookComponent({
243
248
  function isActive(value) {
244
249
  return actives.includes(value);
245
250
  }
246
- function changeActive(value) {
251
+ function activate(value) {
247
252
  if (isActive(value)) {
248
253
  if (props.multiple || props.clearable) {
249
254
  actives.splice(actives.indexOf(value), 1);
@@ -262,6 +267,9 @@ const useSelectionList = shared.defineHookComponent({
262
267
  }
263
268
  }
264
269
  }
270
+ function reject(value) {
271
+ emit("reject", value);
272
+ }
265
273
  const init = (option) => {
266
274
  function remove() {
267
275
  const index = options.findIndex((e) => e.id === option.id);
@@ -292,8 +300,10 @@ const useSelectionList = shared.defineHookComponent({
292
300
  defaultValue: vue.computed(() => props.defaultValue),
293
301
  activateEvent: vue.computed(() => props.activateEvent ?? sharedConfig.activateEvent),
294
302
  active: currentValue,
295
- changeActive,
303
+ activate,
304
+ changeActive: activate,
296
305
  isActive,
306
+ reject,
297
307
  init
298
308
  }));
299
309
  const renderItem = () => {
@@ -302,7 +312,7 @@ const useSelectionList = shared.defineHookComponent({
302
312
  };
303
313
  const slotData = {
304
314
  isActive,
305
- changeActive,
315
+ changeActive: activate,
306
316
  renderItem
307
317
  };
308
318
  const render = () => {
@@ -312,7 +322,7 @@ const useSelectionList = shared.defineHookComponent({
312
322
  options,
313
323
  actives,
314
324
  isActive,
315
- changeActive,
325
+ changeActive: activate,
316
326
  renderItem,
317
327
  render
318
328
  };
@@ -344,15 +354,19 @@ const itemProps = shared.defineHookProps({
344
354
  default: false
345
355
  }
346
356
  });
357
+ const itemEmits = shared.defineHookEmits(["reject"]);
347
358
  const useSelectionItem = shared.defineHookComponent({
348
359
  props: itemProps,
349
- setup(props, { slots }) {
360
+ emits: itemEmits,
361
+ setup(props, { slots, emit }) {
350
362
  const context = useSelectionContext();
351
363
  const activate = () => {
352
364
  if (props.disabled) {
365
+ emit("reject", props.value);
366
+ context.reject(props.value);
353
367
  return;
354
368
  }
355
- context.changeActive(props.value);
369
+ context.activate(props.value);
356
370
  };
357
371
  const label = vue.computed(() => {
358
372
  let label2 = props.label ?? context.label;
@@ -435,7 +449,7 @@ const switchProps = shared.defineHookProps({
435
449
  type: shared.classPropType
436
450
  }
437
451
  });
438
- const switchEmits = shared.defineHookEmits(["update:modelValue", "change"]);
452
+ const switchEmits = shared.defineHookEmits(["update:modelValue", "change", "reject"]);
439
453
  const useSwitch = shared.defineHookComponent({
440
454
  props: switchProps,
441
455
  emits: switchEmits,
@@ -446,6 +460,7 @@ const useSwitch = shared.defineHookComponent({
446
460
  });
447
461
  const toggle = function(value) {
448
462
  if (props.disabled) {
463
+ context.emit("reject", value);
449
464
  return;
450
465
  }
451
466
  const oldValue = modelValue.value;
@@ -798,6 +813,7 @@ exports.affixEmits = affixEmits;
798
813
  exports.affixProps = affixProps;
799
814
  exports.configProviderProps = configProviderProps;
800
815
  exports.iconProps = iconProps;
816
+ exports.itemEmits = itemEmits;
801
817
  exports.itemProps = itemProps;
802
818
  exports.popoverEmits = popoverEmits;
803
819
  exports.popoverProps = popoverProps;
package/dist/index.d.cts CHANGED
@@ -138,6 +138,12 @@ interface Option {
138
138
  render(): ElementLike;
139
139
  }
140
140
  interface HiSelectionContext {
141
+ activate: (_: any) => void;
142
+ reject: (_: any) => void;
143
+ /**
144
+ * @deprecated
145
+ * use activate instead
146
+ */
141
147
  changeActive: (_: any) => void;
142
148
  isActive: (_: any) => boolean;
143
149
  init?: InitFunction;
@@ -201,7 +207,7 @@ declare const selectionProps: {
201
207
  };
202
208
  };
203
209
  type SelectionProps = typeof selectionProps;
204
- declare const selectionEmits: ("change" | "load" | "unload" | "update:modelValue")[];
210
+ declare const selectionEmits: ("change" | "load" | "unload" | "update:modelValue" | "reject")[];
205
211
  declare function useSelectionContext(): HiSelectionContext;
206
212
  declare const useSelectionList: _hoci_shared.HookComponent<{
207
213
  options: {
@@ -217,7 +223,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
217
223
  render: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
218
224
  [key: string]: any;
219
225
  }>;
220
- }, ("change" | "load" | "unload" | "update:modelValue")[], {
226
+ }, ("change" | "load" | "unload" | "update:modelValue" | "reject")[], {
221
227
  modelValue: {
222
228
  type: PropType<any>;
223
229
  default: () => null;
@@ -356,6 +362,7 @@ declare const itemProps: {
356
362
  default: boolean;
357
363
  };
358
364
  };
365
+ declare const itemEmits: "reject"[];
359
366
  declare const useSelectionItem: _hoci_shared.HookComponent<{
360
367
  activate: () => void;
361
368
  render: () => ElementLike;
@@ -364,7 +371,7 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
364
371
  className: vue.ComputedRef<string>;
365
372
  activateEvent: vue.ComputedRef<ActivateEvent>;
366
373
  label: vue.ComputedRef<ElementLike[] | (string | JSX.Element | null | undefined)[]>;
367
- }, vue.EmitsOptions, {
374
+ }, "reject"[], {
368
375
  value: {
369
376
  type: PropType<any>;
370
377
  default(): string;
@@ -444,14 +451,14 @@ declare const switchProps: {
444
451
  };
445
452
  };
446
453
  type HiSwitchProps = typeof switchProps;
447
- declare const switchEmits: ("change" | "update:modelValue")[];
454
+ declare const switchEmits: ("change" | "update:modelValue" | "reject")[];
448
455
  declare const useSwitch: _hoci_shared.HookComponent<{
449
456
  toggle: (value?: any) => void;
450
457
  modelValue: vue.Ref<boolean> | vue.WritableComputedRef<boolean>;
451
458
  className: vue.ComputedRef<string>;
452
459
  isDisabled: vue.ComputedRef<boolean>;
453
460
  activateEvent: vue.ComputedRef<ActivateEvent>;
454
- }, ("change" | "update:modelValue")[], {
461
+ }, ("change" | "update:modelValue" | "reject")[], {
455
462
  modelValue: {
456
463
  type: BooleanConstructor;
457
464
  default: () => false;
@@ -727,4 +734,4 @@ declare const usePopover: _hoci_shared.HookComponent<{
727
734
  teleport: string | boolean | HTMLElement;
728
735
  }>;
729
736
 
730
- export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type Placement, type SelectionProps, type TriggerEvent, affixEmits, affixProps, configProviderProps, iconProps, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
737
+ export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type Placement, type SelectionProps, type TriggerEvent, affixEmits, affixProps, configProviderProps, iconProps, itemEmits, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
package/dist/index.d.mts CHANGED
@@ -138,6 +138,12 @@ interface Option {
138
138
  render(): ElementLike;
139
139
  }
140
140
  interface HiSelectionContext {
141
+ activate: (_: any) => void;
142
+ reject: (_: any) => void;
143
+ /**
144
+ * @deprecated
145
+ * use activate instead
146
+ */
141
147
  changeActive: (_: any) => void;
142
148
  isActive: (_: any) => boolean;
143
149
  init?: InitFunction;
@@ -201,7 +207,7 @@ declare const selectionProps: {
201
207
  };
202
208
  };
203
209
  type SelectionProps = typeof selectionProps;
204
- declare const selectionEmits: ("change" | "load" | "unload" | "update:modelValue")[];
210
+ declare const selectionEmits: ("change" | "load" | "unload" | "update:modelValue" | "reject")[];
205
211
  declare function useSelectionContext(): HiSelectionContext;
206
212
  declare const useSelectionList: _hoci_shared.HookComponent<{
207
213
  options: {
@@ -217,7 +223,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
217
223
  render: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
218
224
  [key: string]: any;
219
225
  }>;
220
- }, ("change" | "load" | "unload" | "update:modelValue")[], {
226
+ }, ("change" | "load" | "unload" | "update:modelValue" | "reject")[], {
221
227
  modelValue: {
222
228
  type: PropType<any>;
223
229
  default: () => null;
@@ -356,6 +362,7 @@ declare const itemProps: {
356
362
  default: boolean;
357
363
  };
358
364
  };
365
+ declare const itemEmits: "reject"[];
359
366
  declare const useSelectionItem: _hoci_shared.HookComponent<{
360
367
  activate: () => void;
361
368
  render: () => ElementLike;
@@ -364,7 +371,7 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
364
371
  className: vue.ComputedRef<string>;
365
372
  activateEvent: vue.ComputedRef<ActivateEvent>;
366
373
  label: vue.ComputedRef<ElementLike[] | (string | JSX.Element | null | undefined)[]>;
367
- }, vue.EmitsOptions, {
374
+ }, "reject"[], {
368
375
  value: {
369
376
  type: PropType<any>;
370
377
  default(): string;
@@ -444,14 +451,14 @@ declare const switchProps: {
444
451
  };
445
452
  };
446
453
  type HiSwitchProps = typeof switchProps;
447
- declare const switchEmits: ("change" | "update:modelValue")[];
454
+ declare const switchEmits: ("change" | "update:modelValue" | "reject")[];
448
455
  declare const useSwitch: _hoci_shared.HookComponent<{
449
456
  toggle: (value?: any) => void;
450
457
  modelValue: vue.Ref<boolean> | vue.WritableComputedRef<boolean>;
451
458
  className: vue.ComputedRef<string>;
452
459
  isDisabled: vue.ComputedRef<boolean>;
453
460
  activateEvent: vue.ComputedRef<ActivateEvent>;
454
- }, ("change" | "update:modelValue")[], {
461
+ }, ("change" | "update:modelValue" | "reject")[], {
455
462
  modelValue: {
456
463
  type: BooleanConstructor;
457
464
  default: () => false;
@@ -727,4 +734,4 @@ declare const usePopover: _hoci_shared.HookComponent<{
727
734
  teleport: string | boolean | HTMLElement;
728
735
  }>;
729
736
 
730
- export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type Placement, type SelectionProps, type TriggerEvent, affixEmits, affixProps, configProviderProps, iconProps, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
737
+ export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type Placement, type SelectionProps, type TriggerEvent, affixEmits, affixProps, configProviderProps, iconProps, itemEmits, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
package/dist/index.d.ts CHANGED
@@ -138,6 +138,12 @@ interface Option {
138
138
  render(): ElementLike;
139
139
  }
140
140
  interface HiSelectionContext {
141
+ activate: (_: any) => void;
142
+ reject: (_: any) => void;
143
+ /**
144
+ * @deprecated
145
+ * use activate instead
146
+ */
141
147
  changeActive: (_: any) => void;
142
148
  isActive: (_: any) => boolean;
143
149
  init?: InitFunction;
@@ -201,7 +207,7 @@ declare const selectionProps: {
201
207
  };
202
208
  };
203
209
  type SelectionProps = typeof selectionProps;
204
- declare const selectionEmits: ("change" | "load" | "unload" | "update:modelValue")[];
210
+ declare const selectionEmits: ("change" | "load" | "unload" | "update:modelValue" | "reject")[];
205
211
  declare function useSelectionContext(): HiSelectionContext;
206
212
  declare const useSelectionList: _hoci_shared.HookComponent<{
207
213
  options: {
@@ -217,7 +223,7 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
217
223
  render: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
218
224
  [key: string]: any;
219
225
  }>;
220
- }, ("change" | "load" | "unload" | "update:modelValue")[], {
226
+ }, ("change" | "load" | "unload" | "update:modelValue" | "reject")[], {
221
227
  modelValue: {
222
228
  type: PropType<any>;
223
229
  default: () => null;
@@ -356,6 +362,7 @@ declare const itemProps: {
356
362
  default: boolean;
357
363
  };
358
364
  };
365
+ declare const itemEmits: "reject"[];
359
366
  declare const useSelectionItem: _hoci_shared.HookComponent<{
360
367
  activate: () => void;
361
368
  render: () => ElementLike;
@@ -364,7 +371,7 @@ declare const useSelectionItem: _hoci_shared.HookComponent<{
364
371
  className: vue.ComputedRef<string>;
365
372
  activateEvent: vue.ComputedRef<ActivateEvent>;
366
373
  label: vue.ComputedRef<ElementLike[] | (string | JSX.Element | null | undefined)[]>;
367
- }, vue.EmitsOptions, {
374
+ }, "reject"[], {
368
375
  value: {
369
376
  type: PropType<any>;
370
377
  default(): string;
@@ -444,14 +451,14 @@ declare const switchProps: {
444
451
  };
445
452
  };
446
453
  type HiSwitchProps = typeof switchProps;
447
- declare const switchEmits: ("change" | "update:modelValue")[];
454
+ declare const switchEmits: ("change" | "update:modelValue" | "reject")[];
448
455
  declare const useSwitch: _hoci_shared.HookComponent<{
449
456
  toggle: (value?: any) => void;
450
457
  modelValue: vue.Ref<boolean> | vue.WritableComputedRef<boolean>;
451
458
  className: vue.ComputedRef<string>;
452
459
  isDisabled: vue.ComputedRef<boolean>;
453
460
  activateEvent: vue.ComputedRef<ActivateEvent>;
454
- }, ("change" | "update:modelValue")[], {
461
+ }, ("change" | "update:modelValue" | "reject")[], {
455
462
  modelValue: {
456
463
  type: BooleanConstructor;
457
464
  default: () => false;
@@ -727,4 +734,4 @@ declare const usePopover: _hoci_shared.HookComponent<{
727
734
  teleport: string | boolean | HTMLElement;
728
735
  }>;
729
736
 
730
- export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type Placement, type SelectionProps, type TriggerEvent, affixEmits, affixProps, configProviderProps, iconProps, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
737
+ export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type Placement, type SelectionProps, type TriggerEvent, affixEmits, affixProps, configProviderProps, iconProps, itemEmits, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
package/dist/index.mjs CHANGED
@@ -186,15 +186,20 @@ const selectionEmits = defineHookEmits([
186
186
  "update:modelValue",
187
187
  "change",
188
188
  "load",
189
- "unload"
189
+ "unload",
190
+ "reject"
190
191
  ]);
191
192
  const HiSelectionContextSymbol = Symbol("[hi-selection]context");
192
193
  function useSelectionContext() {
193
194
  const sharedConfig = useSharedConfig();
194
195
  return inject(HiSelectionContextSymbol, {
195
196
  isActive: () => false,
197
+ activate: () => {
198
+ },
196
199
  changeActive: () => {
197
200
  },
201
+ reject: () => {
202
+ },
198
203
  activeClass: "active",
199
204
  unactiveClass: "unactive",
200
205
  disabledClass: "disabled",
@@ -242,7 +247,7 @@ const useSelectionList = defineHookComponent({
242
247
  function isActive(value) {
243
248
  return actives.includes(value);
244
249
  }
245
- function changeActive(value) {
250
+ function activate(value) {
246
251
  if (isActive(value)) {
247
252
  if (props.multiple || props.clearable) {
248
253
  actives.splice(actives.indexOf(value), 1);
@@ -261,6 +266,9 @@ const useSelectionList = defineHookComponent({
261
266
  }
262
267
  }
263
268
  }
269
+ function reject(value) {
270
+ emit("reject", value);
271
+ }
264
272
  const init = (option) => {
265
273
  function remove() {
266
274
  const index = options.findIndex((e) => e.id === option.id);
@@ -291,8 +299,10 @@ const useSelectionList = defineHookComponent({
291
299
  defaultValue: computed(() => props.defaultValue),
292
300
  activateEvent: computed(() => props.activateEvent ?? sharedConfig.activateEvent),
293
301
  active: currentValue,
294
- changeActive,
302
+ activate,
303
+ changeActive: activate,
295
304
  isActive,
305
+ reject,
296
306
  init
297
307
  }));
298
308
  const renderItem = () => {
@@ -301,7 +311,7 @@ const useSelectionList = defineHookComponent({
301
311
  };
302
312
  const slotData = {
303
313
  isActive,
304
- changeActive,
314
+ changeActive: activate,
305
315
  renderItem
306
316
  };
307
317
  const render = () => {
@@ -311,7 +321,7 @@ const useSelectionList = defineHookComponent({
311
321
  options,
312
322
  actives,
313
323
  isActive,
314
- changeActive,
324
+ changeActive: activate,
315
325
  renderItem,
316
326
  render
317
327
  };
@@ -343,15 +353,19 @@ const itemProps = defineHookProps({
343
353
  default: false
344
354
  }
345
355
  });
356
+ const itemEmits = defineHookEmits(["reject"]);
346
357
  const useSelectionItem = defineHookComponent({
347
358
  props: itemProps,
348
- setup(props, { slots }) {
359
+ emits: itemEmits,
360
+ setup(props, { slots, emit }) {
349
361
  const context = useSelectionContext();
350
362
  const activate = () => {
351
363
  if (props.disabled) {
364
+ emit("reject", props.value);
365
+ context.reject(props.value);
352
366
  return;
353
367
  }
354
- context.changeActive(props.value);
368
+ context.activate(props.value);
355
369
  };
356
370
  const label = computed(() => {
357
371
  let label2 = props.label ?? context.label;
@@ -434,7 +448,7 @@ const switchProps = defineHookProps({
434
448
  type: classPropType
435
449
  }
436
450
  });
437
- const switchEmits = defineHookEmits(["update:modelValue", "change"]);
451
+ const switchEmits = defineHookEmits(["update:modelValue", "change", "reject"]);
438
452
  const useSwitch = defineHookComponent({
439
453
  props: switchProps,
440
454
  emits: switchEmits,
@@ -445,6 +459,7 @@ const useSwitch = defineHookComponent({
445
459
  });
446
460
  const toggle = function(value) {
447
461
  if (props.disabled) {
462
+ context.emit("reject", value);
448
463
  return;
449
464
  }
450
465
  const oldValue = modelValue.value;
@@ -792,4 +807,4 @@ const usePopover = defineHookComponent({
792
807
  }
793
808
  });
794
809
 
795
- export { AFFIX_TARGET_KEY, affixEmits, affixProps, configProviderProps, iconProps, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
810
+ export { AFFIX_TARGET_KEY, affixEmits, affixProps, configProviderProps, iconProps, itemEmits, itemProps, popoverEmits, popoverProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, usePopover, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoci/core",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "description": "",
5
5
  "author": "Chizuki <chizukicn@outlook.com>",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "@vueuse/core": "9.0.0",
31
31
  "maybe-types": "^0.2.0",
32
32
  "tslx": "^0.1.1",
33
- "@hoci/shared": "0.5.6"
33
+ "@hoci/shared": "0.5.7"
34
34
  },
35
35
  "scripts": {
36
36
  "build": "unbuild",