svelte-common 4.22.14 → 4.22.16

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
@@ -26,6 +26,8 @@ or the [live example](https://arlac77.github.io/components/svelte-common/example
26
26
 
27
27
  ### Table of Contents
28
28
 
29
+ * [AttributeDefinition](#attributedefinition)
30
+ * [Properties](#properties)
29
31
  * [tokens](#tokens)
30
32
  * [Parameters](#parameters)
31
33
  * [setAttribute](#setattribute)
@@ -47,6 +49,23 @@ or the [live example](https://arlac77.github.io/components/svelte-common/example
47
49
  * [keyPrefixStore](#keyprefixstore)
48
50
  * [Parameters](#parameters-9)
49
51
 
52
+ ## AttributeDefinition
53
+
54
+ Type: [Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)
55
+
56
+ ### Properties
57
+
58
+ * `type` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** 
59
+ * `writable` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** 
60
+ * `private` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** should the value be shown
61
+ * `depends` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?** name of an attribute we depend on
62
+ * `additionalAttributes` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>** extra attributes that are present in case our attribute is set
63
+ * `description` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
64
+ * `default` **any?** the default value
65
+ * `set` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** set the value
66
+ * `get` **[Function](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Statements/function)?** get the value can be used to calculate default values
67
+ * `env` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>)?** environment variable use to provide the value
68
+
50
69
  ## tokens
51
70
 
52
71
  Split property path into tokens
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-common",
3
- "version": "4.22.14",
3
+ "version": "4.22.16",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -34,24 +34,24 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "svelte-command": "^1.1.39",
37
- "svelte-entitlement": "^1.2.49"
37
+ "svelte-entitlement": "^1.2.50"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@semantic-release/commit-analyzer": "^9.0.2",
41
41
  "@semantic-release/exec": "^6.0.3",
42
42
  "@semantic-release/release-notes-generator": "^10.0.3",
43
- "@sveltejs/vite-plugin-svelte": "^2.0.4",
43
+ "@sveltejs/vite-plugin-svelte": "^2.1.1",
44
44
  "ava": "^5.2.0",
45
45
  "c8": "^7.13.0",
46
46
  "documentation": "^14.0.1",
47
- "mf-styling": "^1.7.52",
48
- "npm-pkgbuild": "^11.7.13",
47
+ "mf-styling": "^1.7.54",
48
+ "npm-pkgbuild": "^11.8.0",
49
49
  "semantic-release": "^21.0.1",
50
- "stylelint": "^15.5.0",
50
+ "stylelint": "^15.6.0",
51
51
  "stylelint-config-standard": "^33.0.0",
52
52
  "svelte": "^3.58.0",
53
53
  "testcafe": "^2.5.0",
54
- "vite": "^4.2.1"
54
+ "vite": "^4.3.3"
55
55
  },
56
56
  "optionalDependencies": {
57
57
  "mf-hosting-cloudflare": "^1.0.5",
package/src/attribute.mjs CHANGED
@@ -1,3 +1,18 @@
1
+ /**
2
+ * @typedef {Object} AttributeDefinition
3
+ *
4
+ * @property {string} type
5
+ * @property {boolean} writable
6
+ * @property {boolean} [private] should the value be shown
7
+ * @property {string} [depends] name of an attribute we depend on
8
+ * @property {string[]} additionalAttributes extra attributes that are present in case our attribute is set
9
+ * @property {string} description
10
+ * @property {any} [default] the default value
11
+ * @property {Function} [set] set the value
12
+ * @property {Function} [get] get the value can be used to calculate default values
13
+ * @property {string|string[]} [env] environment variable use to provide the value
14
+ */
15
+
1
16
  /**
2
17
  * Split property path into tokens
3
18
  * @param {string} string
@@ -114,7 +129,7 @@ export function setAttribute(object, name, value) {
114
129
  * @returns {any} value associated with the given property name
115
130
  */
116
131
  export function getAttribute(object, name) {
117
- if (object && object[name] !== undefined) {
132
+ if (object?.[name] !== undefined) {
118
133
  return object[name];
119
134
  }
120
135