hoci 0.0.3 → 0.0.4

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
@@ -56,7 +56,8 @@ const useSelectionItem = defineHookComponent({
56
56
  const parentLabel = core.resolveRef(vue.inject(ItemLabelSymbol));
57
57
  function render() {
58
58
  return vue.renderSlot(slots, "default", {}, () => {
59
- let label = props.label ?? parentLabel.value;
59
+ var _a;
60
+ let label = (_a = props.label) != null ? _a : parentLabel.value;
60
61
  if (label) {
61
62
  if (typeof label == "function") {
62
63
  label = label(props.value);
@@ -86,14 +87,22 @@ const useSelectionItem = defineHookComponent({
86
87
  }
87
88
  const isActive = vue.inject(IsActiveSymbol, () => false);
88
89
  const changeActive = vue.inject(ChangeActiveSymbol, () => false);
89
- const activeClass = vue.computed(() => vue.inject(ActiveClassSymbol)?.value ?? "active");
90
- const unactiveClass = vue.computed(() => vue.inject(UnactiveSymbol)?.value ?? "unactive");
90
+ const activeClass = vue.computed(() => {
91
+ var _a, _b;
92
+ return (_b = (_a = vue.inject(ActiveClassSymbol)) == null ? void 0 : _a.value) != null ? _b : "active";
93
+ });
94
+ const unactiveClass = vue.computed(() => {
95
+ var _a, _b;
96
+ return (_b = (_a = vue.inject(UnactiveSymbol)) == null ? void 0 : _a.value) != null ? _b : "unactive";
97
+ });
91
98
  const itemClass = vue.computed(() => {
92
- return [vue.inject(ItemClassSymbol)?.value ?? ""].concat(isActive(props.value) ? activeClass.value : unactiveClass.value);
99
+ var _a, _b;
100
+ return [(_b = (_a = vue.inject(ItemClassSymbol)) == null ? void 0 : _a.value) != null ? _b : ""].concat(isActive(props.value) ? activeClass.value : unactiveClass.value);
93
101
  });
94
102
  const activateEvent = core.resolveRef(() => {
103
+ var _a, _b;
95
104
  const event = vue.inject(ActivateEventSymbol);
96
- return props.activateEvent ?? event?.value ?? "click";
105
+ return (_b = (_a = props.activateEvent) != null ? _a : event == null ? void 0 : event.value) != null ? _b : "click";
97
106
  });
98
107
  return {
99
108
  activate() {
@@ -163,6 +172,7 @@ const useSelectionList = defineHookComponent({
163
172
  props: selectionListProps,
164
173
  emits: selectionListEmits,
165
174
  setup(props, { slots, emit }) {
175
+ var _a;
166
176
  const options = vue.reactive([]);
167
177
  function toArray(value) {
168
178
  if (value === void 0) {
@@ -173,7 +183,7 @@ const useSelectionList = defineHookComponent({
173
183
  }
174
184
  return [value];
175
185
  }
176
- const actives = vue.reactive([...toArray(props.modelValue ?? props.defaultValue)]);
186
+ const actives = vue.reactive([...toArray((_a = props.modelValue) != null ? _a : props.defaultValue)]);
177
187
  const currentValue = vue.computed({
178
188
  get() {
179
189
  return props.multiple ? actives : actives[0];
@@ -188,7 +198,8 @@ const useSelectionList = defineHookComponent({
188
198
  });
189
199
  const modelValue = vue.computed({
190
200
  get() {
191
- return props.modelValue ?? props.defaultValue;
201
+ var _a2;
202
+ return (_a2 = props.modelValue) != null ? _a2 : props.defaultValue;
192
203
  },
193
204
  set(val) {
194
205
  emit("update:modelValue", val);
@@ -316,7 +327,8 @@ const useSwitch = defineHookComponent({
316
327
  );
317
328
  const modelValue = vue.computed({
318
329
  get() {
319
- return !!(props.modelValue ?? checked.value);
330
+ var _a;
331
+ return !!((_a = props.modelValue) != null ? _a : checked.value);
320
332
  },
321
333
  set(val) {
322
334
  checked.value = val;
@@ -366,6 +378,7 @@ exports.defineHookProps = defineHookProps;
366
378
  exports.selectionItemProps = selectionItemProps;
367
379
  exports.selectionListEmits = selectionListEmits;
368
380
  exports.selectionListProps = selectionListProps;
381
+ exports.switchEmits = switchEmits;
369
382
  exports.switchProps = switchProps;
370
383
  exports.useSelectionItem = useSelectionItem;
371
384
  exports.useSelectionList = useSelectionList;
package/dist/index.d.ts CHANGED
@@ -430,6 +430,7 @@ declare const switchProps: {
430
430
  default: string;
431
431
  };
432
432
  };
433
+ declare const switchEmits: ("update:modelValue" | "change")[];
433
434
  declare const useSwitch: HookComponent<{
434
435
  toggle: (value?: any) => void;
435
436
  modelValue: vue.WritableComputedRef<boolean>;
@@ -549,4 +550,4 @@ declare const HiSwitch: vue.DefineComponent<{
549
550
  unactiveClass: string | string[];
550
551
  }>;
551
552
 
552
- export { HiItem, HiSelection, HiSwitch, HookComponent, HookComponentOptions, defineHookComponent, defineHookEmits, defineHookProps, selectionItemProps, selectionListEmits, selectionListProps, switchProps, useSelectionItem, useSelectionList, useSwitch };
553
+ export { HiItem, HiSelection, HiSwitch, HookComponent, HookComponentOptions, defineHookComponent, defineHookEmits, defineHookProps, selectionItemProps, selectionListEmits, selectionListProps, switchEmits, switchProps, useSelectionItem, useSelectionList, useSwitch };
@@ -54,7 +54,8 @@ const useSelectionItem = defineHookComponent({
54
54
  const parentLabel = resolveRef(inject(ItemLabelSymbol));
55
55
  function render() {
56
56
  return renderSlot(slots, "default", {}, () => {
57
- let label = props.label ?? parentLabel.value;
57
+ var _a;
58
+ let label = (_a = props.label) != null ? _a : parentLabel.value;
58
59
  if (label) {
59
60
  if (typeof label == "function") {
60
61
  label = label(props.value);
@@ -84,14 +85,22 @@ const useSelectionItem = defineHookComponent({
84
85
  }
85
86
  const isActive = inject(IsActiveSymbol, () => false);
86
87
  const changeActive = inject(ChangeActiveSymbol, () => false);
87
- const activeClass = computed(() => inject(ActiveClassSymbol)?.value ?? "active");
88
- const unactiveClass = computed(() => inject(UnactiveSymbol)?.value ?? "unactive");
88
+ const activeClass = computed(() => {
89
+ var _a, _b;
90
+ return (_b = (_a = inject(ActiveClassSymbol)) == null ? void 0 : _a.value) != null ? _b : "active";
91
+ });
92
+ const unactiveClass = computed(() => {
93
+ var _a, _b;
94
+ return (_b = (_a = inject(UnactiveSymbol)) == null ? void 0 : _a.value) != null ? _b : "unactive";
95
+ });
89
96
  const itemClass = computed(() => {
90
- return [inject(ItemClassSymbol)?.value ?? ""].concat(isActive(props.value) ? activeClass.value : unactiveClass.value);
97
+ var _a, _b;
98
+ return [(_b = (_a = inject(ItemClassSymbol)) == null ? void 0 : _a.value) != null ? _b : ""].concat(isActive(props.value) ? activeClass.value : unactiveClass.value);
91
99
  });
92
100
  const activateEvent = resolveRef(() => {
101
+ var _a, _b;
93
102
  const event = inject(ActivateEventSymbol);
94
- return props.activateEvent ?? event?.value ?? "click";
103
+ return (_b = (_a = props.activateEvent) != null ? _a : event == null ? void 0 : event.value) != null ? _b : "click";
95
104
  });
96
105
  return {
97
106
  activate() {
@@ -161,6 +170,7 @@ const useSelectionList = defineHookComponent({
161
170
  props: selectionListProps,
162
171
  emits: selectionListEmits,
163
172
  setup(props, { slots, emit }) {
173
+ var _a;
164
174
  const options = reactive([]);
165
175
  function toArray(value) {
166
176
  if (value === void 0) {
@@ -171,7 +181,7 @@ const useSelectionList = defineHookComponent({
171
181
  }
172
182
  return [value];
173
183
  }
174
- const actives = reactive([...toArray(props.modelValue ?? props.defaultValue)]);
184
+ const actives = reactive([...toArray((_a = props.modelValue) != null ? _a : props.defaultValue)]);
175
185
  const currentValue = computed({
176
186
  get() {
177
187
  return props.multiple ? actives : actives[0];
@@ -186,7 +196,8 @@ const useSelectionList = defineHookComponent({
186
196
  });
187
197
  const modelValue = computed({
188
198
  get() {
189
- return props.modelValue ?? props.defaultValue;
199
+ var _a2;
200
+ return (_a2 = props.modelValue) != null ? _a2 : props.defaultValue;
190
201
  },
191
202
  set(val) {
192
203
  emit("update:modelValue", val);
@@ -314,7 +325,8 @@ const useSwitch = defineHookComponent({
314
325
  );
315
326
  const modelValue = computed({
316
327
  get() {
317
- return !!(props.modelValue ?? checked.value);
328
+ var _a;
329
+ return !!((_a = props.modelValue) != null ? _a : checked.value);
318
330
  },
319
331
  set(val) {
320
332
  checked.value = val;
@@ -355,4 +367,4 @@ const HiSwitch = defineComponent({
355
367
  }
356
368
  });
357
369
 
358
- export { HiItem, HiSelection, HiSwitch, defineHookComponent, defineHookEmits, defineHookProps, selectionItemProps, selectionListEmits, selectionListProps, switchProps, useSelectionItem, useSelectionList, useSwitch };
370
+ export { HiItem, HiSelection, HiSwitch, defineHookComponent, defineHookEmits, defineHookProps, selectionItemProps, selectionListEmits, selectionListProps, switchEmits, switchProps, useSelectionItem, useSelectionList, useSwitch };
package/package.json CHANGED
@@ -1,21 +1,28 @@
1
1
  {
2
2
  "name": "hoci",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
- "module": "dist/index.mjs",
6
+ "module": "dist/index.esm.js",
7
7
  "types": "dist/index.d.ts",
8
8
  "files": [
9
9
  "dist/"
10
10
  ],
11
+ "exports": {
12
+ ".": {
13
+ "import": "./dist/index.esm.js",
14
+ "require": "./dist/index.cjs"
15
+ },
16
+ "./package.json": "./package.json"
17
+ },
11
18
  "author": "chizuki",
12
19
  "license": "MIT",
13
20
  "dependencies": {
14
- "@vueuse/core": "^9.5.0",
21
+ "@vueuse/core": "^9.1.0",
15
22
  "maybe-types": "^0.0.3"
16
23
  },
17
- "peerDependencies": {
18
- "vue": "^3.2.45"
24
+ "devDependencies": {
25
+ "vue": "^3.2.31"
19
26
  },
20
27
  "scripts": {
21
28
  "build": "unbuild",