@omicronenergy/oscd-scl-dialogs 0.0.9 → 0.0.10

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.
@@ -0,0 +1,171 @@
1
+ /* eslint-disable @typescript-eslint/no-explicit-any */
2
+ /**
3
+ * Copyright 2020 Google LLC
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ /**
18
+ * Converts a camelCase property name to a kebab-case attribute name.
19
+ */
20
+ function getAttributeName(propertyName) {
21
+ return propertyName
22
+ .replace(/[A-Z]+/g, sub => `-${sub}`)
23
+ .replace(/^-/, '')
24
+ .toLowerCase();
25
+ }
26
+ /**
27
+ * Defines that the target property should be exposed as an attribute, and
28
+ * that changes to the attribute should trigger a `notifyPropertyChanged`
29
+ * callback.
30
+ *
31
+ * @param attribute Override the attribute name to use. If ommitted, the
32
+ * property name is used (coverted from camelCase, to kebab-case).
33
+ */
34
+ export function NotifyAttribute(attribute) {
35
+ return function (target, key) {
36
+ const attr = attribute || getAttributeName(key);
37
+ if (target.addObservedAttribute) {
38
+ target.addObservedAttribute(attr);
39
+ }
40
+ Object.defineProperty(target, key, {
41
+ get() {
42
+ return this.getAttribute(attr);
43
+ },
44
+ set(value) {
45
+ if (value === null || value === undefined) {
46
+ this.removeAttribute(attr);
47
+ }
48
+ else {
49
+ this.setAttribute(attr, value);
50
+ }
51
+ this.notifyPropertyChanged(key);
52
+ },
53
+ enumerable: true,
54
+ configurable: true,
55
+ });
56
+ };
57
+ }
58
+ /**
59
+ * Defines that the target property should be exposed as boolean attribute, and
60
+ * that changes to the attribute should trigger a `notifyPropertyChanged`
61
+ * callback.
62
+ *
63
+ * @param attribute Override the attribute name to use. If ommitted, the
64
+ * property name is used (coverted from camelCase, to snake-case).
65
+ */
66
+ export function NotifyBooleanAttribute(attribute) {
67
+ return function (target, key) {
68
+ const attr = attribute || getAttributeName(key);
69
+ if (target.addObservedAttribute) {
70
+ target.addObservedAttribute(attr);
71
+ }
72
+ Object.defineProperty(target, key, {
73
+ get() {
74
+ return this.hasAttribute(attr);
75
+ },
76
+ set(value) {
77
+ if (value) {
78
+ this.setAttribute(attr, '');
79
+ }
80
+ else {
81
+ this.removeAttribute(attr);
82
+ }
83
+ this.notifyPropertyChanged(key);
84
+ },
85
+ enumerable: true,
86
+ configurable: true,
87
+ });
88
+ };
89
+ }
90
+ /**
91
+ * Defines that the target property should be exposed as numeric attribute, and
92
+ * that changes to the attribute should trigger a `notifyPropertyChanged`
93
+ * callback.
94
+ *
95
+ * @param attribute Override the attribute name to use. If ommitted, the
96
+ * property name is used (coverted from camelCase, to snake-case).
97
+ */
98
+ export function NotifyNumericAttribute(attribute) {
99
+ return function (target, key) {
100
+ const attr = attribute || getAttributeName(key);
101
+ if (target.addObservedAttribute) {
102
+ target.addObservedAttribute(attr);
103
+ }
104
+ Object.defineProperty(target, key, {
105
+ get() {
106
+ const value = Number(this.getAttribute(attr));
107
+ if (isNaN(value)) {
108
+ return undefined;
109
+ }
110
+ return value;
111
+ },
112
+ set(value) {
113
+ if (value === null || value === undefined) {
114
+ this.removeAttribute(attr);
115
+ }
116
+ else {
117
+ this.setAttribute(attr, value);
118
+ }
119
+ this.notifyPropertyChanged(key);
120
+ },
121
+ enumerable: true,
122
+ configurable: true,
123
+ });
124
+ };
125
+ }
126
+ /**
127
+ * Defines that the target property should trigger a `notifyPropertyChanged`
128
+ * callback when the property changes.
129
+ *
130
+ * @param attribute Expose the property as an attribute. Note that when
131
+ * attribute is specified, this method has the same behavior as
132
+ * `NotifyAttribute`.
133
+ */
134
+ export function Notify(attribute) {
135
+ if (attribute) {
136
+ return NotifyAttribute(attribute);
137
+ }
138
+ return function (target, key) {
139
+ Object.defineProperty(target, key, {
140
+ get() {
141
+ return this[`$__${key}`];
142
+ },
143
+ set(value) {
144
+ this[`$__${key}`] = value;
145
+ this.notifyPropertyChanged(key);
146
+ },
147
+ enumerable: true,
148
+ configurable: true,
149
+ });
150
+ };
151
+ }
152
+ /**
153
+ * Creates an alias for the given property with a getter and a setter.
154
+ *
155
+ * @param alias Name of the alias.
156
+ */
157
+ export function Alias(alias) {
158
+ return function (target, key) {
159
+ Object.defineProperty(target, alias, {
160
+ get() {
161
+ return this[key];
162
+ },
163
+ set(value) {
164
+ this[key] = value;
165
+ },
166
+ enumerable: true,
167
+ configurable: false,
168
+ });
169
+ };
170
+ }
171
+ //# sourceMappingURL=property-decorators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"property-decorators.js","sourceRoot":"","sources":["../../ace-editor/property-decorators.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;;;;;;;;;;;GAcG;AAWH;;GAEG;AACH,SAAS,gBAAgB,CAAC,YAAoB;IAC5C,OAAO,YAAY;SAChB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,CAAC,IAAI,GAAG,EAAE,CAAC;SACpC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC;SACjB,WAAW,EAAE,CAAC;AACnB,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAAC,SAAkB;IAChD,OAAO,UAAU,MAAkC,EAAE,GAAW;QAC9D,MAAM,IAAI,GAAG,SAAS,IAAI,gBAAgB,CAAC,GAAG,CAAC,CAAC;QAEhD,IAAI,MAAM,CAAC,oBAAoB,EAAE,CAAC;YAChC,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACpC,CAAC;QAED,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,GAAG,EAAE;YACjC,GAAG;gBACD,OAAO,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3B,CAAC;YACD,GAAG,CAAqB,KAAU;gBAChC,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC,GAAG,KAAK,CAAC;gBAC1B,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;YAClC,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,IAAI;SACnB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,OAAO,UAAU,MAAoB,EAAE,GAAW;QAChD,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE;YACnC,GAAG;gBACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;YACnB,CAAC;YACD,GAAG,CAAqB,KAAU;gBAChC,IAAI,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACpB,CAAC;YACD,UAAU,EAAE,IAAI;YAChB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * Copyright 2020 Google LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Describes notification target for the `Notify` decorators.\n */\ninterface NotifyTarget {\n notifyPropertyChanged: (name: string) => void;\n addObservedAttribute?: (name: string) => void;\n [key: string]: any;\n}\n\n/**\n * Converts a camelCase property name to a kebab-case attribute name.\n */\nfunction getAttributeName(propertyName: string): string {\n return propertyName\n .replace(/[A-Z]+/g, sub => `-${sub}`)\n .replace(/^-/, '')\n .toLowerCase();\n}\n\n/**\n * Defines that the target property should be exposed as an attribute, and\n * that changes to the attribute should trigger a `notifyPropertyChanged`\n * callback.\n *\n * @param attribute Override the attribute name to use. If ommitted, the\n * property name is used (coverted from camelCase, to kebab-case).\n */\nexport function NotifyAttribute(attribute?: string) {\n return function (target: NotifyTarget & HTMLElement, key: string): void {\n const attr = attribute || getAttributeName(key);\n\n if (target.addObservedAttribute) {\n target.addObservedAttribute(attr);\n }\n\n Object.defineProperty(target, key, {\n get(this: NotifyTarget & HTMLElement) {\n return this.getAttribute(attr);\n },\n set(this: NotifyTarget & HTMLElement, value: any) {\n if (value === null || value === undefined) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, value);\n }\n this.notifyPropertyChanged(key);\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n\n/**\n * Defines that the target property should be exposed as boolean attribute, and\n * that changes to the attribute should trigger a `notifyPropertyChanged`\n * callback.\n *\n * @param attribute Override the attribute name to use. If ommitted, the\n * property name is used (coverted from camelCase, to snake-case).\n */\nexport function NotifyBooleanAttribute(attribute?: string) {\n return function (target: NotifyTarget & HTMLElement, key: string): void {\n const attr = attribute || getAttributeName(key);\n\n if (target.addObservedAttribute) {\n target.addObservedAttribute(attr);\n }\n\n Object.defineProperty(target, key, {\n get(this: NotifyTarget & HTMLElement) {\n return this.hasAttribute(attr);\n },\n set(this: NotifyTarget & HTMLElement, value: any) {\n if (value) {\n this.setAttribute(attr, '');\n } else {\n this.removeAttribute(attr);\n }\n this.notifyPropertyChanged(key);\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n\n/**\n * Defines that the target property should be exposed as numeric attribute, and\n * that changes to the attribute should trigger a `notifyPropertyChanged`\n * callback.\n *\n * @param attribute Override the attribute name to use. If ommitted, the\n * property name is used (coverted from camelCase, to snake-case).\n */\nexport function NotifyNumericAttribute(attribute?: string) {\n return function (target: NotifyTarget & HTMLElement, key: string): void {\n const attr = attribute || getAttributeName(key);\n\n if (target.addObservedAttribute) {\n target.addObservedAttribute(attr);\n }\n\n Object.defineProperty(target, key, {\n get(this: NotifyTarget & HTMLElement) {\n const value = Number(this.getAttribute(attr));\n if (isNaN(value)) {\n return undefined;\n }\n return value;\n },\n set(this: NotifyTarget & HTMLElement, value: any) {\n if (value === null || value === undefined) {\n this.removeAttribute(attr);\n } else {\n this.setAttribute(attr, value);\n }\n this.notifyPropertyChanged(key);\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n\n/**\n * Defines that the target property should trigger a `notifyPropertyChanged`\n * callback when the property changes.\n *\n * @param attribute Expose the property as an attribute. Note that when\n * attribute is specified, this method has the same behavior as\n * `NotifyAttribute`.\n */\nexport function Notify(\n attribute?: string,\n): (target: NotifyTarget & HTMLElement, key: string) => void {\n if (attribute) {\n return NotifyAttribute(attribute);\n }\n\n return function (target: NotifyTarget, key: string): void {\n Object.defineProperty(target, key, {\n get(this: NotifyTarget) {\n return this[`$__${key}`];\n },\n set(this: NotifyTarget, value: any) {\n this[`$__${key}`] = value;\n this.notifyPropertyChanged(key);\n },\n enumerable: true,\n configurable: true,\n });\n };\n}\n\n/**\n * Creates an alias for the given property with a getter and a setter.\n *\n * @param alias Name of the alias.\n */\nexport function Alias(alias: string) {\n return function (target: NotifyTarget, key: string): void {\n Object.defineProperty(target, alias, {\n get(this: NotifyTarget) {\n return this[key];\n },\n set(this: NotifyTarget, value: any) {\n this[key] = value;\n },\n enumerable: true,\n configurable: false,\n });\n };\n}\n"]}
@@ -100,14 +100,16 @@ export function updateAction(element) {
100
100
  const ldName = ldNameAllowed
101
101
  ? getValue(inputs.find(i => i.label === 'ldName'))
102
102
  : null;
103
- if (ldName === element.getAttribute('ldName') &&
104
- desc === element.getAttribute('desc')) {
105
- return [];
106
- }
103
+ const attributes = {
104
+ ...(ldNameAllowed && ldName !== element.getAttribute('ldName')
105
+ ? { ldName }
106
+ : {}),
107
+ ...(desc !== element.getAttribute('desc') ? { desc } : {}),
108
+ };
107
109
  return [
108
110
  {
109
111
  element,
110
- attributes: { ldName, desc },
112
+ attributes,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,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC;SAC7B;QACD,OAAO,EAAE,MAAM,CACb,IAAI,EACJ,IAAI,EACJ,IAAI,EACJ,mBAAmB,CAAC,MAAM,CAAC,EAC3B,eAAe,CAAC,MAAM,CAAC,EACvB,KAAK,CACN;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,OAAgB;IAChD,OAAO;QACL,KAAK,EAAE,cAAc;QACrB,OAAO,EAAE;YACP,IAAI,EAAE,MAAM;YACZ,KAAK,EAAE,MAAM;YACb,MAAM,EAAE,YAAY,CAAC,OAAO,CAAC;SAC9B;QACD,OAAO,EAAE,MAAM,CACb,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,EAC5B,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,EAC9B,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,EAC5B,mBAAmB,CAAC,OAAO,CAAC,EAC5B,eAAe,CAAC,OAAO,CAAC,EACxB,IAAI,CACL;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { html, TemplateResult } from 'lit';\n\nimport { EditV2 } from '@openscd/oscd-api';\n\nimport { getReference } from '@openscd/scl-lib';\n\nimport {\n createElement,\n getValue,\n Wizard,\n WizardActor,\n WizardInputElement,\n} from '../foundation.js';\nimport { patterns } from './patterns.js';\nimport { SclTextField } from '@openenergytools/scl-text-field';\n\nexport function lDeviceNamePattern(): string {\n return (\n '[A-Za-z][0-9A-Za-z_]{0,2}|' +\n '[A-Za-z][0-9A-Za-z_]{4,63}|' +\n '[A-MO-Za-z][0-9A-Za-z_]{3}|' +\n 'N[0-9A-Za-np-z_][0-9A-Za-z_]{2}|' +\n 'No[0-9A-Za-mo-z_][0-9A-Za-z_]|' +\n 'Non[0-9A-Za-df-z_]'\n );\n}\n\nfunction ldNameIsAllowed(element: Element): boolean {\n return !!element.closest('IED')?.querySelector('Services > ConfLdName');\n}\n\nfunction reservedInstLDevice(currentElement: Element): string[] {\n const ied = currentElement.closest('IED');\n if (!ied) {\n return [];\n }\n\n return Array.from(\n ied.querySelectorAll(':scope > AccessPoint > Server > LDevice'),\n )\n .map(ld => ld.getAttribute('inst') ?? '')\n .filter(name => name !== currentElement.getAttribute('inst'));\n}\n\nfunction render(\n inst: string | null,\n ldName: string | null,\n desc: string | null,\n reservedInsts: string[],\n allowLdName: boolean,\n disableInst: boolean,\n): TemplateResult[] {\n const content = [\n allowLdName\n ? html`<scl-text-field\n label=\"ldName\"\n .value=${ldName}\n nullable\n supportingText=\"Logical device name\"\n validationMessage=\"Required\"\n dialogInitialFocus\n pattern=\"${lDeviceNamePattern()}\"\n ></scl-text-field>`\n : html`<scl-text-field\n label=\"ldName\"\n .value=${ldName}\n supportingText=\"IED doesn't support Functional Naming\"\n helperPersistent\n readOnly\n disabled\n ></scl-text-field>`,\n html`<scl-text-field\n label=\"desc\"\n .value=${desc}\n nullable\n supportingText=\"Logical device description\"\n pattern=\"${patterns.normalizedString}\"\n ></scl-text-field>`,\n html`<scl-text-field\n label=\"inst\"\n .value=${inst}\n ?disabled=${disableInst}\n required\n supportingText=\"Logical device inst\"\n pattern=\"${patterns.normalizedString}\"\n @input=${(e: Event) => {\n const input = e.target as SclTextField;\n const currentValue = getValue(input) ?? '';\n let customValidityMsg = '';\n if (reservedInsts.includes(currentValue)) {\n customValidityMsg = `\"${currentValue}\" is already in use`;\n }\n input.setCustomValidity(customValidityMsg);\n input.reportValidity();\n }}\n .reservedValues=${reservedInsts}\n ></scl-text-field>`,\n ];\n return content;\n}\n\nexport function createAction(parent: Element): WizardActor {\n return (inputs: WizardInputElement[]): EditV2[] => {\n const inst = getValue(inputs.find(i => i.label === 'inst')!)!;\n const ldNameAllowed = ldNameIsAllowed(parent);\n const ldName = ldNameAllowed\n ? getValue(inputs.find(i => i.label === 'ldName')!)\n : null;\n const desc = getValue(inputs.find(i => i.label === 'desc')!);\n const node = createElement(parent.ownerDocument, 'LDevice', {\n inst,\n ldName,\n desc,\n });\n\n return [\n {\n parent,\n node,\n reference: getReference(parent, 'LDevice'),\n },\n ];\n };\n}\n\nexport function updateAction(element: Element): WizardActor {\n return (inputs: WizardInputElement[]): EditV2[] => {\n const ldNameAllowed = ldNameIsAllowed(element);\n const desc = getValue(inputs.find(i => i.label === 'desc')!);\n const ldName = ldNameAllowed\n ? getValue(inputs.find(i => i.label === 'ldName')!)\n : null;\n\n if (\n ldName === element.getAttribute('ldName') &&\n desc === element.getAttribute('desc')\n ) {\n return [];\n }\n\n return [\n {\n element,\n attributes: { ldName, desc },\n },\n ];\n };\n}\n\nexport function createLDeviceWizard(parent: Element): Wizard {\n return {\n title: 'Add LDevice',\n primary: {\n icon: '',\n label: 'save',\n action: createAction(parent),\n },\n content: render(\n null,\n null,\n null,\n reservedInstLDevice(parent),\n ldNameIsAllowed(parent),\n false,\n ),\n };\n}\n\nexport function editLDeviceWizard(element: Element): Wizard {\n return {\n title: 'Edit LDevice',\n primary: {\n icon: 'edit',\n label: 'save',\n action: updateAction(element),\n },\n content: render(\n element.getAttribute('inst'),\n element.getAttribute('ldName'),\n element.getAttribute('desc'),\n reservedInstLDevice(element),\n ldNameIsAllowed(element),\n true,\n ),\n };\n}\n"]}
1
+ {"version":3,"file":"ldevice.js","sourceRoot":"","sources":["../../wizards/ldevice.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAkB,MAAM,KAAK,CAAC;AAI3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EACL,aAAa,EACb,QAAQ,GAIT,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGzC,MAAM,UAAU,kBAAkB;IAChC,OAAO,CACL,4BAA4B;QAC5B,6BAA6B;QAC7B,6BAA6B;QAC7B,kCAAkC;QAClC,gCAAgC;QAChC,oBAAoB,CACrB,CAAC;AACJ,CAAC;AAED,SAAS,eAAe,CAAC,OAAgB;IACvC,OAAO,CAAC,CAAC,OAA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,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,EAC5B,OAAO,CAAC,YAAY,CAAC,QAAQ,CAAC,EAC9B,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,EAC5B,mBAAmB,CAAC,OAAO,CAAC,EAC5B,eAAe,CAAC,OAAO,CAAC,EACxB,IAAI,CACL;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { html, TemplateResult } from 'lit';\n\nimport { EditV2 } from '@openscd/oscd-api';\n\nimport { getReference } from '@openscd/scl-lib';\n\nimport {\n createElement,\n getValue,\n Wizard,\n WizardActor,\n WizardInputElement,\n} from '../foundation.js';\nimport { patterns } from './patterns.js';\nimport { SclTextField } from '@openenergytools/scl-text-field';\n\nexport function lDeviceNamePattern(): string {\n return (\n '[A-Za-z][0-9A-Za-z_]{0,2}|' +\n '[A-Za-z][0-9A-Za-z_]{4,63}|' +\n '[A-MO-Za-z][0-9A-Za-z_]{3}|' +\n 'N[0-9A-Za-np-z_][0-9A-Za-z_]{2}|' +\n 'No[0-9A-Za-mo-z_][0-9A-Za-z_]|' +\n 'Non[0-9A-Za-df-z_]'\n );\n}\n\nfunction ldNameIsAllowed(element: Element): boolean {\n return !!element.closest('IED')?.querySelector('Services > ConfLdName');\n}\n\nfunction reservedInstLDevice(currentElement: Element): string[] {\n const ied = currentElement.closest('IED');\n if (!ied) {\n return [];\n }\n\n return Array.from(\n ied.querySelectorAll(':scope > AccessPoint > Server > LDevice'),\n )\n .map(ld => ld.getAttribute('inst') ?? '')\n .filter(name => name !== currentElement.getAttribute('inst'));\n}\n\nfunction render(\n inst: string | null,\n ldName: string | null,\n desc: string | null,\n reservedInsts: string[],\n allowLdName: boolean,\n disableInst: boolean,\n): TemplateResult[] {\n const content = [\n allowLdName\n ? html`<scl-text-field\n label=\"ldName\"\n .value=${ldName}\n nullable\n supportingText=\"Logical device name\"\n validationMessage=\"Required\"\n dialogInitialFocus\n pattern=\"${lDeviceNamePattern()}\"\n ></scl-text-field>`\n : html`<scl-text-field\n label=\"ldName\"\n .value=${ldName}\n supportingText=\"IED doesn't support Functional Naming\"\n helperPersistent\n readOnly\n disabled\n ></scl-text-field>`,\n html`<scl-text-field\n label=\"desc\"\n .value=${desc}\n nullable\n supportingText=\"Logical device description\"\n pattern=\"${patterns.normalizedString}\"\n ></scl-text-field>`,\n html`<scl-text-field\n label=\"inst\"\n .value=${inst}\n ?disabled=${disableInst}\n required\n supportingText=\"Logical device inst\"\n pattern=\"${patterns.normalizedString}\"\n @input=${(e: Event) => {\n const input = e.target as SclTextField;\n const currentValue = getValue(input) ?? '';\n let customValidityMsg = '';\n if (reservedInsts.includes(currentValue)) {\n customValidityMsg = `\"${currentValue}\" is already in use`;\n }\n input.setCustomValidity(customValidityMsg);\n input.reportValidity();\n }}\n .reservedValues=${reservedInsts}\n ></scl-text-field>`,\n ];\n return content;\n}\n\nexport function createAction(parent: Element): WizardActor {\n return (inputs: WizardInputElement[]): EditV2[] => {\n const inst = getValue(inputs.find(i => i.label === 'inst')!)!;\n const ldNameAllowed = ldNameIsAllowed(parent);\n const ldName = ldNameAllowed\n ? getValue(inputs.find(i => i.label === 'ldName')!)\n : null;\n const desc = getValue(inputs.find(i => i.label === 'desc')!);\n const node = createElement(parent.ownerDocument, 'LDevice', {\n inst,\n ldName,\n desc,\n });\n\n return [\n {\n parent,\n node,\n reference: getReference(parent, 'LDevice'),\n },\n ];\n };\n}\n\nexport function updateAction(element: Element): WizardActor {\n return (inputs: WizardInputElement[]): EditV2[] => {\n const ldNameAllowed = ldNameIsAllowed(element);\n const desc = getValue(inputs.find(i => i.label === 'desc')!);\n const ldName = ldNameAllowed\n ? getValue(inputs.find(i => i.label === 'ldName')!)\n : null;\n\n const attributes = {\n ...(ldNameAllowed && ldName !== element.getAttribute('ldName')\n ? { ldName }\n : {}),\n ...(desc !== element.getAttribute('desc') ? { desc } : {}),\n };\n\n return [\n {\n element,\n attributes,\n },\n ];\n };\n}\n\nexport function createLDeviceWizard(parent: Element): Wizard {\n return {\n title: 'Add LDevice',\n primary: {\n icon: '',\n label: 'save',\n action: createAction(parent),\n },\n content: render(\n null,\n null,\n null,\n reservedInstLDevice(parent),\n ldNameIsAllowed(parent),\n false,\n ),\n };\n}\n\nexport function editLDeviceWizard(element: Element): Wizard {\n return {\n title: 'Edit LDevice',\n primary: {\n icon: 'edit',\n label: 'save',\n action: updateAction(element),\n },\n content: render(\n element.getAttribute('inst'),\n element.getAttribute('ldName'),\n element.getAttribute('desc'),\n reservedInstLDevice(element),\n ldNameIsAllowed(element),\n true,\n ),\n };\n}\n"]}
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@omicronenergy/oscd-scl-dialogs",
3
3
  "description": "Provides a resuable dialog for adding and editing SCL elements in OpenSCD.",
4
4
  "displayName": "OpenSCD Edit Dialog",
5
- "version": "0.0.9",
5
+ "version": "0.0.10",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/OMICRONEnergyOSS/oscd-scl-dialogs.git"
@@ -97,7 +97,6 @@
97
97
  "@web/test-runner-commands": "0.9.0",
98
98
  "@web/test-runner-playwright": "0.11.1",
99
99
  "@web/test-runner-visual-regression": "0.10.0",
100
- "@webcomponents/scoped-custom-element-registry": "0.0.10",
101
100
  "concurrently": "^9.2.1",
102
101
  "eslint": "^9.39.1",
103
102
  "eslint-config-prettier": "^10.1.8",
@@ -117,6 +116,9 @@
117
116
  "typedoc": "^0.28.16",
118
117
  "typescript": "^5.9.3"
119
118
  },
119
+ "overrides": {
120
+ "playwright": "1.54.1"
121
+ },
120
122
  "customElements": "custom-elements.json",
121
123
  "prettier": {
122
124
  "singleQuote": true,