hoci 0.0.8 → 0.0.9

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
@@ -3,25 +3,6 @@
3
3
  const core = require('@vueuse/core');
4
4
  const vue = require('vue');
5
5
 
6
- var __defProp = Object.defineProperty;
7
- var __defProps = Object.defineProperties;
8
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
9
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
10
- var __hasOwnProp = Object.prototype.hasOwnProperty;
11
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
12
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
13
- var __spreadValues = (a, b) => {
14
- for (var prop in b || (b = {}))
15
- if (__hasOwnProp.call(b, prop))
16
- __defNormalProp(a, prop, b[prop]);
17
- if (__getOwnPropSymbols)
18
- for (var prop of __getOwnPropSymbols(b)) {
19
- if (__propIsEnum.call(b, prop))
20
- __defNormalProp(a, prop, b[prop]);
21
- }
22
- return a;
23
- };
24
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
6
  function defineHookProps(props) {
26
7
  return props;
27
8
  }
@@ -34,44 +15,49 @@ function defineHookComponent(options) {
34
15
  isFunction(props) ? core.reactiveComputed(() => props()) : props,
35
16
  options.props
36
17
  );
37
- const rs = options.setup(p, context);
38
- return __spreadProps(__spreadValues({}, rs), { $props: p });
18
+ return options.setup(p, context);
39
19
  };
40
20
  }
41
21
  function isFunction(value) {
42
22
  return typeof value === "function";
43
23
  }
24
+ function isConstructor(value) {
25
+ return isFunction(value) && value.prototype !== void 0;
26
+ }
44
27
  function withDefaults(props, propsOptions) {
45
28
  if (Array.isArray(propsOptions)) {
46
29
  return props;
47
30
  }
48
- const rs = {};
31
+ const newProps = props;
49
32
  const options = propsOptions;
50
33
  for (const key in options) {
51
34
  const k = key;
52
35
  const opt = options[k];
36
+ if (newProps[k] !== void 0) {
37
+ continue;
38
+ }
53
39
  if (opt === null) {
54
40
  continue;
55
41
  }
56
- if (typeof opt === "function") {
42
+ if (isConstructor(opt)) {
57
43
  if (isExtends(opt, Boolean)) {
58
- rs[key] = false;
44
+ newProps[key] = false;
59
45
  }
60
46
  continue;
61
47
  }
62
48
  if (Array.isArray(opt)) {
63
49
  if (opt.some((e) => isExtends(e, Boolean))) {
64
- rs[key] = false;
50
+ newProps[key] = false;
65
51
  }
66
52
  continue;
67
53
  }
68
54
  if (isFunction(opt.default)) {
69
- rs[key] = opt.default(props);
55
+ newProps[key] = opt.default(props);
70
56
  } else if (opt.default !== void 0) {
71
- rs[key] = opt.default;
57
+ newProps[key] = opt.default;
72
58
  }
73
59
  }
74
- return __spreadValues(__spreadValues({}, rs), props);
60
+ return newProps;
75
61
  }
76
62
  function isExtends(types, value) {
77
63
  if (Array.isArray(types)) {
package/dist/index.d.ts CHANGED
@@ -11,9 +11,7 @@ interface HookComponentOptions<R, E = EmitsOptions, EE extends string = string,
11
11
  emits?: E | EE[];
12
12
  setup: (props: D, context: SetupContext<E>) => R;
13
13
  }
14
- type HookComponent<R, E = EmitsOptions, P = ComponentPropsOptions, D = ExtractPropTypes<P>, Defaults = ExtractDefaultPropTypes<P>> = (props: MaybeFunction<Partial<Defaults> & Omit<D, keyof Defaults>>, context: SetupContext<E>) => R & {
15
- $props: D;
16
- };
14
+ type HookComponent<R, E = EmitsOptions, P = ComponentPropsOptions, D = ExtractPropTypes<P>, Defaults = ExtractDefaultPropTypes<P>> = (props: MaybeFunction<Partial<Defaults> & Omit<D, keyof Defaults>>, context: SetupContext<E>) => R;
17
15
  declare function defineHookProps<P extends ComponentObjectPropsOptions = ComponentObjectPropsOptions>(props: P): P;
18
16
  declare function defineHookEmits<E extends EmitsOptions = EmitsOptions, EE extends string = string>(emits: E | EE[]): E | EE[];
19
17
  declare function defineHookComponent<R, E = EmitsOptions, EE extends string = string, P = ComponentPropsOptions, D = ExtractPropTypes<P>, Defaults = ExtractDefaultPropTypes<P>>(options: HookComponentOptions<R, E, EE, P, D>): HookComponent<R, E, P, D, Defaults>;
package/dist/index.esm.js CHANGED
@@ -1,25 +1,6 @@
1
1
  import { reactiveComputed, resolveRef, syncRef, isDefined, useVModel } from '@vueuse/core';
2
2
  import { defineComponent, h, capitalize, inject, watch, onDeactivated, computed, renderSlot, reactive, provide } from 'vue';
3
3
 
4
- var __defProp = Object.defineProperty;
5
- var __defProps = Object.defineProperties;
6
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
7
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
10
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
11
- var __spreadValues = (a, b) => {
12
- for (var prop in b || (b = {}))
13
- if (__hasOwnProp.call(b, prop))
14
- __defNormalProp(a, prop, b[prop]);
15
- if (__getOwnPropSymbols)
16
- for (var prop of __getOwnPropSymbols(b)) {
17
- if (__propIsEnum.call(b, prop))
18
- __defNormalProp(a, prop, b[prop]);
19
- }
20
- return a;
21
- };
22
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
23
4
  function defineHookProps(props) {
24
5
  return props;
25
6
  }
@@ -32,44 +13,49 @@ function defineHookComponent(options) {
32
13
  isFunction(props) ? reactiveComputed(() => props()) : props,
33
14
  options.props
34
15
  );
35
- const rs = options.setup(p, context);
36
- return __spreadProps(__spreadValues({}, rs), { $props: p });
16
+ return options.setup(p, context);
37
17
  };
38
18
  }
