@smilekite/lego-bricks 1.0.0

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/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # SMILE LEGO 业务组件库
2
+
3
+ ## 特性
4
+ * **typescript**
5
+ * Vue3
6
+ * 单元测试
7
+ * 提交发布前验证
8
+ * travis 实现自动发布
@@ -0,0 +1,16 @@
1
+
2
+ .l-image-component[data-v-1e970aa2] {
3
+ max-width: 100%;
4
+ }
5
+
6
+ h2.l-text-component[data-v-6bf95b7a], p.l-text-component[data-v-6bf95b7a] {
7
+ margin-bottom: 0;
8
+ }
9
+ button.l-text-component[data-v-6bf95b7a] {
10
+ padding: 5px 10px;
11
+ cursor: pointer;
12
+ }
13
+ .l-text-component[data-v-6bf95b7a] {
14
+ box-sizing: border-box;
15
+ white-space: pre-wrap;
16
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import LImage from './LImage.vue';
2
+ export default LImage;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import LShape from './LShape.vue';
2
+ export default LShape;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import LText from './LText.vue';
2
+ export default LText;
@@ -0,0 +1,53 @@
1
+ export interface CommonComponentProps {
2
+ actionType: string;
3
+ url: string;
4
+ height: string;
5
+ width: string;
6
+ paddingLeft: string;
7
+ paddingRight: string;
8
+ paddingTop: string;
9
+ paddingBottom: string;
10
+ borderStyle: string;
11
+ borderColor: string;
12
+ borderWidth: string;
13
+ borderRadius: string;
14
+ boxShadow: string;
15
+ opacity: string;
16
+ position: string;
17
+ left: string;
18
+ top: string;
19
+ right: string;
20
+ }
21
+ export declare const commonDefaultProps: CommonComponentProps;
22
+ export interface TextComponentProps extends CommonComponentProps {
23
+ text: string;
24
+ fontSize: string;
25
+ fontFamily: string;
26
+ fontWeight: string;
27
+ fontStyle: string;
28
+ textDecoration: string;
29
+ lineHeight: string;
30
+ textAlign: string;
31
+ color: string;
32
+ backgroundColor: string;
33
+ }
34
+ export interface ImageComponentProps extends CommonComponentProps {
35
+ src: string;
36
+ }
37
+ export interface ShapeComponentProps extends CommonComponentProps {
38
+ backgroundColor: string;
39
+ }
40
+ export declare type AllComponentProps = TextComponentProps & ImageComponentProps & ShapeComponentProps;
41
+ export declare const textDefaultProps: TextComponentProps;
42
+ export declare const imageDefaultProps: ImageComponentProps;
43
+ export declare const shapeDefaultProps: ShapeComponentProps;
44
+ export declare const isEditingProp: {
45
+ isEditing: {
46
+ type: BooleanConstructor;
47
+ default: boolean;
48
+ };
49
+ };
50
+ export declare const textStylePropNames: string[];
51
+ export declare const imageStylePropsNames: string[];
52
+ export declare const shapeStylePropsNames: string[];
53
+ export declare const transformToComponentProps: <T extends {}>(props: T) => any;
@@ -0,0 +1,8 @@
1
+ import { CommonComponentProps } from '../defaultProps';
2
+ declare const useComponentCommon: (props: Readonly<Partial<CommonComponentProps & {
3
+ isEditing: boolean;
4
+ }>>, picks: string[]) => {
5
+ styleProps: import("vue").ComputedRef<any>;
6
+ handleClick: () => void;
7
+ };
8
+ export default useComponentCommon;
@@ -0,0 +1,11 @@
1
+ import { App } from 'vue';
2
+ export { textDefaultProps, textStylePropNames, TextComponentProps, imageDefaultProps, imageStylePropsNames, ImageComponentProps, shapeDefaultProps, shapeStylePropsNames, ShapeComponentProps, AllComponentProps } from './defaultProps';
3
+ import LText from './components/LText';
4
+ import LImage from './components/LImage';
5
+ import LShape from './components/LShape';
6
+ declare const install: (app: App) => void;
7
+ export { LText, LImage, LShape, install };
8
+ declare const _default: {
9
+ install: (app: App<any>) => void;
10
+ };
11
+ export default _default;
@@ -0,0 +1,211 @@
1
+ import { without, mapValues, pick } from 'lodash-es';
2
+ import { computed, defineComponent, openBlock, createBlock, resolveDynamicComponent, normalizeStyle, withCtx, createTextVNode, toDisplayString, createElementBlock, withModifiers } from 'vue';
3
+
4
+ const commonDefaultProps = {
5
+ // actions
6
+ actionType: '',
7
+ url: '',
8
+ // size
9
+ height: '',
10
+ width: '373px',
11
+ paddingLeft: '0px',
12
+ paddingRight: '0px',
13
+ paddingTop: '0px',
14
+ paddingBottom: '0px',
15
+ // border type
16
+ borderStyle: 'none',
17
+ borderColor: '#000',
18
+ borderWidth: '0',
19
+ borderRadius: '0',
20
+ // shadow and opacity
21
+ boxShadow: '0 0 0 #000000',
22
+ opacity: '1',
23
+ // position and x,y
24
+ position: 'absolute',
25
+ left: '0',
26
+ top: '0',
27
+ right: '0'
28
+ };
29
+ const textDefaultProps = {
30
+ // basic props - font styles
31
+ text: '正文内容',
32
+ fontSize: '14px',
33
+ fontFamily: '',
34
+ fontWeight: 'normal',
35
+ fontStyle: 'normal',
36
+ textDecoration: 'none',
37
+ lineHeight: '1',
38
+ textAlign: 'left',
39
+ color: '#000000',
40
+ backgroundColor: '',
41
+ ...commonDefaultProps
42
+ };
43
+ const imageDefaultProps = {
44
+ src: 'test.url',
45
+ ...commonDefaultProps
46
+ };
47
+ const shapeDefaultProps = {
48
+ backgroundColor: '',
49
+ ...commonDefaultProps
50
+ };
51
+ const isEditingProp = {
52
+ isEditing: {
53
+ type: Boolean,
54
+ default: false
55
+ }
56
+ };
57
+ const textStylePropNames = without(Object.keys(textDefaultProps), 'actionType', 'url', 'text');
58
+ const imageStylePropsNames = without(Object.keys(imageDefaultProps), 'actionType', 'url', 'src');
59
+ const shapeStylePropsNames = without(Object.keys(shapeDefaultProps), 'actionType', 'url');
60
+ const transformToComponentProps = (props) => {
61
+ const mapProps = mapValues(props, (item) => {
62
+ return {
63
+ type: item.constructor,
64
+ default: item
65
+ };
66
+ });
67
+ return { ...mapProps, ...isEditingProp };
68
+ };
69
+
70
+ const useComponentCommon = (props, picks) => {
71
+ const styleProps = computed(() => pick(props, picks));
72
+ const handleClick = () => {
73
+ if (props.actionType === 'url' && props.url && !props.isEditing) {
74
+ window.location.href = props.url;
75
+ }
76
+ };
77
+ return {
78
+ styleProps,
79
+ handleClick
80
+ };
81
+ };
82
+
83
+ const defaultProps = transformToComponentProps(textDefaultProps);
84
+ // array that contains style props
85
+ var script = defineComponent({
86
+ name: 'l-text',
87
+ props: {
88
+ tag: {
89
+ type: String,
90
+ default: 'div'
91
+ },
92
+ ...defaultProps
93
+ },
94
+ setup(props) {
95
+ // 重用并且简化
96
+ // 抽离并且获得 styleProps
97
+ const { styleProps, handleClick } = useComponentCommon(props, textStylePropNames);
98
+ return {
99
+ styleProps,
100
+ handleClick
101
+ };
102
+ }
103
+ });
104
+
105
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
106
+ return (openBlock(), createBlock(resolveDynamicComponent(_ctx.tag), {
107
+ style: normalizeStyle(_ctx.styleProps),
108
+ class: "l-text-component",
109
+ onClick: _ctx.handleClick
110
+ }, {
111
+ default: withCtx(() => [
112
+ createTextVNode(toDisplayString(_ctx.text), 1 /* TEXT */)
113
+ ]),
114
+ _: 1 /* STABLE */
115
+ }, 8 /* PROPS */, ["style", "onClick"]))
116
+ }
117
+
118
+ script.render = render;
119
+ script.__scopeId = "data-v-6bf95b7a";
120
+ script.__file = "src/components/LText/LText.vue";
121
+
122
+ script.install = (app) => {
123
+ app.component(script.name, script);
124
+ };
125
+
126
+ const defaultProps$1 = transformToComponentProps(imageDefaultProps);
127
+ // array that contains style props
128
+ var script$1 = defineComponent({
129
+ name: 'l-image',
130
+ props: {
131
+ ...defaultProps$1
132
+ },
133
+ setup(props) {
134
+ // 重用并且简化
135
+ // 抽离并且获得 styleProps
136
+ const { styleProps, handleClick } = useComponentCommon(props, imageStylePropsNames);
137
+ return {
138
+ styleProps,
139
+ handleClick
140
+ };
141
+ }
142
+ });
143
+
144
+ const _hoisted_1 = ["src"];
145
+
146
+ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
147
+ return (openBlock(), createElementBlock("img", {
148
+ style: normalizeStyle(_ctx.styleProps),
149
+ class: "l-image-component",
150
+ onClick: _cache[0] || (_cache[0] = withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"])),
151
+ src: _ctx.src
152
+ }, null, 12 /* STYLE, PROPS */, _hoisted_1))
153
+ }
154
+
155
+ script$1.render = render$1;
156
+ script$1.__scopeId = "data-v-1e970aa2";
157
+ script$1.__file = "src/components/LImage/LImage.vue";
158
+
159
+ script$1.install = (app) => {
160
+ app.component(script$1.name, script$1);
161
+ };
162
+
163
+ const defaultProps$2 = transformToComponentProps(shapeDefaultProps);
164
+ // array that contains style props
165
+ var script$2 = defineComponent({
166
+ name: 'l-shape',
167
+ props: {
168
+ ...defaultProps$2
169
+ },
170
+ setup(props) {
171
+ // 重用并且简化
172
+ // 抽离并且获得 styleProps
173
+ const { styleProps, handleClick } = useComponentCommon(props, shapeStylePropsNames);
174
+ return {
175
+ styleProps,
176
+ handleClick
177
+ };
178
+ }
179
+ });
180
+
181
+ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
182
+ return (openBlock(), createElementBlock("div", {
183
+ style: normalizeStyle(_ctx.styleProps),
184
+ class: "l-shape-component",
185
+ onClick: _cache[0] || (_cache[0] = withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"]))
186
+ }, null, 4 /* STYLE */))
187
+ }
188
+
189
+ script$2.render = render$2;
190
+ script$2.__file = "src/components/LShape/LShape.vue";
191
+
192
+ script$2.install = (app) => {
193
+ app.component(script$2.name, script$2);
194
+ };
195
+
196
+ const components = [
197
+ script,
198
+ script$1,
199
+ script$2
200
+ ];
201
+ const install = (app) => {
202
+ components.forEach(component => {
203
+ app.component(component.name, component);
204
+ });
205
+ };
206
+ var index = {
207
+ install
208
+ };
209
+
210
+ export default index;
211
+ export { script$1 as LImage, script$2 as LShape, script as LText, imageDefaultProps, imageStylePropsNames, install, shapeDefaultProps, shapeStylePropsNames, textDefaultProps, textStylePropNames };
@@ -0,0 +1,227 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('lodash-es'), require('vue')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'lodash-es', 'vue'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.LegoComponents = {}, global._, global.Vue));
5
+ }(this, (function (exports, lodashEs, vue) { 'use strict';
6
+
7
+ const commonDefaultProps = {
8
+ // actions
9
+ actionType: '',
10
+ url: '',
11
+ // size
12
+ height: '',
13
+ width: '373px',
14
+ paddingLeft: '0px',
15
+ paddingRight: '0px',
16
+ paddingTop: '0px',
17
+ paddingBottom: '0px',
18
+ // border type
19
+ borderStyle: 'none',
20
+ borderColor: '#000',
21
+ borderWidth: '0',
22
+ borderRadius: '0',
23
+ // shadow and opacity
24
+ boxShadow: '0 0 0 #000000',
25
+ opacity: '1',
26
+ // position and x,y
27
+ position: 'absolute',
28
+ left: '0',
29
+ top: '0',
30
+ right: '0'
31
+ };
32
+ const textDefaultProps = {
33
+ // basic props - font styles
34
+ text: '正文内容',
35
+ fontSize: '14px',
36
+ fontFamily: '',
37
+ fontWeight: 'normal',
38
+ fontStyle: 'normal',
39
+ textDecoration: 'none',
40
+ lineHeight: '1',
41
+ textAlign: 'left',
42
+ color: '#000000',
43
+ backgroundColor: '',
44
+ ...commonDefaultProps
45
+ };
46
+ const imageDefaultProps = {
47
+ src: 'test.url',
48
+ ...commonDefaultProps
49
+ };
50
+ const shapeDefaultProps = {
51
+ backgroundColor: '',
52
+ ...commonDefaultProps
53
+ };
54
+ const isEditingProp = {
55
+ isEditing: {
56
+ type: Boolean,
57
+ default: false
58
+ }
59
+ };
60
+ const textStylePropNames = lodashEs.without(Object.keys(textDefaultProps), 'actionType', 'url', 'text');
61
+ const imageStylePropsNames = lodashEs.without(Object.keys(imageDefaultProps), 'actionType', 'url', 'src');
62
+ const shapeStylePropsNames = lodashEs.without(Object.keys(shapeDefaultProps), 'actionType', 'url');
63
+ const transformToComponentProps = (props) => {
64
+ const mapProps = lodashEs.mapValues(props, (item) => {
65
+ return {
66
+ type: item.constructor,
67
+ default: item
68
+ };
69
+ });
70
+ return { ...mapProps, ...isEditingProp };
71
+ };
72
+
73
+ const useComponentCommon = (props, picks) => {
74
+ const styleProps = vue.computed(() => lodashEs.pick(props, picks));
75
+ const handleClick = () => {
76
+ if (props.actionType === 'url' && props.url && !props.isEditing) {
77
+ window.location.href = props.url;
78
+ }
79
+ };
80
+ return {
81
+ styleProps,
82
+ handleClick
83
+ };
84
+ };
85
+
86
+ const defaultProps = transformToComponentProps(textDefaultProps);
87
+ // array that contains style props
88
+ var script = vue.defineComponent({
89
+ name: 'l-text',
90
+ props: {
91
+ tag: {
92
+ type: String,
93
+ default: 'div'
94
+ },
95
+ ...defaultProps
96
+ },
97
+ setup(props) {
98
+ // 重用并且简化
99
+ // 抽离并且获得 styleProps
100
+ const { styleProps, handleClick } = useComponentCommon(props, textStylePropNames);
101
+ return {
102
+ styleProps,
103
+ handleClick
104
+ };
105
+ }
106
+ });
107
+
108
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
109
+ return (vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(_ctx.tag), {
110
+ style: vue.normalizeStyle(_ctx.styleProps),
111
+ class: "l-text-component",
112
+ onClick: _ctx.handleClick
113
+ }, {
114
+ default: vue.withCtx(() => [
115
+ vue.createTextVNode(vue.toDisplayString(_ctx.text), 1 /* TEXT */)
116
+ ]),
117
+ _: 1 /* STABLE */
118
+ }, 8 /* PROPS */, ["style", "onClick"]))
119
+ }
120
+
121
+ script.render = render;
122
+ script.__scopeId = "data-v-6bf95b7a";
123
+ script.__file = "src/components/LText/LText.vue";
124
+
125
+ script.install = (app) => {
126
+ app.component(script.name, script);
127
+ };
128
+
129
+ const defaultProps$1 = transformToComponentProps(imageDefaultProps);
130
+ // array that contains style props
131
+ var script$1 = vue.defineComponent({
132
+ name: 'l-image',
133
+ props: {
134
+ ...defaultProps$1
135
+ },
136
+ setup(props) {
137
+ // 重用并且简化
138
+ // 抽离并且获得 styleProps
139
+ const { styleProps, handleClick } = useComponentCommon(props, imageStylePropsNames);
140
+ return {
141
+ styleProps,
142
+ handleClick
143
+ };
144
+ }
145
+ });
146
+
147
+ const _hoisted_1 = ["src"];
148
+
149
+ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
150
+ return (vue.openBlock(), vue.createElementBlock("img", {
151
+ style: vue.normalizeStyle(_ctx.styleProps),
152
+ class: "l-image-component",
153
+ onClick: _cache[0] || (_cache[0] = vue.withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"])),
154
+ src: _ctx.src
155
+ }, null, 12 /* STYLE, PROPS */, _hoisted_1))
156
+ }
157
+
158
+ script$1.render = render$1;
159
+ script$1.__scopeId = "data-v-1e970aa2";
160
+ script$1.__file = "src/components/LImage/LImage.vue";
161
+
162
+ script$1.install = (app) => {
163
+ app.component(script$1.name, script$1);
164
+ };
165
+
166
+ const defaultProps$2 = transformToComponentProps(shapeDefaultProps);
167
+ // array that contains style props
168
+ var script$2 = vue.defineComponent({
169
+ name: 'l-shape',
170
+ props: {
171
+ ...defaultProps$2
172
+ },
173
+ setup(props) {
174
+ // 重用并且简化
175
+ // 抽离并且获得 styleProps
176
+ const { styleProps, handleClick } = useComponentCommon(props, shapeStylePropsNames);
177
+ return {
178
+ styleProps,
179
+ handleClick
180
+ };
181
+ }
182
+ });
183
+
184
+ function render$2(_ctx, _cache, $props, $setup, $data, $options) {
185
+ return (vue.openBlock(), vue.createElementBlock("div", {
186
+ style: vue.normalizeStyle(_ctx.styleProps),
187
+ class: "l-shape-component",
188
+ onClick: _cache[0] || (_cache[0] = vue.withModifiers((...args) => (_ctx.handleClick && _ctx.handleClick(...args)), ["prevent"]))
189
+ }, null, 4 /* STYLE */))
190
+ }
191
+
192
+ script$2.render = render$2;
193
+ script$2.__file = "src/components/LShape/LShape.vue";
194
+
195
+ script$2.install = (app) => {
196
+ app.component(script$2.name, script$2);
197
+ };
198
+
199
+ const components = [
200
+ script,
201
+ script$1,
202
+ script$2
203
+ ];
204
+ const install = (app) => {
205
+ components.forEach(component => {
206
+ app.component(component.name, component);
207
+ });
208
+ };
209
+ var index = {
210
+ install
211
+ };
212
+
213
+ exports.LImage = script$1;
214
+ exports.LShape = script$2;
215
+ exports.LText = script;
216
+ exports.default = index;
217
+ exports.imageDefaultProps = imageDefaultProps;
218
+ exports.imageStylePropsNames = imageStylePropsNames;
219
+ exports.install = install;
220
+ exports.shapeDefaultProps = shapeDefaultProps;
221
+ exports.shapeStylePropsNames = shapeStylePropsNames;
222
+ exports.textDefaultProps = textDefaultProps;
223
+ exports.textStylePropNames = textStylePropNames;
224
+
225
+ Object.defineProperty(exports, '__esModule', { value: true });
226
+
227
+ })));
package/package.json ADDED
@@ -0,0 +1,76 @@
1
+ {
2
+ "name": "@smilekite/lego-bricks",
3
+ "version": "1.0.0",
4
+ "author": "smiley",
5
+ "scripts": {
6
+ "serve": "vue-cli-service serve",
7
+ "build": "npm run clean && npm run build:esm && npm run build:umd",
8
+ "test:watch": "vue-cli-service test:unit --watch",
9
+ "test": "vue-cli-service test:unit",
10
+ "lint": "vue-cli-service lint --max-warnings 5",
11
+ "build:esm": "rollup --config build/rollup.esm.config.js",
12
+ "build:umd": "rollup --config build/rollup.umd.config.js",
13
+ "clean": "rimraf ./dist",
14
+ "prepublishOnly": "npm run lint && npm run test&& npm run build"
15
+ },
16
+ "husky": {
17
+ "hooks": {
18
+ "pre-commit": "npm run lint && npm run test"
19
+ }
20
+ },
21
+ "main": "dist/lego-bricks.umd.js",
22
+ "module": "dist/lego-bricks.esm.js",
23
+ "files": [
24
+ "dist"
25
+ ],
26
+ "dependencies": {
27
+ "core-js": "3.6.5",
28
+ "lodash-es": "4.17.20"
29
+ },
30
+ "devDependencies": {
31
+ "@rollup/plugin-node-resolve": "11.1.1",
32
+ "@rollup/plugin-typescript": "8.1.1",
33
+ "@types/jest": "24.0.19",
34
+ "@types/lodash-es": "4.17.4",
35
+ "@typescript-eslint/eslint-plugin": "2.33.0",
36
+ "@typescript-eslint/parser": "2.33.0",
37
+ "@vue/cli-plugin-babel": "4.5.0",
38
+ "@vue/cli-plugin-eslint": "4.5.0",
39
+ "@vue/cli-plugin-typescript": "4.5.0",
40
+ "@vue/cli-plugin-unit-jest": "4.5.11",
41
+ "@vue/cli-service": "4.5.0",
42
+ "@vue/compiler-sfc": "^3.0.0",
43
+ "@vue/eslint-config-typescript": "5.1.0",
44
+ "@vue/test-utils": "2.0.0-alpha.8",
45
+ "eslint": "6.7.2",
46
+ "eslint-plugin-vue": "7.0.0",
47
+ "husky": "4.3.8",
48
+ "rimraf": "3.0.2",
49
+ "rollup": "2.38.5",
50
+ "rollup-plugin-css-only": "3.1.0",
51
+ "rollup-plugin-typescript2": "0.29.0",
52
+ "rollup-plugin-vue": "6.0.0",
53
+ "typescript": "3.9.3",
54
+ "vue": "3.2.0",
55
+ "vue-jest": "5.0.0-alpha.9"
56
+ },
57
+ "peerDependencies": {
58
+ "vue": "3.2.0"
59
+ },
60
+ "homepage": "https://github.com/Kitesource/lego-bricks",
61
+ "keywords": [
62
+ "Component",
63
+ "UI",
64
+ "Vue3"
65
+ ],
66
+ "license": "MIT",
67
+ "repository": {
68
+ "type": "git",
69
+ "url": "https://github.com/Kitesource/lego-bricks"
70
+ },
71
+ "types": "dist/index.d.ts",
72
+ "publishConfig": {
73
+ "access": "public",
74
+ "registry": "https://registry.npmjs.org/"
75
+ }
76
+ }