@farris/cli 1.0.28 → 2.0.0-beta.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.
Files changed (149) hide show
  1. package/bin/index.js +2 -0
  2. package/lib/commands/build-components.js +40 -0
  3. package/lib/commands/build-components.js.map +1 -0
  4. package/lib/commands/build-css.js +39 -0
  5. package/lib/commands/build-css.js.map +1 -0
  6. package/lib/commands/build-lib.js +26 -0
  7. package/lib/commands/build-lib.js.map +1 -0
  8. package/lib/commands/build.js +16 -0
  9. package/lib/commands/build.js.map +1 -0
  10. package/lib/commands/create-app.js +55 -0
  11. package/lib/commands/create-app.js.map +1 -0
  12. package/lib/commands/dev-serve.js +19 -0
  13. package/lib/commands/dev-serve.js.map +1 -0
  14. package/lib/commands/preview-serve.js +17 -0
  15. package/lib/commands/preview-serve.js.map +1 -0
  16. package/lib/common/constant.js +19 -0
  17. package/lib/common/constant.js.map +1 -0
  18. package/lib/common/generate-app.js +45 -0
  19. package/lib/common/generate-app.js.map +1 -0
  20. package/lib/common/get-dependencies.js +10 -0
  21. package/lib/common/get-dependencies.js.map +1 -0
  22. package/lib/common/get-farris-config.js +12 -0
  23. package/lib/common/get-farris-config.js.map +1 -0
  24. package/lib/common/get-version.js +7 -0
  25. package/lib/common/get-version.js.map +1 -0
  26. package/lib/common/get-vite-config.js +46 -0
  27. package/lib/common/get-vite-config.js.map +1 -0
  28. package/lib/config/vite-app.js +14 -0
  29. package/lib/config/vite-app.js.map +1 -0
  30. package/lib/config/vite-common.js +21 -0
  31. package/lib/config/vite-common.js.map +1 -0
  32. package/lib/config/vite-component.js +30 -0
  33. package/lib/config/vite-component.js.map +1 -0
  34. package/lib/config/vite-lib.js +27 -0
  35. package/lib/config/vite-lib.js.map +1 -0
  36. package/lib/index.js +76 -0
  37. package/lib/index.js.map +1 -0
  38. package/lib/plugins/create-component-style.js +45 -0
  39. package/lib/plugins/create-component-style.js.map +1 -0
  40. package/lib/plugins/create-package-json.js +34 -0
  41. package/lib/plugins/create-package-json.js.map +1 -0
  42. package/lib/plugins/dts.js +9 -0
  43. package/lib/plugins/dts.js.map +1 -0
  44. package/lib/plugins/html-system.js +12 -0
  45. package/lib/plugins/html-system.js.map +1 -0
  46. package/lib/plugins/replace.js +14 -0
  47. package/lib/plugins/replace.js.map +1 -0
  48. package/lib/plugins/systemjs-bundle.js +16 -0
  49. package/lib/plugins/systemjs-bundle.js.map +1 -0
  50. package/package.json +41 -26
  51. package/templates/lib/.eslintrc.cjs +15 -0
  52. package/templates/lib/.prettierrc.json +8 -0
  53. package/templates/lib/components/button/index.ts +7 -0
  54. package/templates/lib/components/button/src/button.component.tsx +84 -0
  55. package/templates/lib/components/button/src/button.props.ts +55 -0
  56. package/templates/lib/components/button/src/button.scss +179 -0
  57. package/templates/lib/components/common/index.ts +6 -0
  58. package/templates/lib/components/common/src/common.scss +4 -0
  59. package/templates/lib/components/common/src/compositions/index.ts +19 -0
  60. package/templates/lib/components/common/src/compositions/types.ts +6 -0
  61. package/templates/lib/components/common/src/compositions/use-bem/index.ts +46 -0
  62. package/templates/lib/components/common/src/compositions/use-click-away/index.ts +40 -0
  63. package/templates/lib/components/common/src/compositions/use-context/use-children-contexts.ts +40 -0
  64. package/templates/lib/components/common/src/compositions/use-context/use-parent-context.ts +24 -0
  65. package/templates/lib/components/common/src/compositions/use-event-listener/index.ts +45 -0
  66. package/templates/lib/components/common/src/compositions/use-expose/index.ts +9 -0
  67. package/templates/lib/components/common/src/compositions/use-lay-render/index.ts +17 -0
  68. package/templates/lib/components/common/src/compositions/use-link/index.ts +14 -0
  69. package/templates/lib/components/common/src/compositions/use-lock-scroll/index.ts +25 -0
  70. package/templates/lib/components/common/src/compositions/use-long-press/index.ts +141 -0
  71. package/templates/lib/components/common/src/compositions/use-momentum/index.ts +82 -0
  72. package/templates/lib/components/common/src/compositions/use-mount-component/index.ts +48 -0
  73. package/templates/lib/components/common/src/compositions/use-rect/index.ts +31 -0
  74. package/templates/lib/components/common/src/compositions/use-refs/index.ts +21 -0
  75. package/templates/lib/components/common/src/compositions/use-resize-observer/index.ts +85 -0
  76. package/templates/lib/components/common/src/compositions/use-resize-observer/utils.ts +37 -0
  77. package/templates/lib/components/common/src/compositions/use-scroll-parent/index.ts +42 -0
  78. package/templates/lib/components/common/src/compositions/use-touch/index.ts +82 -0
  79. package/templates/lib/components/common/src/compositions/use-touch-move/index.ts +120 -0
  80. package/templates/lib/components/common/src/entity/base-property.ts +129 -0
  81. package/templates/lib/components/common/src/entity/entity-schema.ts +274 -0
  82. package/templates/lib/components/common/src/entity/input-base-property.ts +285 -0
  83. package/templates/lib/components/common/src/style/animation/index.scss +150 -0
  84. package/templates/lib/components/common/src/style/base.scss +63 -0
  85. package/templates/lib/components/common/src/style/fonts/farris-mobile-icon.ttf +0 -0
  86. package/templates/lib/components/common/src/style/icon.scss +6 -0
  87. package/templates/lib/components/common/src/style/index.scss +4 -0
  88. package/templates/lib/components/common/src/style/mixins/bem.scss +204 -0
  89. package/templates/lib/components/common/src/style/mixins/border-radius.scss +13 -0
  90. package/templates/lib/components/common/src/style/mixins/ellipsis.scss +15 -0
  91. package/templates/lib/components/common/src/style/mixins/hairline.scss +113 -0
  92. package/templates/lib/components/common/src/style/mixins/index.scss +6 -0
  93. package/templates/lib/components/common/src/style/mixins/margin.scss +10 -0
  94. package/templates/lib/components/common/src/style/mixins/safe-area.scss +9 -0
  95. package/templates/lib/components/common/src/style/variables.scss +113 -0
  96. package/templates/lib/components/common/src/utils/index.ts +15 -0
  97. package/templates/lib/components/common/src/utils/src/common.ts +83 -0
  98. package/templates/lib/components/common/src/utils/src/date.ts +134 -0
  99. package/templates/lib/components/common/src/utils/src/dom/event.ts +37 -0
  100. package/templates/lib/components/common/src/utils/src/hook.ts +18 -0
  101. package/templates/lib/components/common/src/utils/src/number.ts +26 -0
  102. package/templates/lib/components/common/src/utils/src/query-filter.ts +40 -0
  103. package/templates/lib/components/common/src/utils/src/resove-asset.ts +33 -0
  104. package/templates/lib/components/common/src/utils/src/string.ts +18 -0
  105. package/templates/lib/components/common/src/utils/src/throttle.ts +41 -0
  106. package/templates/lib/components/common/src/utils/src/transition.ts +14 -0
  107. package/templates/lib/components/common/src/utils/src/type.ts +105 -0
  108. package/templates/lib/components/common/src/utils/src/use-appearance.ts +33 -0
  109. package/templates/lib/components/common/src/utils/src/with-install.ts +16 -0
  110. package/templates/lib/components/common/src/utils/src/with-register-designer.ts +16 -0
  111. package/templates/lib/components/common/src/utils/src/with-register.ts +16 -0
  112. package/templates/lib/components/common/types.ts +131 -0
  113. package/templates/lib/components/index.ts +0 -0
  114. package/templates/lib/farris.config.mjs +56 -0
  115. package/templates/lib/index.html +12 -0
  116. package/templates/lib/package.json +29 -0
  117. package/templates/lib/src/App.vue +80 -0
  118. package/templates/lib/src/components/TheButton.vue +3 -0
  119. package/templates/lib/src/main.ts +10 -0
  120. package/templates/lib/src/router/index.ts +23 -0
  121. package/templates/lib/src/views/AboutView.vue +15 -0
  122. package/templates/lib/src/views/HomeView.vue +9 -0
  123. package/templates/lib/tsconfig.json +20 -0
  124. package/templates/mobile/.eslintrc.cjs +15 -0
  125. package/templates/mobile/.prettierrc.json +8 -0
  126. package/templates/mobile/farris.config.mjs +24 -0
  127. package/templates/mobile/index.html +12 -0
  128. package/templates/mobile/package.json +29 -0
  129. package/templates/mobile/src/App.vue +80 -0
  130. package/templates/mobile/src/components/TheButton.vue +3 -0
  131. package/templates/mobile/src/main.ts +12 -0
  132. package/templates/mobile/src/router/index.ts +23 -0
  133. package/templates/mobile/src/views/AboutView.vue +15 -0
  134. package/templates/mobile/src/views/HomeView.vue +9 -0
  135. package/templates/mobile/tsconfig.json +18 -0
  136. package/templates/web/.eslintrc.cjs +15 -0
  137. package/templates/web/.prettierrc.json +8 -0
  138. package/templates/web/farris.config.mjs +24 -0
  139. package/templates/web/index.html +12 -0
  140. package/templates/web/package.json +29 -0
  141. package/templates/web/src/App.vue +80 -0
  142. package/templates/web/src/components/TheButton.vue +3 -0
  143. package/templates/web/src/main.ts +10 -0
  144. package/templates/web/src/router/index.ts +23 -0
  145. package/templates/web/src/views/AboutView.vue +15 -0
  146. package/templates/web/src/views/HomeView.vue +9 -0
  147. package/templates/web/tsconfig.json +18 -0
  148. package/README.md +0 -2
  149. package/ci/cli.js +0 -467
