@can2421/ui-components 1.0.6 → 1.0.8

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.es.js CHANGED
@@ -1,43 +1,40 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".c-button{display:inline-block;padding:.5em 1em;outline:unset;border:unset;border-radius:4px;background:#fff;cursor:pointer}.c-button:active{box-shadow:inset 0 0 0 1px #eaeaea}.c-button--primary{background:#409eff;color:#fff}.c-button--disabled{cursor:not-allowed;opacity:.5}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- import { defineComponent as l, createElementBlock as c, openBlock as s, normalizeClass as a, renderSlot as i } from "vue";
3
- const u = (t) => (t.install = (n) => {
4
- const e = t.name || "UnknownComponent";
5
- n.component(e, t);
6
- }, t), o = {
1
+ import { defineComponent, createElementBlock, openBlock, normalizeClass, renderSlot } from "vue";
2
+ const withInstall = (component) => {
3
+ component.install = (app) => {
4
+ const name = component.name || "UnknownComponent";
5
+ app.component(name, component);
6
+ };
7
+ return component;
8
+ };
9
+ const buttonProps = {
7
10
  type: {
8
11
  type: String,
9
12
  default: "primary"
10
13
  },
11
14
  size: String
12
- }, p = /* @__PURE__ */ l({
13
- name: "CButton",
15
+ };
16
+ const _sfc_main = /* @__PURE__ */ defineComponent({
17
+ ...{ name: "CButton" },
14
18
  __name: "button",
15
- props: o,
16
- setup(t) {
17
- const n = t;
18
- function e() {
19
- alert("click");
19
+ props: buttonProps,
20
+ setup(__props) {
21
+ const props = __props;
22
+ function handleClick() {
23
+ console.log("click");
20
24
  }
21
- return (r, b) => (s(), c("button", {
22
- class: a(["c-button", [`c-button--${n.type}`]]),
23
- onClick: e
24
- }, [
25
- i(r.$slots, "default")
26
- ], 2));
25
+ return (_ctx, _cache) => {
26
+ return openBlock(), createElementBlock("button", {
27
+ class: normalizeClass(["c-button", [`c-button--${props.type}`]]),
28
+ onClick: handleClick
29
+ }, [
30
+ renderSlot(_ctx.$slots, "default")
31
+ ], 2);
32
+ };
27
33
  }
28
- }), m = u(p), f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
29
- __proto__: null,
30
- CButton: m,
31
- buttonProps: o
32
- }, Symbol.toStringTag, { value: "Module" })), _ = {
33
- install(t) {
34
- Object.entries(f).forEach(([n, e]) => {
35
- t.component(n, e);
36
- });
37
- }
38
- };
34
+ });
35
+ const CButton = withInstall(_sfc_main);
39
36
  export {
40
- m as CButton,
41
- o as buttonProps,
42
- _ as default
37
+ CButton,
38
+ buttonProps
43
39
  };
