@hoci/core 0.4.2 → 0.4.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/dist/index.cjs CHANGED
@@ -52,7 +52,7 @@ const useAffix = shared.defineHookComponent({
52
52
  props: affixProps,
53
53
  setup(props, { emit }) {
54
54
  const wrapperRef = vue.ref(null);
55
- const parentRef = vue.inject(AFFIX_TARGET_KEY, void 0);
55
+ const parentRef = vue.inject(AFFIX_TARGET_KEY, null);
56
56
  const targetRef = shared.useElement(props.target, parentRef);
57
57
  const isFixed = vue.ref(false);
58
58
  const placeholderStyle = vue.ref({});
@@ -124,6 +124,11 @@ const useAffix = shared.defineHookComponent({
124
124
  function provideAffixTarget(target) {
125
125
  vue.provide(AFFIX_TARGET_KEY, target);
126
126
  }
127
+ function useAffixTargetProvider() {
128
+ const targetRef = vue.ref(null);
129
+ provideAffixTarget(targetRef);
130
+ return targetRef;
131
+ }
127
132
 
128
133
  const selectionProps = shared.defineHookProps({
129
134
  modelValue: {
@@ -201,7 +206,7 @@ function useSelectionContext() {
201
206
  const useSelectionList = shared.defineHookComponent({
202
207
  props: selectionProps,
203
208
  emits: selectionEmits,
204
- setup(props, { emit }) {
209
+ setup(props, { emit, slots }) {
205
210
  const options = vue.reactive([]);
206
211
  function toArray(value) {
207
212
  if (!core.isDefined(value)) {
@@ -289,16 +294,25 @@ const useSelectionList = shared.defineHookComponent({
289
294
  isActive,
290
295
  init
291
296
  }));
292
- function renderItem() {
297
+ const renderItem = () => {
293
298
  const children = options.filter((e) => actives.includes(e.value)).map((e) => e.render());
294
299
  return props.multiple ? children : children[0];
295
- }
300
+ };
301
+ const slotData = {
302
+ isActive,
303
+ changeActive,
304
+ renderItem
305
+ };
306
+ const render = () => {
307
+ return vue.renderSlot(slots, "default", slotData);
308
+ };
296
309
  return {
297
310
  options,
298
311
  actives,
299
312
  isActive,
300
313
  changeActive,
301
- renderItem
314
+ renderItem,
315
+ render
302
316
  };
303
317
  }
304
318
  });
@@ -546,6 +560,7 @@ exports.selectionProps = selectionProps;
546
560
  exports.switchEmits = switchEmits;
547
561
  exports.switchProps = switchProps;
548
562
  exports.useAffix = useAffix;
563
+ exports.useAffixTargetProvider = useAffixTargetProvider;
549
564
  exports.useIcon = useIcon;
550
565
  exports.useSelectionContext = useSelectionContext;
551
566
  exports.useSelectionItem = useSelectionItem;
package/dist/index.d.cts CHANGED
@@ -120,6 +120,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
120
120
  zIndex: number;
121
121
  }>;
122
122
  declare function provideAffixTarget(target: MaybeRefOrGetter<Element | null | undefined>): void;
123
+ declare function useAffixTargetProvider<E extends Element = Element>(): Ref<vue.UnwrapRef<E> | null>;
123
124
 
124
125
  type InitFunction = (option: Option) => () => void;
125
126
  interface Option {
@@ -205,6 +206,9 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
205
206
  isActive: (value: any) => boolean;
206
207
  changeActive: (value: any) => void;
207
208
  renderItem: () => ElementLike;
209
+ render: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
210
+ [key: string]: any;
211
+ }>;
208
212
  }, ("change" | "load" | "unload" | "update:modelValue")[], {
209
213
  modelValue: {
210
214
  type: PropType<any>;
@@ -583,4 +587,4 @@ declare const useIcon: _hoci_shared.HookComponent<{
583
587
  color: string;
584
588
  }>;
585
589
 
586
- export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type SelectionProps, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
590
+ export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type SelectionProps, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useAffixTargetProvider, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
package/dist/index.d.mts CHANGED
@@ -120,6 +120,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
120
120
  zIndex: number;
121
121
  }>;
122
122
  declare function provideAffixTarget(target: MaybeRefOrGetter<Element | null | undefined>): void;
123
+ declare function useAffixTargetProvider<E extends Element = Element>(): Ref<vue.UnwrapRef<E> | null>;
123
124
 
124
125
  type InitFunction = (option: Option) => () => void;
125
126
  interface Option {
@@ -205,6 +206,9 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
205
206
  isActive: (value: any) => boolean;
206
207
  changeActive: (value: any) => void;
207
208
  renderItem: () => ElementLike;
209
+ render: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
210
+ [key: string]: any;
211
+ }>;
208
212
  }, ("change" | "load" | "unload" | "update:modelValue")[], {
209
213
  modelValue: {
210
214
  type: PropType<any>;
@@ -583,4 +587,4 @@ declare const useIcon: _hoci_shared.HookComponent<{
583
587
  color: string;
584
588
  }>;
585
589
 
586
- export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type SelectionProps, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
590
+ export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type SelectionProps, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useAffixTargetProvider, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
package/dist/index.d.ts CHANGED
@@ -120,6 +120,7 @@ declare const useAffix: _hoci_shared.HookComponent<{
120
120
  zIndex: number;
121
121
  }>;
122
122
  declare function provideAffixTarget(target: MaybeRefOrGetter<Element | null | undefined>): void;
123
+ declare function useAffixTargetProvider<E extends Element = Element>(): Ref<vue.UnwrapRef<E> | null>;
123
124
 
124
125
  type InitFunction = (option: Option) => () => void;
125
126
  interface Option {
@@ -205,6 +206,9 @@ declare const useSelectionList: _hoci_shared.HookComponent<{
205
206
  isActive: (value: any) => boolean;
206
207
  changeActive: (value: any) => void;
207
208
  renderItem: () => ElementLike;
209
+ render: () => vue.VNode<vue.RendererNode, vue.RendererElement, {
210
+ [key: string]: any;
211
+ }>;
208
212
  }, ("change" | "load" | "unload" | "update:modelValue")[], {
209
213
  modelValue: {
210
214
  type: PropType<any>;
@@ -583,4 +587,4 @@ declare const useIcon: _hoci_shared.HookComponent<{
583
587
  color: string;
584
588
  }>;
585
589
 
586
- export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type SelectionProps, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
590
+ export { AFFIX_TARGET_KEY, type AffixProps, type HiIconProps, type HiItemSlotsData, type HiSelectionContext, type HiSelectionSlotData, type HiSwitchProps, type InitFunction, type Option, type SelectionProps, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useAffixTargetProvider, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { ref, inject, computed, watchPostEffect, provide, reactive, watch, renderSlot } from 'vue';
1
+ import { ref, inject, computed, watchPostEffect, provide, reactive, renderSlot, watch } from 'vue';
2
2
  import { useElementVisibility, useEventListener, syncRef, toReactive, isDefined, tryOnScopeDispose, useVModel } from '@vueuse/core';
3
3
  import { defineHookProps, defineHookEmits, defineHookComponent, useElement, throttleByRaf, isWindow, valuePropType, classPropType, labelPropType, useSharedConfig } from '@hoci/shared';
4
4
  export * from '@hoci/shared';
@@ -51,7 +51,7 @@ const useAffix = defineHookComponent({
51
51
  props: affixProps,
52
52
  setup(props, { emit }) {
53
53
  const wrapperRef = ref(null);
54
- const parentRef = inject(AFFIX_TARGET_KEY, void 0);
54
+ const parentRef = inject(AFFIX_TARGET_KEY, null);
55
55
  const targetRef = useElement(props.target, parentRef);
56
56
  const isFixed = ref(false);
57
57
  const placeholderStyle = ref({});
@@ -123,6 +123,11 @@ const useAffix = defineHookComponent({
123
123
  function provideAffixTarget(target) {
124
124
  provide(AFFIX_TARGET_KEY, target);
125
125
  }
126
+ function useAffixTargetProvider() {
127
+ const targetRef = ref(null);
128
+ provideAffixTarget(targetRef);
129
+ return targetRef;
130
+ }
126
131
 
127
132
  const selectionProps = defineHookProps({
128
133
  modelValue: {
@@ -200,7 +205,7 @@ function useSelectionContext() {
200
205
  const useSelectionList = defineHookComponent({
201
206
  props: selectionProps,
202
207
  emits: selectionEmits,
203
- setup(props, { emit }) {
208
+ setup(props, { emit, slots }) {
204
209
  const options = reactive([]);
205
210
  function toArray(value) {
206
211
  if (!isDefined(value)) {
@@ -288,16 +293,25 @@ const useSelectionList = defineHookComponent({
288
293
  isActive,
289
294
  init
290
295
  }));
291
- function renderItem() {
296
+ const renderItem = () => {
292
297
  const children = options.filter((e) => actives.includes(e.value)).map((e) => e.render());
293
298
  return props.multiple ? children : children[0];
294
- }
299
+ };
300
+ const slotData = {
301
+ isActive,
302
+ changeActive,
303
+ renderItem
304
+ };
305
+ const render = () => {
306
+ return renderSlot(slots, "default", slotData);
307
+ };
295
308
  return {
296
309
  options,
297
310
  actives,
298
311
  isActive,
299
312
  changeActive,
300
- renderItem
313
+ renderItem,
314
+ render
301
315
  };
302
316
  }
303
317
  });
@@ -534,4 +548,4 @@ const useIcon = defineHookComponent({
534
548
  }
535
549
  });
536
550
 
537
- export { AFFIX_TARGET_KEY, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
551
+ export { AFFIX_TARGET_KEY, affixEmits, affixProps, iconProps, itemProps, provideAffixTarget, selectionEmits, selectionProps, switchEmits, switchProps, useAffix, useAffixTargetProvider, useIcon, useSelectionContext, useSelectionItem, useSelectionList, useSwitch };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hoci/core",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "",
5
5
  "author": "chizuki",
6
6
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  "@vueuse/core": "^10.5.0",
27
27
  "maybe-types": "^0.1.0",
28
28
  "tslx": "^0.1.1",
29
- "@hoci/shared": "0.4.2"
29
+ "@hoci/shared": "0.4.3"
30
30
  },
31
31
  "scripts": {
32
32
  "build": "unbuild",