hoci 0.0.11 → 0.0.12

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
@@ -122,9 +122,13 @@ const useSelectionItem = defineHookComponent({
122
122
  const changeActive = vue.inject(ChangeActiveSymbol, () => {
123
123
  });
124
124
  const parentLabel = core.resolveRef(vue.inject(ItemLabelSymbol));
125
+ const activate = () => {
126
+ changeActive(props.value);
127
+ };
125
128
  function render() {
126
129
  return vue.renderSlot(slots, "default", {
127
- active: isActive(props.value)
130
+ active: isActive(props.value),
131
+ activate
128
132
  }, () => {
129
133
  var _a;
130
134
  let label = (_a = props.label) != null ? _a : parentLabel.value;
@@ -210,26 +214,6 @@ const HiItem = vue.defineComponent({
210
214
  }
211
215
  });
212
216
 
213
- var __async = (__this, __arguments, generator) => {
214
- return new Promise((resolve, reject) => {
215
- var fulfilled = (value) => {
216
- try {
217
- step(generator.next(value));
218
- } catch (e) {
219
- reject(e);
220
- }
221
- };
222
- var rejected = (value) => {
223
- try {
224
- step(generator.throw(value));
225
- } catch (e) {
226
- reject(e);
227
- }
228
- };
229
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
230
- step((generator = generator.apply(__this, __arguments)).next());
231
- });
232
- };
233
217
  const selectionListProps = defineHookProps({
234
218
  tag: {
235
219
  type: String,
@@ -348,26 +332,24 @@ const useSelectionList = defineHookComponent({
348
332
  function isActive(value) {
349
333
  return actives.includes(value);
350
334
  }
351
- function changeActive(option) {
352
- return __async(this, null, function* () {
353
- if (isActive(option)) {
354
- if (props.multiple || props.clearable) {
355
- actives.splice(actives.indexOf(option), 1);
335
+ function changeActive(value) {
336
+ if (isActive(value)) {
337
+ if (props.multiple || props.clearable) {
338
+ actives.splice(actives.indexOf(value), 1);
339
+ emitChange();
340
+ }
341
+ } else {
342
+ if (props.multiple) {
343
+ const limit = typeof props.multiple === "number" ? props.multiple : Infinity;
344
+ if (actives.length < limit) {
345
+ actives.push(value);
356
346
  emitChange();
357
347
  }
358
348
  } else {
359
- if (props.multiple) {
360
- const limit = typeof props.multiple === "number" ? props.multiple : Infinity;
361
- if (actives.length < limit) {
362
- actives.push(option);
363
- emitChange();
364
- }
365
- } else {
366
- actives.splice(0, actives.length, option);
367
- emitChange();
368
- }
349
+ actives.splice(0, actives.length, value);
350
+ emitChange();
369
351
  }
370
- });
352
+ }
371
353
  }
372
354
  vue.provide(IsActiveSymbol, isActive);
373
355
  vue.provide(ChangeActiveSymbol, changeActive);
@@ -395,7 +377,9 @@ const useSelectionList = defineHookComponent({
395
377
  }
396
378
  function render() {
397
379
  return vue.h(props.tag, {}, vue.renderSlot(slots, "default", {
398
- isActive
380
+ isActive,
381
+ changeActive,
382
+ renderItem
399
383
  }));
400
384
  }
401
385
  return {
package/dist/index.d.ts CHANGED
@@ -129,6 +129,10 @@ declare const HiItem: vue.DefineComponent<{
129
129
  value: any;
130
130
  keepAlive: boolean;
131
131
  }>;
132
+ interface HiItemSlotsData {
133
+ active: boolean;
134
+ activate(): void;
135
+ }
132
136
 
133
137
  declare const selectionListProps: {
134
138
  tag: {
@@ -192,7 +196,7 @@ declare const useSelectionList: HookComponent<{
192
196
  }[];
193
197
  actives: any[];
194
198
  isActive: (value: any) => boolean;
195
- changeActive: (option: any) => Promise<void>;
199
+ changeActive: (value: any) => void;
196
200
  renderItem: () => ElementLike;
197
201
  render: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
198
202
  [key: string]: any;
@@ -430,6 +434,11 @@ declare const HiSelection: vue.DefineComponent<{
430
434
  clearable: boolean;
431
435
  defaultValue: any;
432
436
  }>;
437
+ interface HiSelectionSlotData {
438
+ isActive(value: any): boolean;
439
+ changeActive(value: any): void;
440
+ renderItem: () => ElementLike;
441
+ }
433
442
 
434
443
  declare const switchProps: {
435
444
  modelValue: {
@@ -628,4 +637,4 @@ declare const HiSwitch: vue.DefineComponent<{
628
637
  disabledClass: string | string[] | Record<string, boolean>;
629
638
  }>;
630
639
 
631
- export { HiItem, HiSelection, HiSwitch, HookComponent, HookComponentOptions, defineHookComponent, defineHookEmits, defineHookProps, isExtends, normalizeClass, selectionItemProps, selectionListEmits, selectionListProps, switchEmits, switchProps, useSelectionItem, useSelectionList, useSwitch };
640
+ export { HiItem, HiItemSlotsData, HiSelection, HiSelectionSlotData, HiSwitch, HookComponent, HookComponentOptions, defineHookComponent, defineHookEmits, defineHookProps, isExtends, normalizeClass, selectionItemProps, selectionListEmits, selectionListProps, switchEmits, switchProps, useSelectionItem, useSelectionList, useSwitch };
package/dist/index.esm.js CHANGED
@@ -120,9 +120,13 @@ const useSelectionItem = defineHookComponent({
120
120
  const changeActive = inject(ChangeActiveSymbol, () => {
121
121
  });
122
122
  const parentLabel = resolveRef(inject(ItemLabelSymbol));
123
+ const activate = () => {
124
+ changeActive(props.value);
125
+ };
123
126
  function render() {
124
127
  return renderSlot(slots, "default", {
125
- active: isActive(props.value)
128
+ active: isActive(props.value),
129
+ activate
126
130
  }, () => {
127
131
  var _a;
128
132
  let label = (_a = props.label) != null ? _a : parentLabel.value;
@@ -208,26 +212,6 @@ const HiItem = defineComponent({
208
212
  }
209
213
  });
210
214
 
211
- var __async = (__this, __arguments, generator) => {
212
- return new Promise((resolve, reject) => {
213
- var fulfilled = (value) => {
214
- try {
215
- step(generator.next(value));
216
- } catch (e) {
217
- reject(e);
218
- }
219
- };
220
- var rejected = (value) => {
221
- try {
222
- step(generator.throw(value));
223
- } catch (e) {
224
- reject(e);
225
- }
226
- };
227
- var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
228
- step((generator = generator.apply(__this, __arguments)).next());
229
- });
230
- };
231
215
  const selectionListProps = defineHookProps({
232
216
  tag: {
233
217
  type: String,
@@ -346,26 +330,24 @@ const useSelectionList = defineHookComponent({
346
330
  function isActive(value) {
347
331
  return actives.includes(value);
348
332
  }
349
- function changeActive(option) {
350
- return __async(this, null, function* () {
351
- if (isActive(option)) {
352
- if (props.multiple || props.clearable) {
353
- actives.splice(actives.indexOf(option), 1);
333
+ function changeActive(value) {
334
+ if (isActive(value)) {
335
+ if (props.multiple || props.clearable) {
336
+ actives.splice(actives.indexOf(value), 1);
337
+ emitChange();
338
+ }
339
+ } else {
340
+ if (props.multiple) {
341
+ const limit = typeof props.multiple === "number" ? props.multiple : Infinity;
342
+ if (actives.length < limit) {
343
+ actives.push(value);
354
344
  emitChange();
355
345
  }
356
346
  } else {
357
- if (props.multiple) {
358
- const limit = typeof props.multiple === "number" ? props.multiple : Infinity;
359
- if (actives.length < limit) {
360
- actives.push(option);
361
- emitChange();
362
- }
363
- } else {
364
- actives.splice(0, actives.length, option);
365
- emitChange();
366
- }
347
+ actives.splice(0, actives.length, value);
348
+ emitChange();
367
349
  }
368
- });
350
+ }
369
351
  }
370
352
  provide(IsActiveSymbol, isActive);
371
353
  provide(ChangeActiveSymbol, changeActive);
@@ -393,7 +375,9 @@ const useSelectionList = defineHookComponent({
393
375
  }
394
376
  function render() {
395
377
  return h(props.tag, {}, renderSlot(slots, "default", {
396
- isActive
378
+ isActive,
379
+ changeActive,
380
+ renderItem
397
381
  }));
398
382
  }
399
383
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hoci",
3
- "version": "0.0.11",
3
+ "version": "0.0.12",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.esm.js",