@@ -0,0 +1,45 @@
1
+ const NotStyleComponents = ['designer-canvas', 'dynamic-view', 'dynamic-resolver', 'common'];
2
+ const getComponentStyle = (imports) => {
3
+ const components = imports
4
+ .filter(path => {
5
+ return path.startsWith('@components/') && !NotStyleComponents.find(notStylecomponent => path.includes(notStylecomponent));
6
+ })
7
+ .filter((item, index, array) => {
8
+ const targetIndex = array.filter(e => e !== item).findIndex(e => item.includes(e));
9
+ return targetIndex < 0;
10
+ })
11
+ .map(name => {
12
+ const paths = name.split('/');
13
+ return {
14
+ name: paths[1],
15
+ path: `../${paths[1]}/style.js`
16
+ };
17
+ });
18
+ components.push({
19
+ name: 'components',
20
+ path: `./index.css`
21
+ });
22
+ const template = `${components.map(component => {
23
+ const { path } = component;
24
+ return `import '${path}';`;
25
+ }).join('\n')}
26
+ `;
27
+ return template;
28
+ };
29
+ export function createComponentStyle() {
30
+ return {
31
+ name: 'farris-gen-component-style',
32
+ renderChunk(code, chunk) {
33
+ const { imports } = chunk;
34
+ const template = getComponentStyle(imports);
35
+ template && this.emitFile({
36
+ type: 'asset',
37
+ fileName: 'style.js',
38
+ source: template
39
+ });
40
+ return code;
41
+ }
42
+ };
43
+ }
44
+ ;
45
+ //# sourceMappingURL=create-component-style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-component-style.js","sourceRoot":"","sources":["../../src/plugins/create-component-style.ts"],"names":[],"mappings":"AAAA,MAAM,kBAAkB,GAAG,CAAC,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,QAAQ,CAAC,CAAC;AAE7F,MAAM,iBAAiB,GAAG,CAAC,OAAiB,EAAE,EAAE;IAE9C,MAAM,UAAU,GAAG,OAAO;SACvB,MAAM,CAAC,IAAI,CAAC,EAAE;QACb,OAAO,IAAI,CAAC,UAAU,CAAC,cAAc,CAAC,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAC5H,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;QAC7B,MAAM,WAAW,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA,EAAE,CAAC,CAAC,KAAG,IAAI,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;QAChF,OAAO,WAAW,GAAG,CAAC,CAAC;IACzB,CAAC,CAAC;SACD,GAAG,CAAC,IAAI,CAAC,EAAE;QACV,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9B,OAAO;YACL,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC;YACd,IAAI,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,WAAW;SAChC,CAAC;IACJ,CAAC,CAAC,CAAC;IAEL,UAAU,CAAC,IAAI,CAAC;QACd,IAAI,EAAE,YAAY;QAClB,IAAI,EAAE,aAAa;KACpB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,GAAG,UAAU,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE;QAC7C,MAAM,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;QAC3B,OAAO,WAAW,IAAI,IAAI,CAAC;IAC7B,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;CACd,CAAC;IAEA,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEF,MAAM,UAAU,oBAAoB;IAClC,OAAO;QACL,IAAI,EAAE,4BAA4B;QAClC,WAAW,CAAC,IAAY,EAAE,KAAU;YAClC,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;YAE1B,MAAM,QAAQ,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC;YAE5C,QAAQ,IAAI,IAAI,CAAC,QAAQ,CAAC;gBACxB,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,UAAU;gBACpB,MAAM,EAAE,QAAQ;aACjB,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;KACF,CAAC;AACJ,CAAC;AAAA,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ import { CWD } from "../common/constant.js";
4
+ export const createPackageJson = () => {
5
+ return {
6
+ name: 'create-package-json',
7
+ generateBundle() {
8
+ const pkg = readFileSync(resolve(CWD, 'package.json'), 'utf-8');
9
+ const packageJson = JSON.parse(pkg);
10
+ const result = {
11
+ name: '',
12
+ version: '',
13
+ private: false,
14
+ main: './index.umd.js',
15
+ module: './index.esm.js',
16
+ types: './types/index.d.ts',
17
+ style: './index.css',
18
+ };
19
+ const exclude = ['scripts', 'devDependencies', 'private'];
20
+ Object.keys(packageJson).forEach(key => {
21
+ if (exclude.includes(key)) {
22
+ return;
23
+ }
24
+ result[key] = packageJson[key];
25
+ });
26
+ this.emitFile({
27
+ type: 'asset',
28
+ fileName: 'package.json',
29
+ source: JSON.stringify(result, null, 2)
30
+ });
31
+ }
32
+ };
33
+ };
34
+ //# sourceMappingURL=create-package-json.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"create-package-json.js","sourceRoot":"","sources":["../../src/plugins/create-package-json.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAQ,EAAE;IACzC,OAAO;QACL,IAAI,EAAE,qBAAqB;QAC3B,cAAc;YACZ,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC;YAChE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACpC,MAAM,MAAM,GAAwB;gBAClC,IAAI,EAAE,EAAE;gBACR,OAAO,EAAE,EAAE;gBACX,OAAO,EAAE,KAAK;gBACd,IAAI,EAAE,gBAAgB;gBACtB,MAAM,EAAE,gBAAgB;gBACxB,KAAK,EAAE,oBAAoB;gBAC3B,KAAK,EAAE,aAAa;aACrB,CAAC;YACF,MAAM,OAAO,GAAG,CAAC,SAAS,EAAE,iBAAiB,EAAE,SAAS,CAAC,CAAC;YAC1D,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;gBACrC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;oBACzB,OAAO;iBACR;gBACD,MAAM,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YAEH,IAAI,CAAC,QAAQ,CAAC;gBACZ,IAAI,EAAE,OAAO;gBACb,QAAQ,EAAE,cAAc;gBACxB,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;aACxC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ import dts from "vite-plugin-dts";
2
+ export function generateTypes(entry, outDir) {
3
+ return dts({
4
+ entryRoot: entry,
5
+ outDir
6
+ });
7
+ }
8
+ ;
9
+ //# sourceMappingURL=dts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dts.js","sourceRoot":"","sources":["../../src/plugins/dts.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,iBAAiB,CAAC;AAElC,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,MAAc;IACzD,OAAO,GAAG,CAAC;QACT,SAAS,EAAE,KAAK;QAChB,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAAA,CAAC"}
@@ -0,0 +1,12 @@
1
+ export const htmlSystemPlugin = () => {
2
+ return {
3
+ name: 'html-transform-system',
4
+ transformIndexHtml(html) {
5
+ const regexp = /<script.*type="module".*src="(.*?)"><\/script>/;
6
+ return html.replace(regexp, (str, p1) => `
7
+ <script src="https://cdn.bootcdn.net/ajax/libs/systemjs/6.15.1/system.js"></script>
8
+ <script >System.import("${p1}");</script>`);
9
+ }
10
+ };
11
+ };
12
+ //# sourceMappingURL=html-system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html-system.js","sourceRoot":"","sources":["../../src/plugins/html-system.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,OAAO;QACL,IAAI,EAAE,uBAAuB;QAC7B,kBAAkB,CAAC,IAAY;YAC7B,MAAM,MAAM,GAAG,gDAAgD,CAAC;YAChE,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC,GAAW,EAAE,EAAU,EAAC,EAAE,CAAC;;8BAEhC,EAAE,cAAc,CAAC,CAAC;QAC5C,CAAC;KACF,CAAC;AACJ,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export function replace(path) {
2
+ return {
3
+ name: 'farris-replace',
4
+ renderChunk(code, chunk) {
5
+ const fileNames = chunk.fileName.split('.');
6
+ const format = fileNames[fileNames.length - 2];
7
+ return code.replace(/@components(\/\w+)/g, (...args) => {
8
+ return path(format, args);
9
+ });
10
+ }
11
+ };
12
+ }
13
+ ;
14
+ //# sourceMappingURL=replace.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replace.js","sourceRoot":"","sources":["../../src/plugins/replace.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,OAAO,CAAC,IAAgD;IACtE,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,WAAW,CAAC,IAAY,EAAE,KAAU;YAClC,MAAM,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,SAAS,CAAC,SAAS,CAAC,MAAM,GAAC,CAAC,CAAC,CAAC;YAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,qBAAqB,EAAE,CAAC,GAAG,IAAI,EAAC,EAAE;gBACpD,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;YAC5B,CAAC,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC;AAAA,CAAC"}
@@ -0,0 +1,16 @@
1
+ export function systemjsBundle() {
2
+ return {
3
+ name: 'systemjs-bundle',
4
+ outputOptions(options) {
5
+ if (options.format === 'systemjs') {
6
+ return {
7
+ ...options,
8
+ name: undefined
9
+ };
10
+ }
11
+ return options;
12
+ }
13
+ };
14
+ }
15
+ ;
16
+ //# sourceMappingURL=systemjs-bundle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"systemjs-bundle.js","sourceRoot":"","sources":["../../src/plugins/systemjs-bundle.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,cAAc;IAC5B,OAAO;QACL,IAAI,EAAE,iBAAiB;QACvB,aAAa,CAAC,OAAY;YACxB,IAAG,OAAO,CAAC,MAAM,KAAK,UAAU,EAAE;gBAChC,OAAO;oBACL,GAAG,OAAO;oBACV,IAAI,EAAE,SAAS;iBAChB,CAAC;aACH;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;KACF,CAAC;AACJ,CAAC;AAAA,CAAC"}
package/package.json CHANGED
@@ -1,26 +1,41 @@
1
- {
2
- "name": "@farris/cli",
3
- "version": "1.0.28",
4
- "description": "Farris command line interface",
5
- "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "repository": {
10
- "type": "git",
11
- "url": "https://git.iec.io/webadp/farris-cli.git"
12
- },
13
- "keywords": [
14
- "Farris",
15
- "CLI"
16
- ],
17
- "bin": {
18
- "farris": "ci/cli.js"
19
- },
20
- "author": "Sagi Chen",
21
- "license": "ISC",
22
- "dependencies": {
23
- "lerna": "^4.0.0",
24
- "moment": "^2.29.3"
25
- }
26
- }
1
+ {
2
+ "name": "@farris/cli",
3
+ "private": false,
4
+ "version": "2.0.0-beta.8",
5
+ "type": "module",
6
+ "typings": "lib/index.d.ts",
7
+ "bin": {
8
+ "farris-cli": "./bin/index.js"
9
+ },
10
+ "engines": {
11
+ "node": ">=16.0.0"
12
+ },
13
+ "scripts": {
14
+ "build": "rimraf ./lib && tsc"
15
+ },
16
+ "files": [
17
+ "lib",
18
+ "templates",
19
+ "bin.js"
20
+ ],
21
+ "license": "MIT",
22
+ "dependencies": {
23
+ "@types/inquirer": "^9.0.7",
24
+ "@vitejs/plugin-vue": "^4.0.0",
25
+ "@vitejs/plugin-vue-jsx": "^3.0.0",
26
+ "commander": "^9.4.0",
27
+ "esbuild": "^0.23.0",
28
+ "esbuild-sass-plugin": "^3.3.1",
29
+ "inquirer": "^9.3.0",
30
+ "ora": "^8.0.1",
31
+ "typescript": "^4.6.4",
32
+ "vite": "^4.4.1",
33
+ "vite-plugin-css-injected-by-js": "^3.5.2",
34
+ "vite-plugin-dts": "^3.9.1"
35
+ },
36
+ "devDependencies": {
37
+ "@types/inquirer": "^9.0.7",
38
+ "rimraf": "^5.0.7",
39
+ "vue": "^3.2.37"
40
+ }
41
+ }
@@ -0,0 +1,15 @@
1
+ /* eslint-env node */
2
+ require('@rushstack/eslint-patch/modern-module-resolution');
3
+
4
+ module.exports = {
5
+ root: true,
6
+ 'extends': [
7
+ 'plugin:vue/vue3-essential',
8
+ 'eslint:recommended',
9
+ '@vue/eslint-config-typescript',
10
+ '@vue/eslint-config-prettier/skip-formatting'
11
+ ],
12
+ parserOptions: {
13
+ ecmaVersion: 'latest'
14
+ }
15
+ };
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://json.schemastore.org/prettierrc",
3
+ "semi": false,
4
+ "tabWidth": 2,
5
+ "singleQuote": true,
6
+ "printWidth": 100,
7
+ "trailingComma": "none"
8
+ }
@@ -0,0 +1,7 @@
1
+ import { Plugin } from 'vue';
2
+ import { withInstall } from '@components/common';
3
+ import ButtonInstallless from './src/button.component';
4
+
5
+ const Button = withInstall(ButtonInstallless);
6
+ export { Button };
7
+ export default Button as typeof Button & Plugin;
@@ -0,0 +1,84 @@
1
+ import { CSSProperties, computed, defineComponent } from 'vue';
2
+ import { useBem } from '@/components/common';
3
+ import { BUTTON_NAME, ButtonProps, buttonProps } from './button.props';
4
+
5
+ export default defineComponent({
6
+ name: BUTTON_NAME,
7
+ props: buttonProps,
8
+ emits: ['click'],
9
+ setup(props: ButtonProps, context) {
10
+ const { slots } = context;
11
+
12
+ const { bem, getModifierClass } = useBem(BUTTON_NAME);
13
+
14
+ const buttonClass = computed(() => {
15
+ const classList = [bem(), getModifierClass(props.type)];
16
+ props.disabled && classList.push(getModifierClass('disabled'));
17
+ props.block && classList.push(getModifierClass('block'));
18
+ props.round && classList.push(getModifierClass('round'));
19
+ props.plain && classList.push(getModifierClass('plain'));
20
+ props.noBorder && classList.push(getModifierClass('noborder'));
21
+ props.loading && classList.push(getModifierClass('loading'));
22
+ props.size && classList.push(getModifierClass(props.size));
23
+ return classList;
24
+ });
25
+
26
+ const applyGradientBorderBehavior = (style: CSSProperties, color: string) =>{
27
+ const isGradientColor = color.includes('gradient');
28
+ if (isGradientColor) {
29
+ style.border = 0;
30
+ } else {
31
+ style.borderColor = color;
32
+ }
33
+ };
34
+
35
+ const buttonStyle = computed(() => {
36
+ const textColor = props.plain ? props.color : '#fff';
37
+ const backgroundColor = !props.plain ? props.color : null;
38
+
39
+ const style: CSSProperties = {};
40
+ if (props.color) {
41
+ style.color = textColor;
42
+ style.boxShadow = 'none';
43
+ backgroundColor && (style.background = backgroundColor);
44
+ applyGradientBorderBehavior(style, props.color);
45
+ }
46
+ return style;
47
+ });
48
+
49
+ const onClickButton = ($event: Event) =>{
50
+ $event.stopPropagation();
51
+ if (!props.disabled) {
52
+ context.emit('click', $event);
53
+ }
54
+ };
55
+
56
+ const renderLoading = () => {
57
+ return (
58
+ props.loading && <>
59
+ <span class={bem('loading')}>
60
+ <svg viewBox="25 25 50 50" class={bem('loading-icon-circular')}>
61
+ <circle cx="50" cy="50" r="20" fill="none" />
62
+ </svg>
63
+ </span>
64
+ {props.loadingText && <span class={bem('loading-text')}>{props.loadingText}</span>}
65
+ </>
66
+ );
67
+ };
68
+
69
+ const renderText = ()=> {
70
+ return slots.default && <span class={bem('text')}>{slots.default()}</span>;
71
+ };
72
+
73
+ return () => (
74
+ <button
75
+ class={buttonClass.value}
76
+ style={buttonStyle.value}
77
+ onClick={onClickButton}
78
+ >
79
+ {renderLoading()}
80
+ {renderText()}
81
+ </button>
82
+ );
83
+ }
84
+ });
@@ -0,0 +1,55 @@
1
+ import { ExtractPropTypes, PropType } from 'vue';
2
+
3
+ export type ButtonType = 'primary' | 'secondary' | 'success' | 'warning' | 'danger' | 'info';
4
+ export type ButtonSize = 'large' | 'normal' | 'small' | 'mini';
5
+
6
+ export const BUTTON_NAME = "fm-button";
7
+
8
+ export const buttonProps = {
9
+ type: {
10
+ type: String as PropType<ButtonType>,
11
+ default: 'primary'
12
+ },
13
+ size: {
14
+ type: String as PropType<ButtonSize>,
15
+ default: ''
16
+ },
17
+ color: {
18
+ type: String,
19
+ default: ''
20
+ },
21
+ block: {
22
+ type: Boolean,
23
+ default: false
24
+ },
25
+ noBorder: {
26
+ type: Boolean,
27
+ default: false
28
+ },
29
+ plain: {
30
+ type: Boolean,
31
+ default: false
32
+ },
33
+ round: {
34
+ type: Boolean,
35
+ default: false
36
+ },
37
+ disabled: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ icon: {
42
+ type: String,
43
+ default: ''
44
+ },
45
+ loading: {
46
+ type: Boolean,
47
+ default: false
48
+ },
49
+ loadingText: {
50
+ type: String,
51
+ default: ''
52
+ }
53
+ };
54
+
55
+ export type ButtonProps = ExtractPropTypes<typeof buttonProps>;
@@ -0,0 +1,179 @@
1
+ @use '../../common/src/style/mixins/index.scss' as *;
2
+
3
+ :root {
4
+ --fm-button-height: 42px;
5
+ --fm-button-padding: 0 14px;
6
+ --fm-button-radius: 2px;
7
+ --fm-button-border-width: 1px;
8
+ --fm-button-color: var(--fm-white);
9
+ --fm-button-line-height: var(--fm-line-height);
10
+ --fm-button-font-size: var(--fm-font-size);
11
+ --fm-button-plain-background: var(--fm-white);
12
+ --fm-button-lg-height: 46px;
13
+ --fm-button-lg-font-size: 18px;
14
+ --fm-button-md-height: 38px;
15
+ --fm-button-md-font-size: 14px;
16
+ --fm-button-sm-height: 34px;
17
+ --fm-button-sm-padding: 0 8px;
18
+ --fm-button-sm-font-size: 12px;
19
+ --fm-button-xs-height: 28px;
20
+ --fm-button-xs-font-size: 10px;
21
+ --fm-button-secondary-color: var(--fm-blue-light);
22
+ }
23
+
24
+ @include b(button){
25
+ position: relative;
26
+ cursor: pointer;
27
+ display: inline-flex;
28
+ align-items: center;
29
+ justify-content: center;
30
+ box-sizing: border-box;
31
+ text-align: center;
32
+ margin: 0;
33
+ border: none;
34
+ transition: opacity 0.2s;
35
+ color: var(--fm-button-color);
36
+ height: var(--fm-button-height);
37
+ padding: var(--fm-button-padding);
38
+ font-size: var(--fm-button-font-size);
39
+ line-height: var(--fm-button-line-height);
40
+ border-radius: var(--fm-button-radius);
41
+
42
+ @include m((primary, info)) {
43
+ background: var(--fm-primary-color);
44
+ }
45
+
46
+ @include m(secondary) {
47
+ color: var(--fm-primary-color);
48
+ background: var(--fm-button-secondary-color);
49
+ }
50
+
51
+ @include m(danger) {
52
+ background-color: var(--fm-danger-color);
53
+ }
54
+
55
+ @include m(warning) {
56
+ background-color: var(--fm-warning-color);
57
+ }
58
+
59
+ @include m(success) {
60
+ background-color: var(--fm-success-color);
61
+ }
62
+
63
+ @include m(plain) {
64
+ box-shadow: none;
65
+ background: var(--fm-button-plain-background);
66
+ @include root-m((primary, info)) {
67
+ color: var(--fm-primary-color);
68
+ border: var(--fm-button-border-width) solid var(--fm-primary-color);
69
+ }
70
+ @include root-m(success) {
71
+ color: var(--fm-success-color);
72
+ border: var(--fm-button-border-width) solid var(--fm-success-color);
73
+ }
74
+ @include root-m(danger) {
75
+ color: var(--fm-danger-color);
76
+ border: var(--fm-button-border-width) solid var(--fm-danger-color);
77
+ }
78
+ @include root-m(warning) {
79
+ color: var(--fm-button-warning-color);
80
+ border: var(--fm-button-border-width) solid var(--fm-button-warning-color);
81
+ }
82
+ }
83
+
84
+ @include m(noborder) {
85
+ border: none !important;
86
+ }
87
+
88
+ @include m(large) {
89
+ height: var(--fm-button-lg-height);
90
+ font-size: var(--fm-button-lg-font-size);
91
+ }
92
+
93
+ @include m(normal) {
94
+ height: var(--fm-button-md-height);
95
+ font-size: var(--fm-button-md-font-size);
96
+ }
97
+
98
+ @include m(small) {
99
+ height: var(--fm-button-sm-height);
100
+ padding: var(--fm-button-sm-padding);
101
+ font-size: var(--fm-button-sm-font-size);
102
+ }
103
+
104
+ @include m(mini) {
105
+ height: var(--fm-button-xs-height);
106
+ padding: var(--fm-button-sm-padding);
107
+ font-size: var(--fm-button-xs-font-size);
108
+ }
109
+
110
+ @include m(block) {
111
+ display: flex;
112
+ width: 100%;
113
+ }
114
+
115
+ @include m(disabled) {
116
+ cursor: not-allowed;
117
+ opacity: var(--fm-disabled-opacity);
118
+ }
119
+
120
+ @include m((loading, disabled)) {
121
+ &::before {
122
+ display: none;
123
+ }
124
+ }
125
+
126
+ @include m(round) {
127
+ border-radius: var(--fm-radius-max);
128
+ }
129
+
130
+ @include m(square) {
131
+ border-radius: 0;
132
+ }
133
+
134
+ @include e(loading) {
135
+ display: inline-block;
136
+ width: 20px;
137
+ max-width: 100%;
138
+ height: 20px;
139
+ max-height: 100%;
140
+ vertical-align: middle;
141
+ animation: fm-rotate 2s linear infinite;
142
+ circle {
143
+ animation: fm-circular 1.5s ease-in-out infinite;
144
+ stroke: currentColor;
145
+ stroke-width: 4;
146
+ stroke-linecap: round;
147
+ }
148
+ }
149
+ @include e(loading-icon-circular) {
150
+ color: #fff;
151
+ }
152
+ @include e(loading-text) {
153
+ margin-left: 6px;
154
+ }
155
+ @include e(icon) {
156
+ &:not(:last-child) {
157
+ margin-right: 6px;
158
+ }
159
+ }
160
+
161
+ &::before {
162
+ position: absolute;
163
+ top: 50%;
164
+ left: 50%;
165
+ width: 100%;
166
+ height: 100%;
167
+ background-color: #000;
168
+ border: inherit;
169
+ border-color: #000;
170
+ border-radius: inherit;
171
+ -webkit-transform: translate(-50%, -50%);
172
+ transform: translate(-50%, -50%);
173
+ opacity: 0;
174
+ content: ' ';
175
+ }
176
+ &:active::before {
177
+ opacity: 0.1;
178
+ }
179
+ }
@@ -0,0 +1,6 @@
1
+ export * from './src/compositions';
2
+ export * from './src/utils';
3
+ export * from './types';
4
+
5
+ export const FM_UI_PROVIDER_SERVICE_TOKEN = Symbol('UIProviderService');
6
+
@@ -0,0 +1,4 @@
1
+ @use './style/variables';
2
+ @use './style/base';
3
+ @use './style/icon';
4
+ @use './style/animation';
@@ -0,0 +1,19 @@
1
+ export * from './types';
2
+ export * from './use-context/use-parent-context';
3
+ export * from './use-context/use-children-contexts';
4
+ export * from './use-event-listener';
5
+ export * from './use-touch-move';
6
+ export * from './use-touch';
7
+ export * from './use-lay-render';
8
+ export * from './use-refs';
9
+ export * from './use-rect';
10
+ export * from './use-expose';
11
+ export * from './use-mount-component';
12
+ export * from './use-bem';
13
+ export * from './use-link';
14
+ export * from './use-click-away';
15
+ export * from './use-lock-scroll';
16
+ export * from './use-momentum';
17
+ export * from './use-scroll-parent';
18
+ export * from './use-resize-observer';
19
+ export * from './use-long-press';
@@ -0,0 +1,6 @@
1
+ export interface ParentProvideValue<ParentContext, ChildContext> {
2
+ addChild(childContext: ChildContext): void;
3
+ removeChild(childContext: ChildContext): void;
4
+ childContexts: Array<ChildContext>;
5
+ parentContext: ParentContext;
6
+ };
@@ -0,0 +1,46 @@
1
+ import { isArray, camelToKebabCase } from '../../utils';
2
+
3
+ export const useBem = (name: string) => {
4
+
5
+ const snakeCaseName = camelToKebabCase(name);
6
+
7
+ /**
8
+ * @param element 元素类名
9
+ * @returns .block__element
10
+ */
11
+ const getElementClass = (element?: string | string[])=>{
12
+ if(!element) {
13
+ return snakeCaseName;
14
+ }
15
+ const elementClass = isArray(element) ? element.join('__') : element;
16
+ return `${snakeCaseName}__${elementClass}`;
17
+ };
18
+
19
+ /**
20
+ * @param modifier 修饰符
21
+ * @param element 元素类名
22
+ * @returns .block[__element]--modifier
23
+ */
24
+ const getModifierClass = (modifier: string, element?: string | string[])=>{
25
+ const modifierClass = modifier ? `--${modifier}` : '';
26
+ if(element){
27
+ return getElementClass(element) + modifierClass;
28
+ }
29
+ return snakeCaseName + modifierClass;
30
+ };
31
+
32
+ /**
33
+ * @param element 元素类名
34
+ * @param modifier 修饰符
35
+ * @returns .block__element--modifier
36
+ */
37
+ const bem = (element?: string | string[], modifier?: string) => {
38
+ return modifier ? getModifierClass(modifier, element) : getElementClass(element);
39
+ };
40
+
41
+ return {
42
+ bem,
43
+ getElementClass,
44
+ getModifierClass
45
+ };
46
+ };