@dpa-id-components/dpa-shared-components 14.1.0 → 15.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 CHANGED
@@ -4,8 +4,7 @@ Collection of vue 3 components for usage across dpa projects.
4
4
 
5
5
  ## Pre-requirements
6
6
 
7
- This project requires a node version of 16.x or higher. For Node environments such as nuxt.js Node v20 or higher is
8
- required to prevent errors from the missing `crypto` library, which is needed for uuid.
7
+ This project requires a node version of 20.x or higher.
9
8
 
10
9
  You need to add and integrate the Inter font that can be found in `src/assets/fonts` to your project manually.
11
10
  An example how the CSS could look can be found in `src/tailwind/fonts.css`
@@ -56,35 +55,60 @@ The tailwind config is located at `./src/tailwind/tailwind.config.ts`.
56
55
  Please be aware that used plugins must be listed in the dependencies or the projects using the components have to
57
56
  install it.
58
57
 
59
- ### ESLint
58
+ ### Code quality linting with ESLint
60
59
 
61
- As of version `11.x.x`, this project is setup to use ESLint 9+ which no longer supports the `.eslintrc` configuration format. The [ESLint flat configuration file](https://eslint.org/docs/latest/use/configure/configuration-files) for this project is located at `./eslint.config.mjs`. The base ESLint configuration `./eslint.base.config.mjs` is exported in the published npm package as a [shareable config file](https://eslint.org/docs/latest/extend/shareable-configs) and can be used as the base configuration for host projects. Plugins and third party configs used in `./eslint.base.config.mjs` should be added to `dependencies` in `package.json`.
60
+ A shared ESLint configuration is provided at `@dpa-id-components/dpa-shared-components/eslintConfig`. Use it as a base configuration for code quality linting via ESLint.
62
61
 
63
- Please note the following when configuring the `eslint.config.mjs` file in a host project:
64
- - Project specific third-party plugins and config (updated accordingly for flat config support) should be added as `devDependencies`
65
- - Files to be included or ignored by ESLint should be configured here
66
- - Adjust the `lint` script in `package.json` to `"lint": "eslint . --fix"`
62
+ **Example ESLint configuration**:
67
63
 
68
- To use the shared ESLint config in a host project's `eslint.config.mjs`:
69
-
70
- ```JavaScript
71
- import sharedConfig from "@dpa-id-components/dpa-shared-components/eslint.config";
72
- // Other project specific plugins
73
- import pluginCypress from "eslint-plugin-cypress/flat";
64
+ ```js
65
+ import sharedConfig from "@dpa-id-components/dpa-shared-components/eslintConfig";
66
+ import { globalIgnores } from "eslint/config";
74
67
 
75
68
  export default [
76
- // Files to include or ignore under linting
77
69
  {
78
- files: ["**/*.js", "**/*.mjs", "**/*.ts", "**/*.mts", "**/*.vue"],
70
+ files: ["**/*.ts", "**/*.mts", "**/*.vue"],
79
71
  },
72
+
73
+ globalIgnores(["**/dist/", "**/coverage/"]),
74
+
75
+ ...sharedConfig,
76
+
80
77
  {
81
- ignores: ["_infrastructure/*", "**/dist/**", "**/coverage/**"],
78
+ files: ["**/*.vue"],
79
+ rules: {
80
+ "vue/no-undef-components": [
81
+ "error",
82
+ {
83
+ // Add globally-registered components here:
84
+ ignorePatterns: ["i18n-t", "RouterLink", "RouterView"],
85
+ },
86
+ ],
87
+ },
82
88
  },
83
- ...sharedConfig,
84
- pluginCypress.configs.recommended,
85
89
  ];
86
90
  ```
87
91
 
92
+ ### Code formatting with Prettier
93
+
94
+ A shared Prettier configuration is provided at `@dpa-id-components/dpa-shared-components/prettierConfig`. Use it as a base configuration for code formatting via Prettier.
95
+
96
+ **Example Prettier configuration**:
97
+
98
+ ```js
99
+ import config from "@dpa-id-components/dpa-shared-components/prettierConfig";
100
+
101
+ /**
102
+ * @see https://prettier.io/docs/configuration
103
+ * @type {import("prettier").Config}
104
+ */
105
+ export default {
106
+ ...config,
107
+ };
108
+ ```
109
+
110
+ You might also want to add a Prettier ignore file (e.g. for ignoring Markdown files) and set up Prettier in your code editor to automatically format on save.
111
+
88
112
  ## Add a component
89
113
 
90
114
  To add a new component please add at least the following files:
@@ -166,9 +190,9 @@ Custom optimizations right now are:
166
190
 
167
191
  ## Releasing
168
192
 
169
- To publish a new release just go to the Actions tab and click "Publish new version".
193
+ To publish a new release just go to the Actions tab and click "Publish new version".
170
194
  You are prompted with the option to choose which version to bump. Behind the scenes it just does one of those commands below.
171
- They will still work on their own but the #shared-components Slack channel won't be notified.
195
+ They will still work on their own but the #shared-components Slack channel won't be notified.
172
196
 
173
197
  ```shell
174
198
  npm run release:patch
@@ -8185,27 +8185,29 @@ const ys = /* @__PURE__ */ Qa(Wf, [["render", jf]]), Qf = ["data-testid"], Gf =
8185
8185
  },
8186
8186
  emits: ["click"],
