@forsakringskassan/vue-lib-template 1.2.11 → 1.4.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.
@@ -6,6 +6,7 @@
6
6
 
7
7
  @use "@fkui/design/src/fonts";
8
8
  @use "@fkui/design/src/fkui";
9
+ @use "../../src/theme";
9
10
 
10
11
  :root {
11
12
  --f-logo-image-small: hotpink;
@@ -1,19 +1,34 @@
1
1
  /* This file is managed by @forsakringskassan/vue-lib-template. Changes will be overwritten! */
2
2
 
3
3
  import path from "node:path";
4
- import { fileURLToPath } from "node:url";
5
4
  import {
5
+ type Processor,
6
6
  Generator,
7
+ extractMarkdownProcessor,
7
8
  frontMatterFileReader,
9
+ manifestProcessor,
8
10
  vueFileReader,
9
11
  } from "@forsakringskassan/docs-generator";
10
12
  import pkg from "../package.json" with { type: "json" };
11
13
 
14
+ function teleportTarget(): Processor {
15
+ return {
16
+ after: "generate-docs",
17
+ name: "fkui:teleport",
18
+ async handler(context) {
19
+ context.addTemplateBlock("body:end", "teleport-target", {
20
+ filename: "partials/teleport.html",
21
+ });
22
+ },
23
+ };
24
+ }
25
+
12
26
  const docs = new Generator(import.meta.url, {
13
27
  site: { name: pkg.name, lang: "sv" },
14
28
  outputFolder: path.resolve(import.meta.dirname, "public"),
15
29
  exampleFolders: [path.resolve(import.meta.dirname, "../src")],
16
30
  setupPath: path.resolve(import.meta.dirname, "src/setup.ts"),
31
+ templateFolders: ["./templates"],
17
32
  vendor: [
18
33
  { package: "vue", alias: "vue/dist/vue.esm-bundler.js" },
19
34
  {
@@ -24,6 +39,13 @@ const docs = new Generator(import.meta.url, {
24
39
  "@fkui/logic",
25
40
  "@fkui/vue",
26
41
  ],
42
+ processors: [
43
+ extractMarkdownProcessor({
44
+ outputFolder: path.join(import.meta.dirname, "../dist/docs"),
45
+ }),
46
+ manifestProcessor(),
47
+ teleportTarget(),
48
+ ],
27
49
  });
28
50
 
29
51
  docs.compileScript("main", "./src/main.js", {
@@ -34,9 +56,8 @@ docs.compileStyle("main", "./src/main.scss", {
34
56
  appendTo: "head",
35
57
  });
36
58
 
37
- const styleUrl = import.meta.resolve(`../dist/esm/style.css`);
38
- const stylePath = fileURLToPath(styleUrl); // workaround for https://github.com/Forsakringskassan/docs-generator/issues/499
39
- docs.compileStyle("lib", stylePath, {
59
+ const styleUrl = new URL(import.meta.resolve(`../dist/esm/style.css`));
60
+ docs.compileStyle("lib", styleUrl, {
40
61
  appendTo: "head",
41
62
  });
42
63
 
@@ -44,9 +65,8 @@ docs.compileScript("mocks", "./src/bundle-mocks.mjs", {
44
65
  appendTo: "head",
45
66
  });
46
67
 
47
- const mswUrl = import.meta.resolve("msw/mockServiceWorker.js");
48
- const mswPath = fileURLToPath(mswUrl); // workaround for https://github.com/Forsakringskassan/docs-generator/issues/499
49
- docs.compileWorker("msw", mswPath);
68
+ const mswUrl = new URL(import.meta.resolve("msw/mockServiceWorker.js"));
69
+ docs.compileWorker("mock-service-worker", mswUrl);
50
70
 
51
71
  await docs.build([
52
72
  {
@@ -7,14 +7,14 @@
7
7
  "start": "http-server public"
8
8
  },
9
9
  "devDependencies": {
10
- "@fkui/icon-lib-default": "6.58.0",
11
- "@fkui/vue": "6.58.0",
10
+ "@fkui/icon-lib-default": "6.59.0",
11
+ "@fkui/vue": "6.59.0",
12
12
  "@forsakringskassan/apimock-express": "4.1.0",
13
- "@forsakringskassan/docs-generator": "3.10.1",
13
+ "@forsakringskassan/docs-generator": "3.12.0",
14
14
  "@tsconfig/node24": "24.0.5",
15
15
  "@tsconfig/recommended": "1.0.13",
16
16
  "http-server": "14.1.1",
17
17
  "msw": "2.15.0",
18
- "vue": "3.5.42"
18
+ "vue": "3.5.43"
19
19
  }
20
20
  }
@@ -11,12 +11,13 @@ const handlers = [
11
11
  const worker = setupWorker(...handlers);
12
12
  // eslint-disable-next-line no-undef -- technical debt
13
13
  const rootUrl = document.documentElement.dataset["rootUrl"];
14
- const url = `${rootUrl}/msw.js`;
14
+ const url = `${rootUrl}/mock-service-worker.js`;
15
15
 
16
16
  // Used in setup.ts
17
17
  // eslint-disable-next-line unicorn/no-global-object-property-assignment, no-undef -- technical debt
18
18
  window.bundleMocks = worker.start({
19
19
  serviceWorker: {
20
20
  url,
21
+ options: { type: "module" },
21
22
  },
22
23
  });
@@ -1,20 +1,8 @@
1
1
  @use "@forsakringskassan/docs-generator/style.css";
2
- @use "@fkui/theme-default" as theme with (
3
- $global: false
4
- );
5
- @use "@fkui/font-default" as font with (
6
- $global: false
7
- );
8
2
  @use "@fkui/design";
9
3
  @use "@fkui/design/lib/fonts.css";
10
4
  @use "@forsakringskassan/docs-live-example";
11
-
12
- @include font.font-face;
13
-
14
- :root {
15
- @include theme.auto;
16
- @include font.font-family;
17
- }
5
+ @use "../../src/theme";
18
6
 
19
7
  html,
20
8
  body {
@@ -0,0 +1 @@
1
+ <div id="teleport-target" class="user-theme"></div>
@@ -20,6 +20,13 @@
20
20
  "types": "./dist/types/index.d.ts",
21
21
  "import": "./dist/esm/index.esm.js"
22
22
  },
23
+ "./docs": {
24
+ "types": "./dist/docs/index.d.mts",
25
+ "import": "./dist/docs/index.mjs"
26
+ },
27
+ "./docs/links.json": {
28
+ "default": "./dist/docs/links.json"
29
+ },
23
30
  "./selectors": {
24
31
  "types": "./dist/types/selectors.d.ts",
25
32
  "import": "./dist/esm/selectors.esm.js"
@@ -57,7 +64,7 @@
57
64
  "postpublish": "release-postpublish",
58
65
  "start": "vite --",
59
66
  "start:docs": "npm start -w docs",
60
- "stylelint": "stylelint \"src/**/*.{css,scss}\"",
67
+ "stylelint": "stylelint \"src/**/*.{css,scss,vue}\"",
61
68
  "stylelint:fix": "npm run stylelint -- --fix",
62
69
  "pretest": "npm run lint",
63
70
  "test": "vitest run",
@@ -80,51 +87,51 @@
80
87
  "devDependencies": {
81
88
  "@babel/core": "7.29.7",
82
89
  "@babel/preset-env": "7.29.7",
83
- "@fkui/design": "6.58.0",
84
- "@fkui/font-default": "6.58.0",
85
- "@fkui/icon-lib-default": "6.58.0",
86
- "@fkui/logic": "6.58.0",
87
- "@fkui/test-utils": "6.58.0",
88
- "@fkui/theme-default": "6.58.0",
89
- "@fkui/vue": "6.58.0",
90
+ "@fkui/design": "6.59.0",
91
+ "@fkui/font-default": "6.59.0",
92
+ "@fkui/icon-lib-default": "6.59.0",
93
+ "@fkui/logic": "6.59.0",
94
+ "@fkui/test-utils": "6.59.0",
95
+ "@fkui/theme-default": "6.59.0",
96
+ "@fkui/vue": "6.59.0",
90
97
  "@forsakringskassan/apimock-express": "4.1.0",
91
98
  "@forsakringskassan/commitlint-config": "4.2.8",
92
99
  "@forsakringskassan/cypress-config": "1.10.0",
93
100
  "@forsakringskassan/cypress-visual-regression": "5.2.0",
94
- "@forsakringskassan/docs-generator": "3.10.1",
101
+ "@forsakringskassan/docs-generator": "3.12.0",
95
102
  "@forsakringskassan/docs-live-example": "3.0.2",
96
- "@forsakringskassan/eslint-config": "15.9.10",
97
- "@forsakringskassan/eslint-config-cli": "15.9.3",
98
- "@forsakringskassan/eslint-config-cypress": "15.9.9",
99
- "@forsakringskassan/eslint-config-jest": "15.9.2",
100
- "@forsakringskassan/eslint-config-typescript": "15.9.8",
101
- "@forsakringskassan/eslint-config-typescript-typeinfo": "15.9.8",
102
- "@forsakringskassan/eslint-config-vitest": "15.9.4",
103
- "@forsakringskassan/eslint-config-vue": "15.9.8",
104
- "@forsakringskassan/prettier-config": "3.7.8",
105
- "@forsakringskassan/stylelint-config": "3.4.6",
103
+ "@forsakringskassan/eslint-config": "15.11.0",
104
+ "@forsakringskassan/eslint-config-cli": "15.11.0",
105
+ "@forsakringskassan/eslint-config-cypress": "15.11.0",
106
+ "@forsakringskassan/eslint-config-jest": "15.11.0",
107
+ "@forsakringskassan/eslint-config-typescript": "15.11.0",
108
+ "@forsakringskassan/eslint-config-typescript-typeinfo": "15.11.0",
109
+ "@forsakringskassan/eslint-config-vitest": "15.11.0",
110
+ "@forsakringskassan/eslint-config-vue": "15.11.0",
111
+ "@forsakringskassan/prettier-config": "3.7.10",
112
+ "@forsakringskassan/stylelint-config": "3.5.0",
106
113
  "@forsakringskassan/vite-lib-config": "5.12.4",
107
114
  "@forsakringskassan/vitest-config-jsdom": "5.0.0",
108
- "@forsakringskassan/vue-lib-template": "1.2.11",
109
- "@html-validate/release-scripts": "7.6.11",
110
- "@types/node": "24.13.4",
115
+ "@forsakringskassan/vue-lib-template": "1.4.0",
116
+ "@html-validate/release-scripts": "7.6.12",
117
+ "@types/node": "24.13.6",
111
118
  "@typescript/native": "npm:typescript@7.0.2",
112
- "@vue/server-renderer": "3.5.42",
113
- "@vue/test-utils": "2.5.0",
114
- "cloneman": "1.24.1",
119
+ "@vue/server-renderer": "3.5.43",
120
+ "@vue/test-utils": "2.5.1",
121
+ "cloneman": "1.25.0",
115
122
  "core-js": "3.50.0",
116
- "cypress": "16.0.0",
117
- "html-validate": "11.15.0",
123
+ "cypress": "16.1.0",
124
+ "html-validate": "11.16.0",
118
125
  "html-validate-markdown": "6.0.0",
119
126
  "html-validate-vue": "9.3.1",
120
127
  "mocha-junit-reporter": "2.2.1",
121
- "npm-pkg-lint": "5.2.5",
128
+ "npm-pkg-lint": "5.3.1",
122
129
  "npm-run-all2": "9.0.3",
123
130
  "rimraf": "6.1.3",
124
131
  "typescript": "npm:@typescript/typescript6@6.0.2",
125
132
  "vite": "8.3.0",
126
- "vitest": "5.0.0",
127
- "vue": "3.5.42",
133
+ "vitest": "5.0.1",
134
+ "vue": "3.5.43",
128
135
  "vue-tsc": "3.3.11"
129
136
  },
130
137
  "peerDependencies": {
@@ -1,19 +1,7 @@
1
- @use "@fkui/theme-default" as theme with (
2
- $global: false
3
- );
4
- @use "@fkui/font-default" as font with (
5
- $global: false
6
- );
7
1
  @use "@fkui/design";
8
2
  @use "@fkui/design/lib/fonts.css";
9
3
  @use "@forsakringskassan/docs-live-example";
10
-
11
- @include font.font-face;
12
-
13
- :root {
14
- @include theme.auto;
15
- @include font.font-family;
16
- }
4
+ @use "theme";
17
5
 
18
6
  html,
19
7
  body {
@@ -0,0 +1,111 @@
1
+ import { TestPlugin, ValidationPlugin } from "@fkui/vue";
2
+ import { mount } from "@vue/test-utils";
3
+ import { beforeEach, expect, it, vi } from "vitest";
4
+ import FcCatInfoComponent from "../../components/guide/FcCatInfo/FcCatInfoComponent.vue";
5
+ import { catGetById } from "../../components/guide/FcCatInfo/cat-api";
6
+ import { cats } from "../../components/guide/FcCatInfo/cat-data";
7
+ import { FcCatInfoComponentSelectors } from "./FcCatInfoComponent.selectors";
8
+
9
+ vi.mock(import("../../components/guide/FcCatInfo/cat-api"));
10
+
11
+ beforeEach(() => {
12
+ vi.mocked(catGetById).mockResolvedValue(cats[0]);
13
+ });
14
+
15
+ it("should use the default selector", () => {
16
+ expect.assertions(2);
17
+ const wrapper = mount(FcCatInfoComponent, {
18
+ props: { catId: cats[0].id },
19
+ });
20
+ const { selector } = FcCatInfoComponentSelectors();
21
+
22
+ expect(selector).toBe(":scope");
23
+ expect(wrapper.find(selector).exists()).toBe(true);
24
+ });
25
+
26
+ it("should find the component with an explicit selector", () => {
27
+ expect.assertions(2);
28
+ const wrapper = mount(FcCatInfoComponent, {
29
+ attrs: { "data-test": "my-cat-info" },
30
+ props: { catId: cats[0].id },
31
+ });
32
+ const { selector } = FcCatInfoComponentSelectors(
33
+ '[data-test="my-cat-info"]',
34
+ );
35
+
36
+ expect(selector).toBe('[data-test="my-cat-info"]');
37
+ expect(wrapper.find(selector).exists()).toBe(true);
38
+ });
39
+
40
+ it("should find the loading container", () => {
41
+ expect.assertions(1);
42
+ const wrapper = mount(FcCatInfoComponent, {
43
+ props: { catId: cats[0].id },
44
+ });
45
+ const { loadingContainer } = FcCatInfoComponentSelectors();
46
+
47
+ expect(wrapper.get(loadingContainer()).text()).toContain(
48
+ "Hämtar kattinformation...",
49
+ );
50
+ });
51
+
52
+ it("should find all view mode elements", async () => {
53
+ expect.assertions(5);
54
+ const wrapper = mount(FcCatInfoComponent, {
55
+ props: { catId: cats[0].id, isEditable: false },
56
+ });
57
+ const selectors = FcCatInfoComponentSelectors();
58
+
59
+ await vi.waitFor(() => {
60
+ if (!wrapper.find(selectors.viewContainer()).exists()) {
61
+ throw new Error("View container has not been rendered yet");
62
+ }
63
+ });
64
+
65
+ const view = wrapper.get(selectors.viewContainer());
66
+ expect(view.text()).toContain(cats[0].name);
67
+ expect(view.text()).toContain(`${cats[0].age} år`);
68
+ expect(view.text()).toContain(cats[0].breed);
69
+ expect(view.text()).toContain(cats[0].color);
70
+ expect(view.text()).toContain(cats[0].favoriteFood);
71
+ });
72
+
73
+ it("should find all edit mode inputs", async () => {
74
+ expect.assertions(6);
75
+ const wrapper = mount(FcCatInfoComponent, {
76
+ props: { catId: cats[0].id, isEditable: true },
77
+ global: {
78
+ plugins: [TestPlugin, ValidationPlugin],
79
+ },
80
+ });
81
+ const selectors = FcCatInfoComponentSelectors();
82
+
83
+ await vi.waitFor(() => {
84
+ if (!wrapper.find(selectors.editContainer()).exists()) {
85
+ throw new Error("Edit container has not been rendered yet");
86
+ }
87
+ });
88
+
89
+ expect(wrapper.find(selectors.editContainer()).exists()).toBe(true);
90
+
91
+ expect(
92
+ wrapper.get<HTMLInputElement>(selectors.nameInput()).element.value,
93
+ ).toBe(cats[0].name);
94
+
95
+ expect(
96
+ wrapper.get<HTMLInputElement>(selectors.ageInput()).element.value,
97
+ ).toBe(cats[0].age.toString());
98
+
99
+ expect(
100
+ wrapper.get<HTMLInputElement>(selectors.breedInput()).element.value,
101
+ ).toBe(cats[0].breed);
102
+
103
+ expect(
104
+ wrapper.get<HTMLInputElement>(selectors.colorInput()).element.value,
105
+ ).toBe(cats[0].color);
106
+
107
+ expect(
108
+ wrapper.get<HTMLInputElement>(selectors.favoriteFoodInput()).element
109
+ .value,
110
+ ).toBe(cats[0].favoriteFood);
111
+ });
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Theme selection.
3
+ *
4
+ * This file can be customized to set theme and related features for:
5
+ *
6
+ * - Local builds (`npm start`)
7
+ * - Cypress component tests
8
+ * - Documentation
9
+ *
10
+ * It is not included in the production build.
11
+ *
12
+ * --- This notice must be kept ---
13
+ */
14
+
15
+ @use "@fkui/theme-default" as theme with (
16
+ $global: false
17
+ );
18
+
19
+ @use "@fkui/font-default" as font with (
20
+ $global: false
21
+ );
22
+
23
+ @include font.font-face;
24
+
25
+ :root {
26
+ @include theme.auto;
27
+ @include font.font-family;
28
+ }
package/index.js CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  const options = {
9
9
  ...packageJson.cloneman,
10
- fileHash: "c8696b477625b5dc20f234843d09017230ad3dbd962739042e8d0f82b0166b2a",
10
+ fileHash: "06d2b6a7e26a9d5b9df47375fe9fc0d856d30afd18da47362ccf24b6fa6c1468",
11
11
  filesDir: path.join(import.meta.dirname, "files"),
12
12
  hooksDir: path.join(import.meta.dirname, "hooks"),
13
13
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forsakringskassan/vue-lib-template",
3
- "version": "1.2.11",
3
+ "version": "1.4.0",
4
4
  "description": "Vue library template based on Cloneman",
5
5
  "keywords": [
6
6
  "template",
@@ -54,6 +54,7 @@
54
54
  "docs/src/main.js",
55
55
  "docs/src/main.scss",
56
56
  "docs/src/setup.ts",
57
+ "docs/templates/partials/teleport.html",
57
58
  "docs/tsconfig.json",
58
59
  "eslint.config.mjs",
59
60
  "etc/lib.api.md",
@@ -91,10 +92,12 @@
91
92
  "src/mocks/guide/cat-api.mock.mts",
92
93
  "src/mocks/guide/index.mts",
93
94
  "src/mocks/index.mts",
95
+ "src/selectors/guide/FcCatInfoComponent.selectors.spec.ts",
94
96
  "src/selectors/guide/FcCatInfoComponent.selectors.ts",
95
97
  "src/selectors/guide/index.ts",
96
98
  "src/selectors/index.ts",
97
99
  "src/style.scss",
100
+ "src/theme.scss",
98
101
  "src/vite-dev/app.vue",
99
102
  "tsconfig.cypress.json",
100
103
  "tsconfig.json",
@@ -141,6 +144,14 @@
141
144
  "tsconfig.selectors.json",
142
145
  "vite.config.mts"
143
146
  ],
147
+ "partiallyManagedFiles": [
148
+ {
149
+ "filename": "src/theme.scss",
150
+ "include": {
151
+ "above": "--- This notice must be kept ---"
152
+ }
153
+ }
154
+ ],
144
155
  "removeFiles": [
145
156
  "api-extractor.json",
146
157
  "index.html",