39
19
  function isFunction(value) {
40
20
  return typeof value === "function";
41
21
  }
22
+ function isConstructor(value) {
23
+ return isFunction(value) && value.prototype !== void 0;
24
+ }
42
25
  function withDefaults(props, propsOptions) {
43
26
  if (Array.isArray(propsOptions)) {
44
27
  return props;
45
28
  }
46
- const rs = {};
29
+ const newProps = props;
47
30
  const options = propsOptions;
48
31
  for (const key in options) {
49
32
  const k = key;
50
33
  const opt = options[k];
34
+ if (newProps[k] !== void 0) {
35
+ continue;
36
+ }
51
37
  if (opt === null) {
52
38
  continue;
53
39
  }
54
- if (typeof opt === "function") {
40
+ if (isConstructor(opt)) {
55
41
  if (isExtends(opt, Boolean)) {
56
- rs[key] = false;
42
+ newProps[key] = false;
57
43
  }
58
44
  continue;
59
45
  }
60
46
  if (Array.isArray(opt)) {
61
47
  if (opt.some((e) => isExtends(e, Boolean))) {
62
- rs[key] = false;
48
+ newProps[key] = false;
63
49
  }
64
50
  continue;
65
51
  }
66
52
  if (isFunction(opt.default)) {
67
- rs[key] = opt.default(props);
53
+ newProps[key] = opt.default(props);
68
54
  } else if (opt.default !== void 0) {
69
- rs[key] = opt.default;
55
+ newProps[key] = opt.default;
70
56
  }
71
57
  }
72
- return __spreadValues(__spreadValues({}, rs), props);
58
+ return newProps;
73
59
  }
74
60
  function isExtends(types, value) {
75
61
  if (Array.isArray(types)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hoci",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.esm.js",