@forsakringskassan/vue-lib-template 1.0.4 → 1.2.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.
Files changed (69) hide show
  1. package/files/Jenkinsfile +2 -0
  2. package/files/README.md +6 -5
  3. package/files/_editorconfig +3 -0
  4. package/files/_gitignore +3 -0
  5. package/files/_htmlvalidateignore +5 -0
  6. package/files/_prettierignore +4 -1
  7. package/files/api-extractor.lib.json +1 -1
  8. package/files/api-extractor.selectors.json +1 -1
  9. package/files/babel.config.js +2 -0
  10. package/files/cypress/support/common.ts +7 -6
  11. package/files/cypress/support/component.ts +5 -25
  12. package/files/cypress/support/main.scss +2 -0
  13. package/files/cypress/tsconfig.json +3 -3
  14. package/files/cypress.config.ts +14 -75
  15. package/files/docs/build.mts +16 -0
  16. package/files/docs/index.md +2 -0
  17. package/files/docs/kattinformation/index.md +28 -0
  18. package/files/docs/package.json +5 -2
  19. package/files/docs/src/bundle-mocks.mjs +22 -0
  20. package/files/docs/src/global.d.ts +7 -0
  21. package/files/docs/src/main.js +17 -0
  22. package/files/docs/src/main.scss +22 -0
  23. package/files/docs/src/setup.ts +6 -1
  24. package/files/docs/tsconfig.json +3 -0
  25. package/files/eslint.config.mjs +2 -0
  26. package/files/etc/lib.api.md +1 -1
  27. package/files/etc/selectors.api.md +13 -0
  28. package/files/package.json +47 -33
  29. package/files/renovate.json +2 -3
  30. package/files/src/CatInfoEdit.vue +57 -0
  31. package/files/src/CatInfoLogic.spec.ts +118 -0
  32. package/files/src/CatInfoShow.vue +27 -0
  33. package/files/src/FcCatInfoComponent.cy.ts +74 -0
  34. package/files/src/FcCatInfoComponent.vue +81 -0
  35. package/files/src/FcCatInfoComponentLiveExample.vue +42 -0
  36. package/files/src/cat-api-mock.spec.ts +27 -0
  37. package/files/src/cat-api.mock.mts +26 -0
  38. package/files/src/cat-api.spec.ts +65 -0
  39. package/files/src/cat-api.ts +15 -0
  40. package/files/src/cat-data.ts +40 -0
  41. package/files/src/cat-info-logic.ts +52 -0
  42. package/files/src/cat-types.ts +11 -0
  43. package/files/src/examples/CatInfoExample.vue +20 -0
  44. package/files/src/index.ts +3 -1
  45. package/files/src/local.ts +1 -1
  46. package/files/src/mocks.mts +6 -0
  47. package/files/src/selectors/FcCatInfoComponent.selectors.ts +74 -0
  48. package/files/src/selectors/index.ts +1 -1
  49. package/files/src/style.scss +1 -0
  50. package/files/src/vite-dev/app.vue +1 -1
  51. package/files/tsconfig.cypress.json +1 -1
  52. package/files/tsconfig.json +1 -1
  53. package/files/tsconfig.lib.json +8 -2
  54. package/files/tsconfig.selectors.json +1 -1
  55. package/files/vite.config.mts +5 -1
  56. package/hooks/install.mjs +9 -1
  57. package/index.js +1 -0
  58. package/package.json +25 -16
  59. package/files/cypress/support/commands/forced-colors.ts +0 -33
  60. package/files/cypress/support/component-index.html +0 -14
  61. package/files/cypress/types/cy-mount.d.ts +0 -9
  62. package/files/cypress/types/forced-colors.d.ts +0 -18
  63. package/files/docs/components/AwesomeComponent.md +0 -27
  64. package/files/docs/components/index.md +0 -5
  65. package/files/src/AwesomeComponent.cy.ts +0 -9
  66. package/files/src/AwesomeComponent.vue +0 -45
  67. package/files/src/AwesomeComponentLogic.spec.ts +0 -30
  68. package/files/src/awesome-component-logic.ts +0 -28
  69. package/files/src/examples/DummyExample.vue +0 -7