40
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":["../../utils/install.ts","../src/button/button.types.ts","../src/button/button.vue","../src/button/index.ts"],"sourcesContent":["import type { App, Plugin } from 'vue'\r\n\r\n// 这里的 T 必须继承自基础组件类型\r\nexport type SFCWithInstall<T> = T & Plugin\r\n\r\nexport const withInstall = <T>(component: T) => {\r\n (component as SFCWithInstall<T>).install = (app: App) => {\r\n const name = (component as any).name || 'UnknownComponent'\r\n app.component(name, component as SFCWithInstall<T>)\r\n }\r\n return component as SFCWithInstall<T>\r\n}","import type { ExtractPropTypes, PropType } from 'vue'\r\n\r\nexport type ButtonType = 'primary' | 'success' | 'warning' | 'danger' | 'info'\r\n\r\nexport const buttonProps = {\r\n type: {\r\n type: String as PropType<ButtonType>,\r\n default: 'primary',\r\n },\r\n size: String,\r\n} as const\r\n\r\nexport type ButtonProps = ExtractPropTypes<typeof buttonProps>\r\n","<template>\r\n <button class=\"c-button\" :class=\"[`c-button--${props.type}`]\" @click=\"handleClick\">\r\n <slot />\r\n </button>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { buttonProps } from './button.types'\r\nimport './style/button.scss'\r\n\r\ndefineOptions({ name: 'CButton' })\r\n\r\nconst props = defineProps(buttonProps)\r\n\r\nfunction handleClick() {\r\n // eslint-disable-next-line no-console\r\n console.log('click')\r\n}\r\n</script>\r\n","import { withInstall } from '../../../utils/install'\r\nimport Button from './button.vue'\r\n\r\nconst CButton = withInstall(Button)\r\n\r\nexport * from './button.types'\r\n\r\nexport {\r\n CButton,\r\n}\r\n"],"names":["_createElementBlock","_normalizeClass","_renderSlot","Button"],"mappings":";AAKO,MAAM,cAAc,CAAI,cAAiB;AAC7C,YAAgC,UAAU,CAAC,QAAa;AACvD,UAAM,OAAQ,UAAkB,QAAQ;AACxC,QAAI,UAAU,MAAM,SAA8B;AAAA,EACpD;AACA,SAAO;AACT;ACPO,MAAM,cAAc;AAAA,EACzB,MAAM;AAAA,IACJ,MAAM;AAAA,IACN,SAAS;AAAA,EAAA;AAAA,EAEX,MAAM;AACR;;;;;;ACEA,UAAM,QAAQ;AAEd,aAAS,cAAc;AAErB,cAAQ,IAAI,OAAO;AAAA,IACrB;;0BAhBEA,mBAES,UAAA;AAAA,QAFD,OAAKC,eAAA,CAAC,YAAU,CAAA,aAAuB,MAAM,IAAI,EAAA,CAAA,CAAA;AAAA,QAAM,SAAO;AAAA,MAAA;QACpEC,WAAQ,KAAA,QAAA,SAAA;AAAA,MAAA;;;;ACCZ,MAAM,UAAU,YAAYC,SAAM;"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,43 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode(".c-button{display:inline-block;padding:.5em 1em;outline:unset;border:unset;border-radius:4px;background:#fff;cursor:pointer}.c-button:active{box-shadow:inset 0 0 0 1px #eaeaea}.c-button--primary{background:#409eff;color:#fff}.c-button--disabled{cursor:not-allowed;opacity:.5}")),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();
2
- (function(e,t){typeof exports=="object"&&typeof module<"u"?t(exports,require("vue")):typeof define=="function"&&define.amd?define(["exports","vue"],t):(e=typeof globalThis<"u"?globalThis:e||self,t(e.CanUI={},e.Vue))})(this,(function(e,t){"use strict";const u=n=>(n.install=o=>{const i=n.name||"UnknownComponent";o.component(i,n)},n),s={type:{type:String,default:"primary"},size:String},l=u(t.defineComponent({name:"CButton",__name:"button",props:s,setup(n){const o=n;function i(){alert("click")}return(a,d)=>(t.openBlock(),t.createElementBlock("button",{class:t.normalizeClass(["c-button",[`c-button--${o.type}`]]),onClick:i},[t.renderSlot(a.$slots,"default")],2))}})),c=Object.freeze(Object.defineProperty({__proto__:null,CButton:l,buttonProps:s},Symbol.toStringTag,{value:"Module"})),r={install(n){Object.entries(c).forEach(([o,i])=>{n.component(o,i)})}};e.CButton=l,e.buttonProps=s,e.default=r,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
1
+ (function(global, factory) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("vue")) : typeof define === "function" && define.amd ? define(["exports", "vue"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.CanUI = {}, global.Vue));
3
+ })(this, (function(exports2, vue) {
4
+ "use strict";
5
+ const withInstall = (component) => {
6
+ component.install = (app) => {
7
+ const name = component.name || "UnknownComponent";
8
+ app.component(name, component);
9
+ };
10
+ return component;
11
+ };
12
+ const buttonProps = {
13
+ type: {
14
+ type: String,
15
+ default: "primary"
16
+ },
17
+ size: String
18
+ };
19
+ const _sfc_main = /* @__PURE__ */ vue.defineComponent({
20
+ ...{ name: "CButton" },
21
+ __name: "button",
22
+ props: buttonProps,
23
+ setup(__props) {
24
+ const props = __props;
25
+ function handleClick() {
26
+ console.log("click");
27
+ }
28
+ return (_ctx, _cache) => {
29
+ return vue.openBlock(), vue.createElementBlock("button", {
30
+ class: vue.normalizeClass(["c-button", [`c-button--${props.type}`]]),
31
+ onClick: handleClick
32
+ }, [
33
+ vue.renderSlot(_ctx.$slots, "default")
34
+ ], 2);
35
+ };
36
+ }
37
+ });
38
+ const CButton = withInstall(_sfc_main);
39
+ exports2.CButton = CButton;
40
+ exports2.buttonProps = buttonProps;
41
+ Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
42
+ }));
43
+ //# sourceMappingURL=index.umd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.umd.js","sources":["../../utils/install.ts","../src/button/button.types.ts","../src/button/button.vue","../src/button/index.ts"],"sourcesContent":["import type { App, Plugin } from 'vue'\r\n\r\n// 这里的 T 必须继承自基础组件类型\r\nexport type SFCWithInstall<T> = T & Plugin\r\n\r\nexport const withInstall = <T>(component: T) => {\r\n (component as SFCWithInstall<T>).install = (app: App) => {\r\n const name = (component as any).name || 'UnknownComponent'\r\n app.component(name, component as SFCWithInstall<T>)\r\n }\r\n return component as SFCWithInstall<T>\r\n}","import type { ExtractPropTypes, PropType } from 'vue'\r\n\r\nexport type ButtonType = 'primary' | 'success' | 'warning' | 'danger' | 'info'\r\n\r\nexport const buttonProps = {\r\n type: {\r\n type: String as PropType<ButtonType>,\r\n default: 'primary',\r\n },\r\n size: String,\r\n} as const\r\n\r\nexport type ButtonProps = ExtractPropTypes<typeof buttonProps>\r\n","<template>\r\n <button class=\"c-button\" :class=\"[`c-button--${props.type}`]\" @click=\"handleClick\">\r\n <slot />\r\n </button>\r\n</template>\r\n\r\n<script lang=\"ts\" setup>\r\nimport { buttonProps } from './button.types'\r\nimport './style/button.scss'\r\n\r\ndefineOptions({ name: 'CButton' })\r\n\r\nconst props = defineProps(buttonProps)\r\n\r\nfunction handleClick() {\r\n // eslint-disable-next-line no-console\r\n console.log('click')\r\n}\r\n</script>\r\n","import { withInstall } from '../../../utils/install'\r\nimport Button from './button.vue'\r\n\r\nconst CButton = withInstall(Button)\r\n\r\nexport * from './button.types'\r\n\r\nexport {\r\n CButton,\r\n}\r\n"],"names":["_createElementBlock","_normalizeClass","_renderSlot","Button"],"mappings":";;;;AAKO,QAAM,cAAc,CAAI,cAAiB;AAC7C,cAAgC,UAAU,CAAC,QAAa;AACvD,YAAM,OAAQ,UAAkB,QAAQ;AACxC,UAAI,UAAU,MAAM,SAA8B;AAAA,IACpD;AACA,WAAO;AAAA,EACT;ACPO,QAAM,cAAc;AAAA,IACzB,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,IAAA;AAAA,IAEX,MAAM;AAAA,EACR;;;;;;ACEA,YAAM,QAAQ;AAEd,eAAS,cAAc;AAErB,gBAAQ,IAAI,OAAO;AAAA,MACrB;;gCAhBEA,IAAAA,mBAES,UAAA;AAAA,UAFD,OAAKC,IAAAA,eAAA,CAAC,YAAU,CAAA,aAAuB,MAAM,IAAI,EAAA,CAAA,CAAA;AAAA,UAAM,SAAO;AAAA,QAAA;UACpEC,eAAQ,KAAA,QAAA,SAAA;AAAA,QAAA;;;;ACCZ,QAAM,UAAU,YAAYC,SAAM;;;;;"}
@@ -0,0 +1,20 @@
1
+ .c-button {
2
+ display: inline-block;
3
+ padding: 0.5em 1em;
4
+ outline: unset;
5
+ border: unset;
6
+ border-radius: 4px;
7
+ background: #fff;
8
+ cursor: pointer;
9
+ }
10
+ .c-button:active {
11
+ box-shadow: inset 0 0 0 1px #eaeaea;
12
+ }
13
+ .c-button--primary {
14
+ background: #409eff;
15
+ color: #fff;
16
+ }
17
+ .c-button--disabled {
18
+ cursor: not-allowed;
19
+ opacity: 0.5;
20
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@can2421/ui-components",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "main": "dist/index.umd.js",
5
5
  "module": "dist/index.es.js",
6
6
  "types": "dist/index.es.d.ts",
@@ -1,6 +0,0 @@
1
- export * from './packages/components/index'
2
- export {}
3
- import CanUI from './packages/components/index'
4
- export default CanUI
5
- export * from './packages/components/index'
6
- export {}
@@ -1,6 +0,0 @@
1
- import { App } from 'vue';
2
- export * from './src/index';
3
- declare const _default: {
4
- install(app: App): void;
5
- };
6
- export default _default;
@@ -1,31 +0,0 @@
1
- declare function __VLS_template(): {
2
- attrs: Partial<{}>;
3
- slots: {
4
- default?(_: {}): any;
5
- };
6
- refs: {};
7
- rootEl: HTMLButtonElement;
8
- };
9
- type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
10
- declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
11
- readonly type: {
12
- readonly type: import('vue').PropType<import('./button.types').ButtonType>;
13
- readonly default: "primary";
14
- };
15
- readonly size: StringConstructor;
16
- }>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
17
- readonly type: {
18
- readonly type: import('vue').PropType<import('./button.types').ButtonType>;
19
- readonly default: "primary";
20
- };
21
- readonly size: StringConstructor;
22
- }>> & Readonly<{}>, {
23
- readonly type: import('./button.types').ButtonType;
24
- }, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLButtonElement>;
25
- declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
26
- export default _default;
27
- type __VLS_WithTemplateSlots<T, S> = T & {
28
- new (): {
29
- $slots: S;
30
- };
31
- };
@@ -1,10 +0,0 @@
1
- import { ExtractPropTypes, PropType } from 'vue';
2
- export type ButtonType = 'primary' | 'success' | 'warning' | 'danger' | 'info';
3
- export declare const buttonProps: {
4
- readonly type: {
5
- readonly type: PropType<ButtonType>;
6
- readonly default: "primary";
7
- };
8
- readonly size: StringConstructor;
9
- };
10
- export type ButtonProps = ExtractPropTypes<typeof buttonProps>;
@@ -1,43 +0,0 @@
1
- declare const CButton: import('../../../utils/install').SFCWithInstall<{
2
- new (...args: any[]): import('vue').CreateComponentPublicInstanceWithMixins<Readonly<import('vue').ExtractPropTypes<{
3
- readonly type: {
4
- readonly type: import('vue').PropType<import('./button.types').ButtonType>;
5
- readonly default: "primary";
6
- };
7
- readonly size: StringConstructor;
8
- }>> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, import('vue').PublicProps, {
9
- readonly type: import('./button.types').ButtonType;
10
- }, true, {}, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, {}, HTMLButtonElement, import('vue').ComponentProvideOptions, {
11
- P: {};
12
- B: {};
13
- D: {};
14
- C: {};
15
- M: {};
16
- Defaults: {};
17
- }, Readonly<import('vue').ExtractPropTypes<{
18
- readonly type: {
19
- readonly type: import('vue').PropType<import('./button.types').ButtonType>;
20
- readonly default: "primary";
21
- };
22
- readonly size: StringConstructor;
23
- }>> & Readonly<{}>, {}, {}, {}, {}, {
24
- readonly type: import('./button.types').ButtonType;
25
- }>;
26
- __isFragment?: never;
27
- __isTeleport?: never;
28
- __isSuspense?: never;
29
- } & import('vue').ComponentOptionsBase<Readonly<import('vue').ExtractPropTypes<{
30
- readonly type: {
31
- readonly type: import('vue').PropType<import('./button.types').ButtonType>;
32
- readonly default: "primary";
33
- };
34
- readonly size: StringConstructor;
35
- }>> & Readonly<{}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, {
36
- readonly type: import('./button.types').ButtonType;
37
- }, {}, string, {}, import('vue').GlobalComponents, import('vue').GlobalDirectives, string, import('vue').ComponentProvideOptions> & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & (new () => {
38
- $slots: {
39
- default?(_: {}): any;
40
- };
41
- })>;
42
- export * from './button.types';
43
- export { CButton, };
@@ -1 +0,0 @@
1
- export * from './button';
@@ -1,2 +0,0 @@
1
- declare const _default: import('vite').UserConfig;
2
- export default _default;
@@ -1,3 +0,0 @@
1
- import { Plugin } from 'vue';
2
- export type SFCWithInstall<T> = T & Plugin;
3
- export declare const withInstall: <T>(component: T) => SFCWithInstall<T>;
@@ -1,2 +0,0 @@
1
- declare const _default: import('vue').DefineComponent<{}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, HTMLButtonElement>;
2
- export default _default;
@@ -1 +0,0 @@
1
- export {};
@@ -1,2 +0,0 @@
1
- declare const _default: import('vite').UserConfig;
2
- export default _default;