8187
8187
  setup(e, { emit: t }) {
8188
- const n = t, r = e, a = F(() => {
8189
- const l = r.rounded ? "rounded-full" : "rounded-none";
8188
+ const n = t, r = e, a = F(
8189
+ () => typeof r.to == "string" ? "a" : r.to ? "RouterLink" : "button"
8190
+ ), o = F(() => {
8191
+ const i = r.rounded ? "rounded-full" : "rounded-none";
8190
8192
  switch (r.disabled ? "disabled" : r.color) {
8191
8193
  case "blue":
8192
- return `${l} text-white bg-blue-default hover:bg-blue-dark`;
8194
+ return `${i} text-white bg-blue-default hover:bg-blue-dark`;
8193
8195
  case "primary-green":
8194
- return `${l} text-white bg-green-primary hover:bg-night-green`;
8196
+ return `${i} text-white bg-green-primary hover:bg-night-green`;
8195
8197
  case "transparent":
8196
- return `${l} text-blue-default bg-transparent border-[1px] border-gray-300 hover:text-blue-dark hover:border-gray-700`;
8198
+ return `${i} text-blue-default bg-transparent border-[1px] border-gray-300 hover:text-blue-dark hover:border-gray-700`;
8197
8199
  case "white":
8198
- return `${l} text-blue-default bg-white border-[1px] border-gray-300 hover:text-blue-dark hover:border-gray-700`;
8200
+ return `${i} text-blue-default bg-white border-[1px] border-gray-300 hover:text-blue-dark hover:border-gray-700`;
8199
8201
  case "gray":
8200
- return `${l} text-white bg-gray-700 hover:bg-gray-800`;
8202
+ return `${i} text-white bg-gray-700 hover:bg-gray-800`;
8201
8203
  case "light-gray":
8202
- return `${l} text-gray-800 bg-gray-100`;
8204
+ return `${i} text-gray-800 bg-gray-100`;
8203
8205
  case "disabled":
8204
- return r.disabledVariant === "primary" ? `${l} text-gray-400 bg-gray-100 cursor-not-allowed` : `${l} text-gray-400 bg-white cursor-not-allowed border border-gray-400`;
8206
+ return r.disabledVariant === "primary" ? `${i} text-gray-400 bg-gray-100 cursor-not-allowed` : `${i} text-gray-400 bg-white cursor-not-allowed border border-gray-400`;
8205
8207
  default:
8206
- return `${l} text-white bg-blue-default hover:bg-blue-dark`;
8208
+ return `${i} text-white bg-blue-default hover:bg-blue-dark`;
8207
8209
  }
8208
- }), o = F(() => {
8210
+ }), s = F(() => {
8209
8211
  switch (r.size) {
8210
8212
  case "xs":
8211
8213
  return "h-6 text-xs";
@@ -8218,30 +8220,31 @@ const ys = /* @__PURE__ */ Qa(Wf, [["render", jf]]), Qf = ["data-testid"], Gf =
8218
8220
  default:
8219
8221
  return "h-10 text-base";
8220
8222
  }
8221
- }), s = F(() => r.size === "xs" ? "xs" : r.size === "small" ? "small" : "medium");
8222
- return (l, i) => (P(), xe(tn(l.to ? "RouterLink" : "button"), {
8223
+ }), l = F(() => r.size === "xs" ? "xs" : r.size === "small" ? "small" : "medium");
8224
+ return (i, u) => (P(), xe(tn(a.value), {
8223
8225
  class: oe(["UiButton focus-visible:outline-blue inline-flex items-center whitespace-nowrap font-medium leading-normal focus:outline-none", {
8224
- "px-4": l.size !== "xs",
8225
- "px-2": l.size === "xs",
8226
- [a.value]: !0,
8227
- [o.value]: !0
8226
+ "px-4": i.size !== "xs",
8227
+ "px-2": i.size === "xs",
8228
+ [o.value]: !0,
8229
+ [s.value]: !0
8228
8230
  }]),
8229
- to: l.to,
8230
- type: l.to ? void 0 : "button",
8231
- disabled: l.to ? void 0 : l.disabled,
8232
- onClick: i[0] || (i[0] = (u) => n("click"))
8231
+ to: a.value === "RouterLink" ? i.to : void 0,
8232
+ href: a.value === "a" ? i.to : void 0,
8233
+ type: a.value === "button" ? "button" : void 0,
8234
+ disabled: a.value === "button" ? i.disabled : void 0,
8235
+ onClick: u[0] || (u[0] = (c) => n("click"))
8233
8236
  }, {
8234
8237
  default: Te(() => [
8235
- l.iconName ? (P(), xe(wt, {
8238
+ i.iconName ? (P(), xe(wt, {
8236
8239
  key: 0,
8237
- name: l.iconName,
8238
- size: s.value,
8240
+ name: i.iconName,
8241
+ size: l.value,
8239
8242
  class: "mr-2"
8240
8243
  }, null, 8, ["name", "size"])) : j("", !0),
8241
- se(l.$slots, "default")
8244
+ se(i.$slots, "default")
8242
8245
  ]),
8243
8246
  _: 3
8244
- }, 8, ["class", "to", "type", "disabled"]));
8247
+ }, 8, ["class", "to", "href", "type", "disabled"]));
8245
8248
  }
8246
8249
  }), ap = {}, op = { class: "flex [&>*:first-child]:rounded-l-full [&>*:last-child]:rounded-r-full [&>*:last-child]:border-r [&>*]:border [&>*]:border-r-0 [&>*]:border-gray-300" };
8247
8250
  function sp(e, t) {