@@ -0,0 +1,6 @@
1
+ import { appendBasePath } from "@forsakringskassan/apimock-express/browser";
2
+ import catApiMock from "./cat-api.mock.mts";
3
+
4
+ const mocks = [...appendBasePath([catApiMock], "/api")];
5
+
6
+ export default mocks;
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Selectors for `FcCatInfoComponent`.
3
+ *
4
+ * @public
5
+ * @param selector - The selector for the FcCatInfoComponent.
6
+ * @returns An object with selector methods for the FcCatInfoComponent.
7
+ */
8
+ export function FcCatInfoComponentSelectors(selector: string = ":scope") {
9
+ return Object.freeze({
10
+ /**
11
+ * The base selector for the component.
12
+ * @returns The root selector for the component.
13
+ */
14
+ get selector(): string {
15
+ return selector;
16
+ },
17
+
18
+ /**
19
+ * The loader container.
20
+ */
21
+ loadingContainer(): string {
22
+ return `${selector} [data-test="cat-info-loading"]`;
23
+ },
24
+
25
+ /**
26
+ * The view mode container.
27
+ */
28
+ viewContainer(): string {
29
+ return `${selector} [data-test="cat-info-view"]`;
30
+ },
31
+
32
+ /**
33
+ * The edit mode container.
34
+ */
35
+ editContainer(): string {
36
+ return `${selector} [data-test="cat-info-edit"]`;
37
+ },
38
+
39
+ /**
40
+ * Input for Cat Name in edit mode.
41
+ */
42
+ nameInput(): string {
43
+ return `${selector} [data-test="edit-name"] input`;
44
+ },
45
+
46
+ /**
47
+ * Input for Cat Age in edit mode.
48
+ */
49
+ ageInput(): string {
50
+ return `${selector} [data-test="edit-age"] input`;
51
+ },
52
+
53
+ /**
54
+ * Input for Cat Breed in edit mode.
55
+ */
56
+ breedInput(): string {
57
+ return `${selector} [data-test="edit-breed"] input`;
58
+ },
59
+
60
+ /**
61
+ * Input for Cat Color in edit mode.
62
+ */
63
+ colorInput(): string {
64
+ return `${selector} [data-test="edit-color"] input`;
65
+ },
66
+
67
+ /**
68
+ * Input for Favorite Food in edit mode.
69
+ */
70
+ favoriteFoodInput(): string {
71
+ return `${selector} [data-test="edit-favorite-food"] input`;
72
+ },
73
+ });
74
+ }
@@ -1 +1 @@
1
- export {};
1
+ export { FcCatInfoComponentSelectors } from "./FcCatInfoComponent.selectors";
@@ -0,0 +1 @@
1
+ /* Library styles */
@@ -7,7 +7,7 @@ const namn = ref("Vue lib template");
7
7
 
8
8
  <template>
9
9
  <div class="container">
10
- <h1>@forsakringskassan/vue-lib-template</h1>
10
+ <h1>Development application</h1>
11
11
 
12
12
  <f-text-field v-model="namn" v-validation.required maxlength="100"> Namn </f-text-field>
13
13
  <pre>Hello {{ namn }}!</pre>
@@ -1,4 +1,4 @@
1
- /* This file was generated by @forsakringskassan/vite-lib-config. Changes may be overwritten! */
1
+ /* This file is managed by @forsakringskassan/vue-lib-template. Changes will be overwritten! */
2
2
 
3
3
  {
4
4
  "extends": [
@@ -1,4 +1,4 @@
1
- /* This file was generated by @forsakringskassan/vite-lib-config. Changes may be overwritten! */
1
+ /* This file is managed by @forsakringskassan/vue-lib-template. Changes will be overwritten! */
2
2
 
3
3
  {
4
4
  "extends": "@forsakringskassan/vite-lib-config/tsconfig.root.json",
@@ -1,13 +1,19 @@
1
- /* This file was generated by @forsakringskassan/vite-lib-config. Changes may be overwritten! */
1
+ /* This file is managed by @forsakringskassan/vue-lib-template. Changes will be overwritten! */
2
2
 
3
3
  {
4
4
  "extends": "@forsakringskassan/vite-lib-config/tsconfig.lib.json",
5
5
  "compilerOptions": {
6
+ "allowImportingTsExtensions": true,
6
7
  "paths": {
7
8
  "@forsakringskassan/vue-lib-template/selectors": [
8
9
  "./src/selectors/index.ts"
9
10
  ],
10
11
  "@forsakringskassan/vue-lib-template": ["./src/index.ts"]
11
12
  }
12
- }
13
+ },
14
+ "include": [
15
+ "${configDir}/src/**/*.mts",
16
+ "${configDir}/src/**/*.ts",
17
+ "${configDir}/src/**/*.vue"
18
+ ]
13
19
  }
@@ -1,4 +1,4 @@
1
- /* This file was generated by @forsakringskassan/vite-lib-config. Changes may be overwritten! */
1
+ /* This file is managed by @forsakringskassan/vue-lib-template. Changes will be overwritten! */
2
2
 
3
3
  {
4
4
  "extends": "@forsakringskassan/vite-lib-config/tsconfig.selectors.json"
@@ -1,8 +1,12 @@
1
- /* This file was generated by @forsakringskassan/vite-lib-config. Changes may be overwritten! */
1
+ /* This file is managed by @forsakringskassan/vue-lib-template. Changes will be overwritten! */
2
2
 
3
3
  import { defineConfig } from "@forsakringskassan/vite-lib-config/vite";
4
4
  import { defineTestConfig } from "@forsakringskassan/vitest-config-jsdom";
5
+ import mocks from "./src/mocks.mts";
5
6
 
6
7
  export default defineConfig({
7
8
  test: defineTestConfig(),
9
+ fk: {
10
+ mocks,
11
+ },
8
12
  });
package/hooks/install.mjs CHANGED
@@ -2,7 +2,8 @@
2
2
  * @param {import("cloneman").InstallContext} context
3
3
  */
4
4
  export default async (context) => {
5
- const { getParameter, updateJsonFile } = context;
5
+ const { getParameter, updateJsonFile, getApplicationName, replaceInFile } =
6
+ context;
6
7
 
7
8
  /* write repository url to "package.json" */
8
9
  const repoUrl = getParameter("repo-url");
@@ -12,4 +13,11 @@ export default async (context) => {
12
13
  url: repoUrl,
13
14
  },
14
15
  });
16
+
17
+ /* update placeholder names with the real application name (from package.json) */
18
+ const name = getApplicationName;
19
+ const placeholder = "@forsakringskassan/vue-lib-template";
20
+ await replaceInFile("tsconfig.lib.json", placeholder, name);
21
+ await replaceInFile("tsconfig.cypress.json", placeholder, name);
22
+ await replaceInFile("tsconfig.selectors.json", placeholder, name);
15
23
  };
package/index.js CHANGED
@@ -7,6 +7,7 @@
7
7
 
8
8
  const options = {
9
9
  ...packageJson.cloneman,
10
+ fileHash: "36c8f49330d6acb55faacab6e563150ce680f321673ee1d5989144b469ef7839",
10
11
  filesDir: path.join(import.meta.dirname, "files"),
11
12
  hooksDir: path.join(import.meta.dirname, "hooks"),
12
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/vue-lib-template",
3
- "version": "1.0.4",
3
+ "version": "1.2.0",
4
4
  "description": "Vue library template based on Cloneman",
5
5
  "keywords": [
6
6
  "template",
@@ -40,20 +40,18 @@
40
40
  "CODEOWNERS",
41
41
  "cypress.config.ts",
42
42
  "cypress/fixtures/example.json",
43
- "cypress/support/commands/forced-colors.ts",
44
43
  "cypress/support/common.ts",
45
- "cypress/support/component-index.html",
46
44
  "cypress/support/component.ts",
47
45
  "cypress/support/main.scss",
48
46
  "cypress/tsconfig.json",
49
- "cypress/types/cy-mount.d.ts",
50
- "cypress/types/forced-colors.d.ts",
51
47
  "cypress/types/mocha.d.ts",
52
48
  "docs/build.mts",
53
- "docs/components/AwesomeComponent.md",
54
- "docs/components/index.md",
55
49
  "docs/index.md",
50
+ "docs/kattinformation/index.md",
56
51
  "docs/package.json",
52
+ "docs/src/bundle-mocks.mjs",
53
+ "docs/src/global.d.ts",
54
+ "docs/src/main.js",
57
55
  "docs/src/main.scss",
58
56
  "docs/src/setup.ts",
59
57
  "docs/tsconfig.json",
@@ -64,15 +62,27 @@
64
62
  "LICENSE.md",
65
63
  "README.md",
66
64
  "renovate.json",
67
- "src/awesome-component-logic.ts",
68
- "src/AwesomeComponent.cy.ts",
69
- "src/AwesomeComponent.vue",
70
- "src/AwesomeComponentLogic.spec.ts",
71
- "src/examples/DummyExample.vue",
65
+ "src/cat-api-mock.spec.ts",
66
+ "src/cat-api.mock.mts",
67
+ "src/cat-api.spec.ts",
68
+ "src/cat-api.ts",
69
+ "src/cat-data.ts",
70
+ "src/cat-info-logic.ts",
71
+ "src/cat-types.ts",
72
+ "src/CatInfoEdit.vue",
73
+ "src/CatInfoLogic.spec.ts",
74
+ "src/CatInfoShow.vue",
75
+ "src/examples/CatInfoExample.vue",
76
+ "src/FcCatInfoComponent.cy.ts",
77
+ "src/FcCatInfoComponent.vue",
78
+ "src/FcCatInfoComponentLiveExample.vue",
72
79
  "src/index.ts",
73
80
  "src/local.scss",
74
81
  "src/local.ts",
82
+ "src/mocks.mts",
83
+ "src/selectors/FcCatInfoComponent.selectors.ts",
75
84
  "src/selectors/index.ts",
85
+ "src/style.scss",
76
86
  "src/vite-dev/app.vue",
77
87
  "tsconfig.cypress.json",
78
88
  "tsconfig.json",
@@ -94,17 +104,16 @@
94
104
  "babel.config.js",
95
105
  "cypress.config.ts",
96
106
  "cypress/fixtures/example.json",
97
- "cypress/support/commands/forced-colors.ts",
98
107
  "cypress/support/common.ts",
99
- "cypress/support/component-index.html",
100
108
  "cypress/support/component.ts",
101
109
  "cypress/support/main.scss",
102
110
  "cypress/tsconfig.json",
103
- "cypress/types/cy-mount.d.ts",
104
- "cypress/types/forced-colors.d.ts",
105
111
  "cypress/types/mocha.d.ts",
106
112
  "docs/build.mts",
107
113
  "docs/package.json",
114
+ "docs/src/bundle-mocks.mjs",
115
+ "docs/src/global.d.ts",
116
+ "docs/src/main.js",
108
117
  "docs/src/main.scss",
109
118
  "docs/src/setup.ts",
110
119
  "docs/tsconfig.json",
@@ -1,33 +0,0 @@
1
- /// <reference types="cypress" />
2
-
3
- export type ForcedColorMode = "none" | "dark" | "light";
4
-
5
- /**
6
- * Custom Cypress command for testing with forced colors mode
7
- * Forces the browser to use forced colors prefers-color-scheme media query
8
- */
9
- Cypress.Commands.add("forcedColors", (mode: ForcedColorMode) => {
10
- const cdpCommand = "Emulation.setEmulatedMedia";
11
- const media = "forced-colors";
12
-
13
- const features =
14
- mode === "none"
15
- ? [{ name: media, value: "none" }]
16
- : [
17
- { name: media, value: "active" },
18
- {
19
- name: "prefers-color-scheme",
20
- value: mode,
21
- },
22
- ];
23
-
24
- cy.then(() => {
25
- return Cypress.automation("remote:debugger:protocol", {
26
- command: cdpCommand,
27
- params: {
28
- media,
29
- features,
30
- },
31
- });
32
- }).window();
33
- });
@@ -1,14 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
- <meta name="viewport" content="width=device-width,initial-scale=1.0" />
7
- <title>Components App</title>
8
- </head>
9
- <body>
10
- <div data-cy-root>
11
- <div id="teleport"></div>
12
- </div>
13
- </body>
14
- </html>
@@ -1,9 +0,0 @@
1
- import { mount } from "cypress/vue";
2
-
3
- declare global {
4
- namespace Cypress {
5
- interface Chainable {
6
- mount: typeof mount;
7
- }
8
- }
9
- }
@@ -1,18 +0,0 @@
1
- /// <reference types="cypress" />
2
-
3
- declare global {
4
- namespace Cypress {
5
- interface Chainable {
6
- /**
7
- * Forces the application to run in forced colors mode
8
- * @param mode - "light" or "dark" color mode, "none" will disable the forced colors
9
- * @example cy.forcedColors("dark")
10
- */
11
- forcedColors(
12
- mode: "none" | "dark" | "light",
13
- ): Cypress.Chainable<void>;
14
- }
15
- }
16
- }
17
-
18
- export {};
@@ -1,27 +0,0 @@
1
- ---
2
- title: Mäktig komponent
3
- status: Draft
4
- layout: component
5
- component: AwesomeComponent
6
- ---
7
-
8
- 𝅘𝅥𝅮 Allting är så mäktigt 𝅘𝅥𝅮
9
-
10
- ```import
11
- DummyExample.vue
12
- ```
13
-
14
- ## Tänk på att
15
-
16
- - Detta är en exempel komponent.
17
- - Den ska inte användas i produktion.
18
-
19
- ## Copy
20
-
21
- - Använd tydlig och begriplig text.
22
-
23
- ## API
24
-
25
- :::api
26
- vue:AwesomeComponent
27
- :::
@@ -1,5 +0,0 @@
1
- ---
2
- title: Komponenter
3
- name: components
4
- layout: content-with-menu
5
- ---
@@ -1,9 +0,0 @@
1
- import AwesomeComponent from "./AwesomeComponent.vue";
2
-
3
- describe("AwesomeComponent", () => {
4
- it("fetches data on button click", () => {
5
- cy.mount(AwesomeComponent);
6
- cy.get("button").click();
7
- cy.get("p.result").should("contain.text", "Hello from backend");
8
- });
9
- });
@@ -1,45 +0,0 @@
1
- <script setup lang="ts">
2
- import { FButton, FCard } from "@fkui/vue";
3
- import { useAwesomeLogic } from "./awesome-component-logic";
4
-
5
- const { loading, data, fetchData } = useAwesomeLogic();
6
- </script>
7
-
8
- <template>
9
- <f-card class="awesome-card">
10
- <template #header>
11
- <h2>
12
- <!-- @slot Heading -->
13
- <slot>Awesome Component</slot>
14
- </h2>
15
- </template>
16
- <template #default>
17
- <div class="content">
18
- <f-button :disabled="loading" variant="primary" size="medium" @click="fetchData">
19
- {{ loading ? "Loading..." : "Fetch data" }}
20
- </f-button>
21
- <p v-if="data" class="result">{{ data }}</p>
22
- </div>
23
- </template>
24
- </f-card>
25
- </template>
26
-
27
- <style lang="scss" scoped>
28
- .awesome-card {
29
- padding: 1rem;
30
- max-width: 400px;
31
- margin: auto;
32
- }
33
-
34
- .content {
35
- display: flex;
36
- flex-direction: column;
37
- gap: 0.5rem;
38
- align-items: center;
39
- }
40
-
41
- .result {
42
- font-weight: bold;
43
- color: #0066cc;
44
- }
45
- </style>
@@ -1,30 +0,0 @@
1
- import { beforeEach, describe, expect, it, vi } from "vitest";
2
- import { useAwesomeLogic } from "./awesome-component-logic";
3
-
4
- describe("useAwesomeLogic", () => {
5
- let logic: ReturnType<typeof useAwesomeLogic>;
6
-
7
- beforeEach(() => {
8
- // Reset timers for the Promise timeout
9
- vi.useFakeTimers();
10
- logic = useAwesomeLogic();
11
- });
12
-
13
- it("should have initial state", () => {
14
- expect.assertions(2);
15
- expect(logic.loading.value).toBe(false);
16
- expect(logic.data.value).toBeNull();
17
- });
18
-
19
- it("fetchData sets loading then data", async () => {
20
- expect.assertions(3);
21
- const fetchPromise = logic.fetchData();
22
- // loading should be true immediately
23
- expect(logic.loading.value).toBe(true);
24
- // fast-forward the timer to resolve the simulated backend call
25
- vi.advanceTimersByTime(300);
26
- await fetchPromise;
27
- expect(logic.loading.value).toBe(false);
28
- expect(logic.data.value).toBe("Hello from backend");
29
- });
30
- });
@@ -1,28 +0,0 @@
1
- import type { Ref } from "vue";
2
- import { ref } from "vue";
3
-
4
- /**
5
- * Business logic for the Awesome component.
6
- * Returns reactive refs and a fetch function that simulates a backend call.
7
- */
8
- export function useAwesomeLogic(): {
9
- loading: Ref<boolean>;
10
- data: Ref<string | null>;
11
- fetchData: () => Promise<void>;
12
- } {
13
- const loading = ref(false);
14
- const data = ref<string | null>(null);
15
-
16
- async function fetchData(): Promise<void> {
17
- loading.value = true;
18
- const result = await new Promise<{ message: string }>((resolve) => {
19
- setTimeout(() => {
20
- resolve({ message: "Hello from backend" });
21
- }, 300);
22
- });
23
- data.value = result.message;
24
- loading.value = false;
25
- }
26
-
27
- return { loading, data, fetchData };
28
- }
@@ -1,7 +0,0 @@
1
- <script setup lang="ts">
2
- import AwesomeComponent from "../AwesomeComponent.vue";
3
- </script>
4
-
5
- <template>
6
- <awesome-component />
7
- </template>