@ja-platform/parser-core 0.0.0-dev-20261019214152

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 (122) hide show
  1. package/dist/@types/AttributeParseEvent.d.ts +15 -0
  2. package/dist/@types/XMLParseEvent.d.ts +37 -0
  3. package/dist/@types/attributes/AttributeDefaults.d.ts +7 -0
  4. package/dist/@types/attributes/ConditionType.d.ts +10 -0
  5. package/dist/@types/attributes/V5Attribute.d.ts +103 -0
  6. package/dist/@types/attributes/V5BooleanAttribute.d.ts +19 -0
  7. package/dist/@types/attributes/V5ConstantBooleanAttribute.d.ts +15 -0
  8. package/dist/@types/attributes/V5ConstantTextAttribute.d.ts +15 -0
  9. package/dist/@types/attributes/V5ContentTextAttribute.d.ts +18 -0
  10. package/dist/@types/attributes/V5ExpressionAttribute.d.ts +17 -0
  11. package/dist/@types/attributes/V5FunctionAttribute.d.ts +9 -0
  12. package/dist/@types/attributes/V5ListAttribute.d.ts +21 -0
  13. package/dist/@types/attributes/V5NumberAttribute.d.ts +27 -0
  14. package/dist/@types/attributes/V5PathAttribue.d.ts +11 -0
  15. package/dist/@types/attributes/V5SetAttribute.d.ts +18 -0
  16. package/dist/@types/attributes/V5TextArrayAttribute.d.ts +15 -0
  17. package/dist/@types/attributes/V5TextAttribute.d.ts +20 -0
  18. package/dist/@types/attributes/index.d.ts +15 -0
  19. package/dist/@types/entities/V5AbstractEntity.d.ts +15 -0
  20. package/dist/@types/entities/V5CommonEntity.d.ts +28 -0
  21. package/dist/@types/entities/index.d.ts +2 -0
  22. package/dist/@types/events/V5EditorContext.d.ts +43 -0
  23. package/dist/@types/index.d.ts +36 -0
  24. package/dist/@types/nodes/V5ContentNode.d.ts +45 -0
  25. package/dist/@types/nodes/V5Node.d.ts +128 -0
  26. package/dist/@types/nodes/V5NodeAlternatives.d.ts +24 -0
  27. package/dist/@types/parsed/ParsedArrayNode.d.ts +28 -0
  28. package/dist/@types/parsed/ParsedAttribute.d.ts +28 -0
  29. package/dist/@types/parsed/ParsedContentNode.d.ts +13 -0
  30. package/dist/@types/parsed/ParsedDiagnostic.d.ts +12 -0
  31. package/dist/@types/parsed/ParsedNode.d.ts +103 -0
  32. package/dist/@types/parsed/ParsedNodeTypes.d.ts +64 -0
  33. package/dist/@types/parsed/index.d.ts +6 -0
  34. package/dist/@types/utils/types/valueOf.d.ts +3 -0
  35. package/dist/@types/values/AbstractValueProvider.d.ts +16 -0
  36. package/dist/@types/values/ConstantExpressionValueProvider.d.ts +9 -0
  37. package/dist/@types/values/ParsedNodeValues.d.ts +24 -0
  38. package/dist/@types/values/ParsedProviderValue.d.ts +31 -0
  39. package/dist/@types/values/ParsedValue.d.ts +38 -0
  40. package/dist/@types/values/ParserDefaultValueProvider.d.ts +9 -0
  41. package/dist/AttributeParseEvent.js +3 -0
  42. package/dist/AttributeParseEvent.js.map +1 -0
  43. package/dist/XMLParseEvent.js +3 -0
  44. package/dist/XMLParseEvent.js.map +1 -0
  45. package/dist/attributes/AttributeDefaults.js +15 -0
  46. package/dist/attributes/AttributeDefaults.js.map +1 -0
  47. package/dist/attributes/ConditionType.js +26 -0
  48. package/dist/attributes/ConditionType.js.map +1 -0
  49. package/dist/attributes/V5Attribute.js +162 -0
  50. package/dist/attributes/V5Attribute.js.map +1 -0
  51. package/dist/attributes/V5BooleanAttribute.js +45 -0
  52. package/dist/attributes/V5BooleanAttribute.js.map +1 -0
  53. package/dist/attributes/V5ConstantBooleanAttribute.js +22 -0
  54. package/dist/attributes/V5ConstantBooleanAttribute.js.map +1 -0
  55. package/dist/attributes/V5ConstantTextAttribute.js +22 -0
  56. package/dist/attributes/V5ConstantTextAttribute.js.map +1 -0
  57. package/dist/attributes/V5ContentTextAttribute.js +44 -0
  58. package/dist/attributes/V5ContentTextAttribute.js.map +1 -0
  59. package/dist/attributes/V5ExpressionAttribute.js +30 -0
  60. package/dist/attributes/V5ExpressionAttribute.js.map +1 -0
  61. package/dist/attributes/V5FunctionAttribute.js +14 -0
  62. package/dist/attributes/V5FunctionAttribute.js.map +1 -0
  63. package/dist/attributes/V5ListAttribute.js +38 -0
  64. package/dist/attributes/V5ListAttribute.js.map +1 -0
  65. package/dist/attributes/V5NumberAttribute.js +64 -0
  66. package/dist/attributes/V5NumberAttribute.js.map +1 -0
  67. package/dist/attributes/V5PathAttribue.js +15 -0
  68. package/dist/attributes/V5PathAttribue.js.map +1 -0
  69. package/dist/attributes/V5SetAttribute.js +27 -0
  70. package/dist/attributes/V5SetAttribute.js.map +1 -0
  71. package/dist/attributes/V5TextArrayAttribute.js +40 -0
  72. package/dist/attributes/V5TextArrayAttribute.js.map +1 -0
  73. package/dist/attributes/V5TextAttribute.js +52 -0
  74. package/dist/attributes/V5TextAttribute.js.map +1 -0
  75. package/dist/attributes/index.js +32 -0
  76. package/dist/attributes/index.js.map +1 -0
  77. package/dist/entities/V5AbstractEntity.js +17 -0
  78. package/dist/entities/V5AbstractEntity.js.map +1 -0
  79. package/dist/entities/V5CommonEntity.js +33 -0
  80. package/dist/entities/V5CommonEntity.js.map +1 -0
  81. package/dist/entities/index.js +19 -0
  82. package/dist/entities/index.js.map +1 -0
  83. package/dist/events/V5EditorContext.js +3 -0
  84. package/dist/events/V5EditorContext.js.map +1 -0
  85. package/dist/index.js +53 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/nodes/V5ContentNode.js +57 -0
  88. package/dist/nodes/V5ContentNode.js.map +1 -0
  89. package/dist/nodes/V5Node.js +277 -0
  90. package/dist/nodes/V5Node.js.map +1 -0
  91. package/dist/nodes/V5NodeAlternatives.js +119 -0
  92. package/dist/nodes/V5NodeAlternatives.js.map +1 -0
  93. package/dist/parsed/ParsedArrayNode.js +48 -0
  94. package/dist/parsed/ParsedArrayNode.js.map +1 -0
  95. package/dist/parsed/ParsedAttribute.js +41 -0
  96. package/dist/parsed/ParsedAttribute.js.map +1 -0
  97. package/dist/parsed/ParsedContentNode.js +19 -0
  98. package/dist/parsed/ParsedContentNode.js.map +1 -0
  99. package/dist/parsed/ParsedDiagnostic.js +21 -0
  100. package/dist/parsed/ParsedDiagnostic.js.map +1 -0
  101. package/dist/parsed/ParsedNode.js +240 -0
  102. package/dist/parsed/ParsedNode.js.map +1 -0
  103. package/dist/parsed/ParsedNodeTypes.js +3 -0
  104. package/dist/parsed/ParsedNodeTypes.js.map +1 -0
  105. package/dist/parsed/index.js +23 -0
  106. package/dist/parsed/index.js.map +1 -0
  107. package/dist/tsconfig.tsbuildinfo +1 -0
  108. package/dist/utils/types/valueOf.js +3 -0
  109. package/dist/utils/types/valueOf.js.map +1 -0
  110. package/dist/values/AbstractValueProvider.js +45 -0
  111. package/dist/values/AbstractValueProvider.js.map +1 -0
  112. package/dist/values/ConstantExpressionValueProvider.js +22 -0
  113. package/dist/values/ConstantExpressionValueProvider.js.map +1 -0
  114. package/dist/values/ParsedNodeValues.js +80 -0
  115. package/dist/values/ParsedNodeValues.js.map +1 -0
  116. package/dist/values/ParsedProviderValue.js +44 -0
  117. package/dist/values/ParsedProviderValue.js.map +1 -0
  118. package/dist/values/ParsedValue.js +73 -0
  119. package/dist/values/ParsedValue.js.map +1 -0
  120. package/dist/values/ParserDefaultValueProvider.js +16 -0
  121. package/dist/values/ParserDefaultValueProvider.js.map +1 -0
  122. package/package.json +38 -0
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.V5Attribute = exports.AttributeCategory = exports.ComponentSize = exports.DefaultValueKind = void 0;
37
+ const xml = __importStar(require("@journeyapps/common-xml"));
38
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
39
+ const parser_type_system_1 = require("@ja-platform/parser-type-system");
40
+ const V5CommonEntity_1 = require("../entities/V5CommonEntity");
41
+ const parsed_1 = require("../parsed");
42
+ var DefaultValueKind;
43
+ (function (DefaultValueKind) {
44
+ DefaultValueKind["COLOR"] = "color";
45
+ DefaultValueKind["SIZE"] = "size";
46
+ })(DefaultValueKind || (exports.DefaultValueKind = DefaultValueKind = {}));
47
+ var ComponentSize;
48
+ (function (ComponentSize) {
49
+ ComponentSize["SMALL"] = "small";
50
+ ComponentSize["MEDIUM"] = "medium";
51
+ ComponentSize["LARGE"] = "large";
52
+ })(ComponentSize || (exports.ComponentSize = ComponentSize = {}));
53
+ var AttributeCategory;
54
+ (function (AttributeCategory) {
55
+ AttributeCategory["THEME"] = "theme";
56
+ AttributeCategory["LAYOUT"] = "layout";
57
+ })(AttributeCategory || (exports.AttributeCategory = AttributeCategory = {}));
58
+ class V5Attribute extends V5CommonEntity_1.V5CommonEntity {
59
+ constructor(type, options) {
60
+ var _a, _b, _c, _d, _e;
61
+ super(Object.assign(Object.assign({}, options), { syntax: (_a = options.syntax) !== null && _a !== void 0 ? _a : new parser_expressions_1.CombinedParser([
62
+ new parser_expressions_1.FunctionExpressionParser(),
63
+ new parser_expressions_1.EvaluatedExpressionParser(),
64
+ new parser_expressions_1.ConstantExpressionParser((_b = options.valueType) !== null && _b !== void 0 ? _b : parser_type_system_1.textType)
65
+ ]), autoWatch: (_c = options.autoWatch) !== null && _c !== void 0 ? _c : true, configurable: (_d = options.configurable) !== null && _d !== void 0 ? _d : false, advanced: (_e = options.advanced) !== null && _e !== void 0 ? _e : false }));
66
+ this.type = type;
67
+ }
68
+ get key() {
69
+ return this.options.key;
70
+ }
71
+ get defaultValue() {
72
+ return this.options.defaultValue;
73
+ }
74
+ get name() {
75
+ return this.options.name;
76
+ }
77
+ normalizeValue(value) {
78
+ return (this.options.valueType ? this.options.valueType.parse(value) : value);
79
+ }
80
+ isEnclosedWith(checkerCB) {
81
+ let node = this.parent;
82
+ const checker = {
83
+ hasAttributeType(type) {
84
+ for (let attr of node.attributes) {
85
+ if (attr.constructor.name === type) {
86
+ return true;
87
+ }
88
+ }
89
+ }
90
+ };
91
+ // keep checking the parent
92
+ do {
93
+ if (checkerCB(checker)) {
94
+ return true;
95
+ }
96
+ node = node.parent;
97
+ } while (!!node);
98
+ return false;
99
+ }
100
+ serialize() {
101
+ return Object.assign(Object.assign({}, super.serialize()), { required: this.options.required, defaultValue: this.options.defaultValue, defaultValueKind: this.options.defaultValueKind, docs: this.options.docs, type: 'standard', advanced: !!this.options.advanced });
102
+ }
103
+ getEditorV5Syntax(helpers) {
104
+ return helpers.viewFunctionsSelection();
105
+ }
106
+ getParsedValue(event, _parseContext) {
107
+ var _a, _b;
108
+ var _c;
109
+ return ((_c = (_b = (_a = event.helper).parseAttributeExpression) === null || _b === void 0 ? void 0 : _b.call(_a, { attribute: this, source: event.input.value })) !== null && _c !== void 0 ? _c : this.options.syntax.parse(event.input.value));
110
+ }
111
+ stringify(value, parent) {
112
+ if (value == null) {
113
+ return {
114
+ isAttribute: true,
115
+ value: null
116
+ };
117
+ }
118
+ return {
119
+ isAttribute: true,
120
+ value: value.raw()
121
+ };
122
+ }
123
+ createParsedAttribute(options) {
124
+ return new parsed_1.ParsedAttribute(options);
125
+ }
126
+ getInput(event) {
127
+ var _a;
128
+ return {
129
+ value: event.element == null ? null : xml.getAttribute(event.element, this.options.name),
130
+ source: event.element == null ? null : ((_a = xml.attributeNode(event.element, this.options.name)) !== null && _a !== void 0 ? _a : event.element)
131
+ };
132
+ }
133
+ parse(event, parseContext = {}) {
134
+ const input = this.getInput(event);
135
+ let expression = null;
136
+ let failure;
137
+ try {
138
+ if (input.value != null) {
139
+ expression = this.getParsedValue(Object.assign(Object.assign({}, event), { input: Object.assign(Object.assign({}, input), { value: input.value }) }), parseContext);
140
+ }
141
+ }
142
+ catch (error) {
143
+ if (!(error instanceof SyntaxError)) {
144
+ throw error;
145
+ }
146
+ failure = error;
147
+ }
148
+ const parsedAttribute = this.createParsedAttribute({
149
+ definition: this,
150
+ event,
151
+ expression,
152
+ parseContext
153
+ });
154
+ if (failure) {
155
+ parsedAttribute.pushError({ message: failure.message, element: input.source });
156
+ }
157
+ return parsedAttribute;
158
+ }
159
+ }
160
+ exports.V5Attribute = V5Attribute;
161
+ V5Attribute.TYPE = 'base-attribute';
162
+ //# sourceMappingURL=V5Attribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5Attribute.js","sourceRoot":"","sources":["../../src/attributes/V5Attribute.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,MAAY,GAAG,oDAAgC;AAC/C,wEASyC;AACzC,wEAAiE;AACjE,+DAA2G;AAG3G,sCAAgF;AAIhF,IAAY,gBAGX;AAHD,WAAY,gBAAgB;IAC1B,mCAAe,CAAA;IACf,iCAAa,CAAA;AACf,CAAC,EAHW,gBAAgB,aAAhB,gBAAgB,GAAhB,gBAAgB,QAG3B;AAED,IAAY,a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,YAAY,CAAC,CAAC;YACxG,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,CAAC,KAAK,YAAY,WAAW,CAAC,EAAE,CAAC;gBACpC,MAAM,KAAK,CAAC;YACd,CAAC;YACD,OAAO,GAAG,KAAK,CAAC;QAClB,CAAC;QAED,MAAM,eAAe,GAAG,IAAI,CAAC,qBAAqB,CAAC;YACjD,UAAU,EAAE,IAAI;YAChB,KAAK;YACL,UAAU;YACV,YAAY;SACb,CAAC,CAAC;QAEH,IAAI,OAAO,EAAE,CAAC;YACZ,eAAe,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;QACjF,CAAC;QACD,OAAO,eAAe,CAAC;IACzB,CAAC;CACF;;AAtIQ,gBAAI,GAAG,gBAAgB,CAAC","sourcesContent":["import { AttributeParseEvent, AttributeParseInput } from '../AttributeParseEvent';\nimport { XMLParseEvent } from '../XMLParseEvent';\nimport * as xml from '@journeyapps/common-xml';\nimport {\n AbstractExpression,\n ExpressionParser,\n ConstantExpression,\n EvaluatedExpression,\n CombinedParser,\n FunctionExpressionParser,\n EvaluatedExpressionParser,\n ConstantExpressionParser\n} from '@ja-platform/parser-expressions';\nimport { Type, textType } from '@ja-platform/parser-type-system';\nimport { V5CommonEntity, V5CommonEntityListener, V5CommonEntityOptions } from '../entities/V5CommonEntity';\nimport { V5EditorHelpers } from '../events/V5EditorContext';\nimport { V5Node } from '../nodes/V5Node';\nimport { ParsedAttribute, ParsedAttributeOptions, ParsedNode } from '../parsed';\n\nexport type CombinedAttributeExpression = EvaluatedExpression | ConstantExpression<unknown>;\n\nexport enum DefaultValueKind {\n COLOR = 'color',\n SIZE = 'size'\n}\n\nexport enum ComponentSize {\n SMALL = 'small',\n MEDIUM = 'medium',\n LARGE = 'large'\n}\n\nexport type DefaultValueMap<T extends any> = { [k in string | number | symbol]: T };\n\nexport interface V5AttributeListener extends V5CommonEntityListener {}\n\nexport interface NodeChecker {\n hasAttributeType(type: string): boolean;\n}\n\nexport type DefaultValueType<T> = { [k in ComponentSize]: T } | T;\n\nexport enum AttributeCategory {\n THEME = 'theme',\n LAYOUT = 'layout'\n}\n\nexport interface V5AttributeOptions<DEFAULT = any, VALUE = unknown> extends V5CommonEntityOptions {\n /**\n * Accepted expression syntax. Defaults to prefixed code followed by constant text.\n */\n syntax?: ExpressionParser<AbstractExpression>;\n /**\n * Conversion and literal validation for the resolved attribute value.\n */\n valueType?: Type<VALUE>;\n required?: boolean;\n configurable?: boolean;\n advanced?: boolean;\n\n /**\n * Used to categorise sets of attributes for easier filtering\n */\n category?: AttributeCategory;\n fragmentNamespace?: string;\n\n defaultValue?: DEFAULT;\n /**\n * Select a variant contribution explicitly; omitted defaults are literal values.\n */\n defaultValueKind?: DefaultValueKind;\n /**\n * The interim value to use when the component attribute is still being evaluated (ie. setting up watches),\n * will fallback to `defaultValue` if not set.\n */\n loadingValue?: DEFAULT;\n /**\n * By default autowatch is enabled, disable it if the attribute relies on parameters such as $object\n * (used quite often in query-widget) which need to have watches setup in virtual tables\n * @deprecated\n */\n autoWatch?: boolean;\n /**\n * Indicates that the attribute is considered deprecated\n */\n deprecated?: boolean;\n /**\n * Ensures that functions returned by this attribute will be mapped to string identifiers in the runtime\n */\n mapGeneratedFunctions?: boolean;\n}\n\nexport interface V5AttributeGenerics<O extends V5AttributeOptions = V5AttributeOptions> {\n Options: O;\n Listener: V5AttributeListener;\n Value: any;\n NormalizedValue: unknown;\n}\n\nexport interface StringifyDirective {\n isAttribute: boolean;\n value: string | null;\n}\n\nexport class V5Attribute<G extends V5AttributeGenerics = V5AttributeGenerics> extends V5CommonEntity<G> {\n static TYPE = 'base-attribute';\n parent: V5Node<any>;\n type: string;\n\n constructor(type: string, options: G['Options']) {\n super({\n ...options,\n syntax:\n options.syntax ??\n new CombinedParser<CombinedAttributeExpression>([\n new FunctionExpressionParser(),\n new EvaluatedExpressionParser(),\n new ConstantExpressionParser(options.valueType ?? textType)\n ]),\n autoWatch: options.autoWatch ?? true,\n configurable: options.configurable ?? false,\n advanced: options.advanced ?? false\n });\n this.type = type;\n }\n\n get key() {\n return this.options.key;\n }\n\n get defaultValue() {\n return this.options.defaultValue;\n }\n\n get name() {\n return this.options.name;\n }\n\n normalizeValue(value: unknown): G['NormalizedValue'] {\n return (this.options.valueType ? this.options.valueType.parse(value) : value) as G['NormalizedValue'];\n }\n\n isEnclosedWith(checkerCB: (helper: NodeChecker) => boolean) {\n let node: V5Node = this.parent;\n\n const checker: NodeChecker = {\n hasAttributeType(type: string): boolean {\n for (let attr of node.attributes) {\n if (attr.constructor.name === type) {\n return true;\n }\n }\n }\n };\n // keep checking the parent\n do {\n if (checkerCB(checker)) {\n return true;\n }\n\n node = node.parent;\n } while (!!node);\n return false;\n }\n\n serialize(): any {\n return {\n ...super.serialize(),\n required: this.options.required,\n defaultValue: this.options.defaultValue,\n defaultValueKind: this.options.defaultValueKind,\n docs: this.options.docs,\n type: 'standard',\n advanced: !!this.options.advanced\n };\n }\n getEditorV5Syntax<T>(helpers: V5EditorHelpers<T>): T {\n return helpers.viewFunctionsSelection();\n }\n\n protected getParsedValue(event: AttributeParseEvent, _parseContext?: Record<string, any>): G['Value'] {\n return (\n event.helper.parseAttributeExpression?.({ attribute: this, source: event.input.value }) ??\n this.options.syntax.parse(event.input.value)\n );\n }\n\n stringify(value: G['Value'], parent: ParsedNode): StringifyDirective {\n if (value == null) {\n return {\n isAttribute: true,\n value: null\n };\n }\n\n return {\n isAttribute: true,\n value: value.raw()\n };\n }\n\n createParsedAttribute(options: ParsedAttributeOptions<G['Value'], this>): ParsedAttribute<G['Value'], this> {\n return new ParsedAttribute(options);\n }\n\n protected getInput(event: XMLParseEvent<ParsedNode>): AttributeParseInput {\n return {\n value: event.element == null ? null : xml.getAttribute(event.element, this.options.name),\n source: event.element == null ? null : (xml.attributeNode(event.element, this.options.name) ?? event.element)\n };\n }\n\n parse(event: XMLParseEvent<ParsedNode>, parseContext: Record<string, any> = {}) {\n const input = this.getInput(event);\n let expression: G['Value'] = null;\n let failure: SyntaxError;\n try {\n if (input.value != null) {\n expression = this.getParsedValue({ ...event, input: { ...input, value: input.value } }, parseContext);\n }\n } catch (error) {\n if (!(error instanceof SyntaxError)) {\n throw error;\n }\n failure = error;\n }\n\n const parsedAttribute = this.createParsedAttribute({\n definition: this,\n event,\n expression,\n parseContext\n });\n\n if (failure) {\n parsedAttribute.pushError({ message: failure.message, element: input.source });\n }\n return parsedAttribute;\n }\n}\n"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5BooleanAttribute = void 0;
4
+ const ConditionType_1 = require("./ConditionType");
5
+ const AttributeDefaults_1 = require("./AttributeDefaults");
6
+ const V5Attribute_1 = require("./V5Attribute");
7
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
8
+ const parser_type_system_1 = require("@ja-platform/parser-type-system");
9
+ /**
10
+ * For dealing with boolean attribute types such as `show-if` and `hide-if`
11
+ */
12
+ class V5BooleanAttribute extends V5Attribute_1.V5Attribute {
13
+ static isInstanceOf(attr) {
14
+ return attr.type === V5BooleanAttribute.TYPE;
15
+ }
16
+ constructor(options) {
17
+ var _a, _b, _c, _d;
18
+ const valueType = (_a = options.valueType) !== null && _a !== void 0 ? _a : new ConditionType_1.ConditionType();
19
+ super(V5BooleanAttribute.TYPE, Object.assign(Object.assign({}, options), { valueType, syntax: (_b = options.syntax) !== null && _b !== void 0 ? _b : new parser_expressions_1.CombinedParser([
20
+ new parser_expressions_1.FunctionExpressionParser(),
21
+ new parser_expressions_1.EvaluatedExpressionParser(),
22
+ new parser_expressions_1.ShorthandExpressionParser(),
23
+ new parser_expressions_1.ConstantExpressionParser((_c = options.valueType) !== null && _c !== void 0 ? _c : parser_type_system_1.booleanType)
24
+ ]), defaultValueKind: V5Attribute_1.DefaultValueKind.SIZE, configurable: (_d = options.configurable) !== null && _d !== void 0 ? _d : true }));
25
+ if (typeof this.options.defaultValue == 'boolean') {
26
+ this.options.defaultValue = (0, AttributeDefaults_1.fanDefaultValue)(this.options.defaultValue);
27
+ }
28
+ }
29
+ getEditorV5Syntax(helpers) {
30
+ return helpers.typedBindingOrFunction({
31
+ // Do not limit the type to boolean.
32
+ // Very often the developer wants to set something based on the
33
+ // presence of a non-boolean field.
34
+ types: null,
35
+ writable: false,
36
+ constants: true
37
+ }, this.options.defaultValue == null ? null : '' + this.options.defaultValue);
38
+ }
39
+ serialize() {
40
+ return Object.assign(Object.assign({}, super.serialize()), { type: 'boolean' });
41
+ }
42
+ }
43
+ exports.V5BooleanAttribute = V5BooleanAttribute;
44
+ V5BooleanAttribute.TYPE = 'boolean-attribute';
45
+ //# sourceMappingURL=V5BooleanAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5BooleanAttribute.js","sourceRoot":"","sources":["../../src/attributes/V5BooleanAttribute.ts"],"names":[],"mappings":";;;AAAA,mDAAgD;AAChD,2DAAsD;AACtD,+CAMuB;AAEvB,wEASyC;AACzC,wEAA8D;AAU9D;;GAEG;AACH,wBAAgC,SAAQ,yBAAuC;IAG7E,MAAM,CAAC,YAAY,CAAC,IAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,KAAK,kBAAkB,CAAC,IAAI,CAAC;IAC/C,CAAC;IAED,YAAY,OAA8C;;QACxD,MAAM,SAAS,SAAG,OAAO,CAAC,SAAS,mCAAI,IAAI,6BAAa,EAAE,CAAC;QAC3D,KAAK,CAAC,kBAAkB,CAAC,IAAI,kCACxB,OAAO,KACV,SAAS,EACT,MAAM,QACJ,OAAO,CAAC,MAAM,mCACd,IAAI,mCAAc,CAA4B;gBAC5C,IAAI,6CAAwB,EAAE;gBAC9B,IAAI,8CAAyB,EAAE;gBAC/B,IAAI,8CAAyB,EAAE;gBAC/B,IAAI,6CAAwB,OAAC,OAAO,CAAC,SAAS,mCAAI,gCAAW,CAAC;aAC/D,CAAC,EACJ,gBAAgB,EAAE,8BAAgB,CAAC,IAAI,EACvC,YAAY,QAAE,OAAO,CAAC,YAAY,mCAAI,IAAI,IAC1C,CAAC;QACH,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,SAAS,EAAE,CAAC;YAClD,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,IAAA,mCAAe,EAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED,iBAAiB,CAAI,OAA2B;QAC9C,OAAO,OAAO,CAAC,sBAAsB,CACnC;YACE,oCAAoC;YACpC,+DAA+D;YAC/D,mCAAmC;YACnC,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,IAAI;SAChB,EACD,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,CAC1E,CAAC;IACJ,CAAC;IAED,SAAS;QACP,uCACK,KAAK,CAAC,SAAS,EAAE,KACpB,IAAI,EAAE,SAAS,IACf;IACJ,CAAC;CACF;;AA/CQ,uBAAI,GAAG,mBAAmB,CAAC","sourcesContent":["import { ConditionType } from './ConditionType';\nimport { fanDefaultValue } from './AttributeDefaults';\nimport {\n DefaultValueKind,\n V5Attribute,\n V5AttributeOptions,\n V5AttributeGenerics,\n DefaultValueType\n} from './V5Attribute';\nimport { V5EditorHelpers } from '../events/V5EditorContext';\nimport {\n EvaluatedExpression,\n ConstantExpression,\n ShorthandExpression,\n CombinedParser,\n FunctionExpressionParser,\n EvaluatedExpressionParser,\n ConstantExpressionParser,\n ShorthandExpressionParser\n} from '@ja-platform/parser-expressions';\nimport { booleanType } from '@ja-platform/parser-type-system';\n\nexport type CombinedBooleanExpression = EvaluatedExpression | ConstantExpression<boolean> | ShorthandExpression;\n\nexport interface V5BooleanAttributeGenerics extends V5AttributeGenerics {\n Options: V5AttributeOptions<DefaultValueType<boolean>, boolean>;\n Value: CombinedBooleanExpression | null;\n NormalizedValue: boolean;\n}\n\n/**\n * For dealing with boolean attribute types such as `show-if` and `hide-if`\n */\nexport class V5BooleanAttribute extends V5Attribute<V5BooleanAttributeGenerics> {\n static TYPE = 'boolean-attribute';\n\n static isInstanceOf(attr: V5Attribute): attr is V5BooleanAttribute {\n return attr.type === V5BooleanAttribute.TYPE;\n }\n\n constructor(options: V5BooleanAttributeGenerics['Options']) {\n const valueType = options.valueType ?? new ConditionType();\n super(V5BooleanAttribute.TYPE, {\n ...options,\n valueType,\n syntax:\n options.syntax ??\n new CombinedParser<CombinedBooleanExpression>([\n new FunctionExpressionParser(),\n new EvaluatedExpressionParser(),\n new ShorthandExpressionParser(),\n new ConstantExpressionParser(options.valueType ?? booleanType)\n ]),\n defaultValueKind: DefaultValueKind.SIZE,\n configurable: options.configurable ?? true\n });\n if (typeof this.options.defaultValue == 'boolean') {\n this.options.defaultValue = fanDefaultValue(this.options.defaultValue);\n }\n }\n\n getEditorV5Syntax<T>(helpers: V5EditorHelpers<T>): T {\n return helpers.typedBindingOrFunction(\n {\n // Do not limit the type to boolean.\n // Very often the developer wants to set something based on the\n // presence of a non-boolean field.\n types: null,\n writable: false,\n constants: true\n },\n this.options.defaultValue == null ? null : '' + this.options.defaultValue\n );\n }\n\n serialize(): any {\n return {\n ...super.serialize(),\n type: 'boolean'\n };\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5ConstantBooleanAttribute = void 0;
4
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
5
+ const parser_type_system_1 = require("@ja-platform/parser-type-system");
6
+ const V5Attribute_1 = require("./V5Attribute");
7
+ /**
8
+ * A boolean attribute that accepts constant text only.
9
+ */
10
+ class V5ConstantBooleanAttribute extends V5Attribute_1.V5Attribute {
11
+ static isInstanceOf(attr) {
12
+ return attr.type === V5ConstantBooleanAttribute.TYPE;
13
+ }
14
+ constructor(options) {
15
+ var _a;
16
+ const valueType = (_a = options.valueType) !== null && _a !== void 0 ? _a : parser_type_system_1.booleanType;
17
+ super(V5ConstantBooleanAttribute.TYPE, Object.assign(Object.assign({}, options), { syntax: new parser_expressions_1.ConstantExpressionParser(valueType), valueType }));
18
+ }
19
+ }
20
+ exports.V5ConstantBooleanAttribute = V5ConstantBooleanAttribute;
21
+ V5ConstantBooleanAttribute.TYPE = 'constant-boolean-attribute';
22
+ //# sourceMappingURL=V5ConstantBooleanAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5ConstantBooleanAttribute.js","sourceRoot":"","sources":["../../src/attributes/V5ConstantBooleanAttribute.ts"],"names":[],"mappings":";;;AAAA,wEAA+F;AAC/F,wEAA8D;AAC9D,+CAAqF;AAQrF;;GAEG;AACH,gCAAwC,SAAQ,yBAA+C;IAG7F,MAAM,CAAC,YAAY,CAAC,IAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,KAAK,0BAA0B,CAAC,IAAI,CAAC;IACvD,CAAC;IAED,YAAY,OAAsD;;QAChE,MAAM,SAAS,SAAG,OAAO,CAAC,SAAS,mCAAI,gCAAW,CAAC;QACnD,KAAK,CAAC,0BAA0B,CAAC,IAAI,kCAChC,OAAO,KACV,MAAM,EAAE,IAAI,6CAAwB,CAAC,SAAS,CAAC,EAC/C,SAAS,IACT,CAAC;IACL,CAAC;CACF;;AAdQ,+BAAI,GAAG,4BAA4B,CAAC","sourcesContent":["import { ConstantExpression, ConstantExpressionParser } from '@ja-platform/parser-expressions';\nimport { booleanType } from '@ja-platform/parser-type-system';\nimport { V5Attribute, V5AttributeGenerics, V5AttributeOptions } from './V5Attribute';\n\nexport interface V5ConstantBooleanAttributeGenerics extends V5AttributeGenerics {\n Options: V5AttributeOptions<boolean, boolean>;\n Value: ConstantExpression<boolean> | null;\n NormalizedValue: boolean;\n}\n\n/**\n * A boolean attribute that accepts constant text only.\n */\nexport class V5ConstantBooleanAttribute extends V5Attribute<V5ConstantBooleanAttributeGenerics> {\n static TYPE = 'constant-boolean-attribute';\n\n static isInstanceOf(attr: V5Attribute): attr is V5ConstantBooleanAttribute {\n return attr.type === V5ConstantBooleanAttribute.TYPE;\n }\n\n constructor(options: V5ConstantBooleanAttributeGenerics['Options']) {\n const valueType = options.valueType ?? booleanType;\n super(V5ConstantBooleanAttribute.TYPE, {\n ...options,\n syntax: new ConstantExpressionParser(valueType),\n valueType\n });\n }\n}\n"]}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5ConstantTextAttribute = void 0;
4
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
5
+ const parser_type_system_1 = require("@ja-platform/parser-type-system");
6
+ const V5Attribute_1 = require("./V5Attribute");
7
+ /**
8
+ * A string attribute that accepts constant text only.
9
+ */
10
+ class V5ConstantTextAttribute extends V5Attribute_1.V5Attribute {
11
+ static isInstanceOf(attr) {
12
+ return attr.type === V5ConstantTextAttribute.TYPE;
13
+ }
14
+ constructor(options) {
15
+ var _a;
16
+ const valueType = (_a = options.valueType) !== null && _a !== void 0 ? _a : parser_type_system_1.textType;
17
+ super(V5ConstantTextAttribute.TYPE, Object.assign(Object.assign({}, options), { syntax: new parser_expressions_1.ConstantExpressionParser(valueType), valueType }));
18
+ }
19
+ }
20
+ exports.V5ConstantTextAttribute = V5ConstantTextAttribute;
21
+ V5ConstantTextAttribute.TYPE = 'constant-text-attribute';
22
+ //# sourceMappingURL=V5ConstantTextAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5ConstantTextAttribute.js","sourceRoot":"","sources":["../../src/attributes/V5ConstantTextAttribute.ts"],"names":[],"mappings":";;;AAAA,wEAA+F;AAC/F,wEAA2D;AAC3D,+CAAqF;AAQrF;;GAEG;AACH,6BAAqC,SAAQ,yBAA4C;IAGvF,MAAM,CAAC,YAAY,CAAC,IAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,KAAK,uBAAuB,CAAC,IAAI,CAAC;IACpD,CAAC;IAED,YAAY,OAAmD;;QAC7D,MAAM,SAAS,SAAG,OAAO,CAAC,SAAS,mCAAI,6BAAQ,CAAC;QAChD,KAAK,CAAC,uBAAuB,CAAC,IAAI,kCAC7B,OAAO,KACV,MAAM,EAAE,IAAI,6CAAwB,CAAC,SAAS,CAAC,EAC/C,SAAS,IACT,CAAC;IACL,CAAC;CACF;;AAdQ,4BAAI,GAAG,yBAAyB,CAAC","sourcesContent":["import { ConstantExpression, ConstantExpressionParser } from '@ja-platform/parser-expressions';\nimport { textType } from '@ja-platform/parser-type-system';\nimport { V5Attribute, V5AttributeGenerics, V5AttributeOptions } from './V5Attribute';\n\nexport interface V5ConstantTextAttributeGenerics extends V5AttributeGenerics {\n Options: V5AttributeOptions<string, string>;\n Value: ConstantExpression | null;\n NormalizedValue: string;\n}\n\n/**\n * A string attribute that accepts constant text only.\n */\nexport class V5ConstantTextAttribute extends V5Attribute<V5ConstantTextAttributeGenerics> {\n static TYPE = 'constant-text-attribute';\n\n static isInstanceOf(attr: V5Attribute): attr is V5ConstantTextAttribute {\n return attr.type === V5ConstantTextAttribute.TYPE;\n }\n\n constructor(options: V5ConstantTextAttributeGenerics['Options']) {\n const valueType = options.valueType ?? textType;\n super(V5ConstantTextAttribute.TYPE, {\n ...options,\n syntax: new ConstantExpressionParser(valueType),\n valueType\n });\n }\n}\n"]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5ContentTextAttribute = void 0;
4
+ const V5TextAttribute_1 = require("./V5TextAttribute");
5
+ const common_xml_1 = require("@journeyapps/common-xml");
6
+ class V5ContentTextAttribute extends V5TextAttribute_1.V5TextAttribute {
7
+ constructor(options) {
8
+ super(options);
9
+ this.type = V5ContentTextAttribute.TYPE;
10
+ }
11
+ getInput(event) {
12
+ var _a;
13
+ var _b;
14
+ const input = super.getInput(event);
15
+ if (input.value != null) {
16
+ return input;
17
+ }
18
+ return { value: (_b = (_a = event.element) === null || _a === void 0 ? void 0 : _a.textContent) !== null && _b !== void 0 ? _b : null, source: event.element };
19
+ }
20
+ getParsedValue(event, parseContext = {}) {
21
+ const expression = super.getParsedValue(event, parseContext);
22
+ if ((0, common_xml_1.getAttribute)(event.element, this.options.name) == null) {
23
+ parseContext['_content'] = expression;
24
+ }
25
+ return expression;
26
+ }
27
+ validateInput(event, expression, parseContext) {
28
+ var _a, _b;
29
+ if ((0, common_xml_1.getAttribute)(event.element, this.options.name) != null) {
30
+ super.validateInput(event, expression, parseContext);
31
+ return;
32
+ }
33
+ (_b = (_a = event.helper).validateFormatContent) === null || _b === void 0 ? void 0 : _b.call(_a, { element: event.element, scope: event.scope, expression });
34
+ }
35
+ stringify(value, parent) {
36
+ return Object.assign(Object.assign({}, super.stringify(value, parent)), { isAttribute: !parent.content() });
37
+ }
38
+ serialize() {
39
+ return Object.assign(Object.assign({}, super.serialize()), { type: 'content-text' });
40
+ }
41
+ }
42
+ exports.V5ContentTextAttribute = V5ContentTextAttribute;
43
+ V5ContentTextAttribute.TYPE = 'content-text-attribute';
44
+ //# sourceMappingURL=V5ContentTextAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5ContentTextAttribute.js","sourceRoot":"","sources":["../../src/attributes/V5ContentTextAttribute.ts"],"names":[],"mappings":";;;AACA,uDAK2B;AAI3B,wDAAuD;AAIvD,4BAAoC,SAAQ,iCAI3C;IAGC,YAAY,OAAsC;QAChD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC,IAAI,CAAC;IAC1C,CAAC;IAES,QAAQ,CAAC,KAAgC;;;QACjD,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACpC,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC;QACf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import { AttributeParseEvent, AttributeParseInput } from '../AttributeParseEvent';\nimport {\n CombinedTextExpression,\n V5TextAttribute,\n V5TextAttributeGenerics,\n V5TextAttributeOptions\n} from './V5TextAttribute';\nimport { StringifyDirective } from './V5Attribute';\nimport { ParsedNode } from '../parsed';\nimport { XMLParseEvent } from '../XMLParseEvent';\nimport { getAttribute } from '@journeyapps/common-xml';\n\nexport interface V5ContextTextAttributeOptions extends Omit<V5TextAttributeOptions, 'configurable'> {}\n\nexport class V5ContentTextAttribute extends V5TextAttribute<\n V5TextAttributeGenerics & {\n Options: V5ContextTextAttributeOptions;\n }\n> {\n static TYPE = 'content-text-attribute';\n\n constructor(options: V5ContextTextAttributeOptions) {\n super(options);\n this.type = V5ContentTextAttribute.TYPE;\n }\n\n protected getInput(event: XMLParseEvent<ParsedNode>): AttributeParseInput {\n const input = super.getInput(event);\n if (input.value != null) {\n return input;\n }\n return { value: event.element?.textContent ?? null, source: event.element };\n }\n\n protected getParsedValue(\n event: AttributeParseEvent,\n parseContext: Record<string, any> = {}\n ): CombinedTextExpression | null {\n const expression = super.getParsedValue(event, parseContext);\n if (getAttribute(event.element, this.options.name) == null) {\n parseContext['_content'] = expression;\n }\n return expression;\n }\n\n protected validateInput(\n event: AttributeParseEvent,\n expression: CombinedTextExpression,\n parseContext: Record<string, any>\n ): void {\n if (getAttribute(event.element, this.options.name) != null) {\n super.validateInput(event, expression, parseContext);\n return;\n }\n event.helper.validateFormatContent?.({ element: event.element, scope: event.scope, expression });\n }\n\n stringify(value: V5TextAttributeGenerics['Value'], parent: ParsedNode): StringifyDirective {\n return {\n ...super.stringify(value, parent),\n isAttribute: !parent.content()\n };\n }\n\n serialize(): any {\n return {\n ...super.serialize(),\n type: 'content-text'\n };\n }\n}\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5ExpressionAttribute = void 0;
4
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
5
+ const V5Attribute_1 = require("./V5Attribute");
6
+ /**
7
+ * An attribute containing a reference or explicitly evaluated code.
8
+ * Examples include `user.name`, `$object.quantity` and `$:calculateTotal()`.
9
+ * Bare identifiers always represent references; there is no literal text fallback.
10
+ */
11
+ class V5ExpressionAttribute extends V5Attribute_1.V5Attribute {
12
+ constructor(options) {
13
+ var _a;
14
+ super(V5ExpressionAttribute.TYPE, Object.assign(Object.assign({}, options), { syntax: (_a = options.syntax) !== null && _a !== void 0 ? _a : new parser_expressions_1.CombinedParser([
15
+ new parser_expressions_1.FunctionExpressionParser(),
16
+ new parser_expressions_1.EvaluatedExpressionParser(),
17
+ new parser_expressions_1.ShorthandExpressionParser()
18
+ ]) }));
19
+ }
20
+ getEditorV5Syntax(helpers) {
21
+ return helpers.typedBindingOrFunction({
22
+ types: null,
23
+ writable: false,
24
+ constants: false
25
+ });
26
+ }
27
+ }
28
+ exports.V5ExpressionAttribute = V5ExpressionAttribute;
29
+ V5ExpressionAttribute.TYPE = 'expression-attribute';
30
+ //# sourceMappingURL=V5ExpressionAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5ExpressionAttribute.js","sourceRoot":"","sources":["../../src/attributes/V5ExpressionAttribute.ts"],"names":[],"mappings":";;;AAAA,wEAOyC;AAEzC,+CAAiE;AAQjE;;;;GAIG;AACH,2BAAmC,SAAQ,yBAA0C;IAGnF,YAAY,OAAiD;;QAC3D,KAAK,CAAC,qBAAqB,CAAC,IAAI,kCAC3B,OAAO,KACV,MAAM,QACJ,OAAO,CAAC,MAAM,mCACd,IAAI,mCAAc,CAAqB;gBACrC,IAAI,6CAAwB,EAAE;gBAC9B,IAAI,8CAAyB,EAAE;gBAC/B,IAAI,8CAAyB,EAAE;aAChC,CAAC,IACJ,CAAC;IACL,CAAC;IAED,iBAAiB,CAAI,OAA2B;QAC9C,OAAO,OAAO,CAAC,sBAAsB,CAAC;YACpC,KAAK,EAAE,IAAI;YACX,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;IACL,CAAC;CACF;;AAtBQ,0BAAI,GAAG,sBAAsB,CAAC","sourcesContent":["import {\n CombinedParser,\n EvaluatedExpression,\n EvaluatedExpressionParser,\n FunctionExpressionParser,\n ShorthandExpression,\n ShorthandExpressionParser\n} from '@ja-platform/parser-expressions';\nimport { V5EditorHelpers } from '../events/V5EditorContext';\nimport { V5Attribute, V5AttributeGenerics } from './V5Attribute';\n\nexport type CombinedExpression = EvaluatedExpression | ShorthandExpression;\n\nexport interface V5ExpressionAttributeGenerics extends V5AttributeGenerics {\n Value: CombinedExpression | null;\n}\n\n/**\n * An attribute containing a reference or explicitly evaluated code.\n * Examples include `user.name`, `$object.quantity` and `$:calculateTotal()`.\n * Bare identifiers always represent references; there is no literal text fallback.\n */\nexport class V5ExpressionAttribute extends V5Attribute<V5ExpressionAttributeGenerics> {\n static TYPE = 'expression-attribute';\n\n constructor(options: V5ExpressionAttributeGenerics['Options']) {\n super(V5ExpressionAttribute.TYPE, {\n ...options,\n syntax:\n options.syntax ??\n new CombinedParser<CombinedExpression>([\n new FunctionExpressionParser(),\n new EvaluatedExpressionParser(),\n new ShorthandExpressionParser()\n ])\n });\n }\n\n getEditorV5Syntax<T>(helpers: V5EditorHelpers<T>): T {\n return helpers.typedBindingOrFunction({\n types: null,\n writable: false,\n constants: false\n });\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5FunctionAttribute = void 0;
4
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
5
+ const V5Attribute_1 = require("./V5Attribute");
6
+ class V5FunctionAttribute extends V5Attribute_1.V5Attribute {
7
+ constructor(options) {
8
+ var _a;
9
+ super(V5FunctionAttribute.TYPE, Object.assign(Object.assign({ autoWatch: false }, options), { syntax: (_a = options.syntax) !== null && _a !== void 0 ? _a : new parser_expressions_1.FunctionExpressionParser() }));
10
+ }
11
+ }
12
+ exports.V5FunctionAttribute = V5FunctionAttribute;
13
+ V5FunctionAttribute.TYPE = 'on-function-attribute';
14
+ //# sourceMappingURL=V5FunctionAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5FunctionAttribute.js","sourceRoot":"","sources":["../../src/attributes/V5FunctionAttribute.ts"],"names":[],"mappings":";;;AAAA,wEAA+F;AAC/F,+CAAiE;AAMjE,yBAAiC,SAAQ,yBAAwC;IAG/E,YAAY,OAA6D;;QACvE,KAAK,CAAC,mBAAmB,CAAC,IAAI,gCAC5B,SAAS,EAAE,KAAK,IACb,OAAO,KACV,MAAM,QAAE,OAAO,CAAC,MAAM,mCAAI,IAAI,6CAAwB,EAAE,IACxD,CAAC;IACL,CAAC;CACF;;AATQ,wBAAI,GAAG,uBAAuB,CAAC","sourcesContent":["import { FunctionExpression, FunctionExpressionParser } from '@ja-platform/parser-expressions';\nimport { V5Attribute, V5AttributeGenerics } from './V5Attribute';\n\nexport interface V5FunctionAttributeGenerics extends V5AttributeGenerics {\n Value: FunctionExpression | null;\n}\n\nexport class V5FunctionAttribute extends V5Attribute<V5FunctionAttributeGenerics> {\n static TYPE = 'on-function-attribute';\n\n constructor(options: Omit<V5AttributeGenerics['Options'], 'configurable'>) {\n super(V5FunctionAttribute.TYPE, {\n autoWatch: false,\n ...options,\n syntax: options.syntax ?? new FunctionExpressionParser()\n });\n }\n}\n"]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5ListAttribute = void 0;
4
+ const V5Attribute_1 = require("./V5Attribute");
5
+ class V5ListAttribute extends V5Attribute_1.V5Attribute {
6
+ constructor(options) {
7
+ var _a, _b;
8
+ super(V5ListAttribute.TYPE, Object.assign(Object.assign({}, options), { options: options.options || [], configurable: (_a = options.configurable) !== null && _a !== void 0 ? _a : true }));
9
+ this.delimiter = (_b = options.delimiter) !== null && _b !== void 0 ? _b : ',';
10
+ }
11
+ static isInstanceOf(attr) {
12
+ return attr.type === V5ListAttribute.TYPE;
13
+ }
14
+ static toList(value, delimiter = ',') {
15
+ if (value == null) {
16
+ return null;
17
+ }
18
+ else if (Array.isArray(value)) {
19
+ return value;
20
+ }
21
+ else if (typeof value === 'string' || value instanceof String) {
22
+ return `${value}`.split(delimiter);
23
+ }
24
+ else {
25
+ // Value might be an object, which will be resolved elsewhere
26
+ return value;
27
+ }
28
+ }
29
+ getEditorV5Syntax(helpers) {
30
+ return helpers.dynamicList(this.options.options, this.options.defaultValue);
31
+ }
32
+ serialize() {
33
+ return Object.assign(Object.assign({}, super.serialize()), { type: 'list', options: this.options.options });
34
+ }
35
+ }
36
+ exports.V5ListAttribute = V5ListAttribute;
37
+ V5ListAttribute.TYPE = 'list-attribute';
38
+ //# sourceMappingURL=V5ListAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5ListAttribute.js","sourceRoot":"","sources":["../../src/attributes/V5ListAttribute.ts"],"names":[],"mappings":";;;AACA,+CAAqF;AAerF,qBAA6B,SAAQ,yBAAoC;IAGvE,YAAY,OAA2C;;QACrD,KAAK,CAAC,eAAe,CAAC,IAAI,kCACrB,OAAO,KACV,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,EAC9B,YAAY,QAAE,OAAO,CAAC,YAAY,mCAAI,IAAI,IAC1C,CAAC;QACH,IAAI,CAAC,SAAS,SAAG,OAAO,CAAC,SAAS,mCAAI,GAAG,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,IAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,IAAI,CAAC;IAC5C,CAAC;IAED,MAAM,CAAC,MAAM,CAAC,KAAU,EAAE,SAAS,GAAG,GAAG;QACvC,IAAI,KAAK,IAAI,IAAI,EAAE,CAAC;YAClB,OAAO,IAAI,CAAC;QACd,CAAC;aAAM,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAChC,OAAO,KAAK,CAAC;QACf,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,YAAY,MAAM,EAAE,CAAC;YAChE,OAAO,GAAG,KAAK,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACrC,CAAC;aAAM,CAAC;YACN,6DAA6D;YAC7D,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAED,iBAAiB,CAAI,OAA2B;QAC9C,OAAO,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAC9E,CAAC;IACD,SAAS;QACP,uCACK,KAAK,CAAC,SAAS,EAAE,KACpB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,IAC7B;IACJ,CAAC;CACF;;AAtCQ,oBAAI,GAAG,gBAAgB,CAAC","sourcesContent":["import type { EvaluatedExpression, ConstantExpression } from '@ja-platform/parser-expressions';\nimport { V5Attribute, V5AttributeGenerics, V5AttributeOptions } from './V5Attribute';\nimport { V5EditorHelpers } from '../events/V5EditorContext';\n\nexport type CombinedListExpression = EvaluatedExpression | ConstantExpression;\n\nexport interface V5ListAttributeOptions extends V5AttributeOptions<string[]> {\n options: string[];\n delimiter?: string;\n}\n\nexport interface V5ListAttributeGenerics extends V5AttributeGenerics {\n Value: CombinedListExpression | null;\n Options: V5ListAttributeOptions;\n}\n\nexport class V5ListAttribute extends V5Attribute<V5ListAttributeGenerics> {\n static TYPE = 'list-attribute';\n delimiter: string;\n constructor(options: V5ListAttributeGenerics['Options']) {\n super(V5ListAttribute.TYPE, {\n ...options,\n options: options.options || [],\n configurable: options.configurable ?? true\n });\n this.delimiter = options.delimiter ?? ',';\n }\n\n static isInstanceOf(attr: V5Attribute): attr is V5ListAttribute {\n return attr.type === V5ListAttribute.TYPE;\n }\n\n static toList(value: any, delimiter = ','): any[] {\n if (value == null) {\n return null;\n } else if (Array.isArray(value)) {\n return value;\n } else if (typeof value === 'string' || value instanceof String) {\n return `${value}`.split(delimiter);\n } else {\n // Value might be an object, which will be resolved elsewhere\n return value;\n }\n }\n\n getEditorV5Syntax<T>(helpers: V5EditorHelpers<T>): T {\n return helpers.dynamicList(this.options.options, this.options.defaultValue);\n }\n serialize(): any {\n return {\n ...super.serialize(),\n type: 'list',\n options: this.options.options\n };\n }\n}\n"]}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5NumberAttribute = void 0;
4
+ const parser_expressions_1 = require("@ja-platform/parser-expressions");
5
+ const parser_type_system_1 = require("@ja-platform/parser-type-system");
6
+ const AttributeDefaults_1 = require("./AttributeDefaults");
7
+ const V5Attribute_1 = require("./V5Attribute");
8
+ class V5NumberAttribute extends V5Attribute_1.V5Attribute {
9
+ static isInstanceOf(attr) {
10
+ return attr.type === V5NumberAttribute.TYPE;
11
+ }
12
+ constructor(options) {
13
+ var _a, _b;
14
+ super(V5NumberAttribute.TYPE, Object.assign(Object.assign({}, options), { valueType: (_a = options.valueType) !== null && _a !== void 0 ? _a : parser_type_system_1.numberType, defaultValueKind: V5Attribute_1.DefaultValueKind.SIZE, configurable: (_b = options.configurable) !== null && _b !== void 0 ? _b : true }));
15
+ if (typeof this.options.defaultValue == 'number') {
16
+ this.options.defaultValue = (0, AttributeDefaults_1.fanDefaultValue)(this.options.defaultValue);
17
+ }
18
+ }
19
+ getParsedValue(event) {
20
+ const value = event.input.value;
21
+ if (value.trim() === '') {
22
+ return null;
23
+ }
24
+ return super.getParsedValue(event);
25
+ }
26
+ setParent(parent) {
27
+ super.setParent(parent);
28
+ parent.registerListener({
29
+ postParse: ({ parsed }) => {
30
+ parsed.registerListener({
31
+ postValidation: ({ context }) => {
32
+ var _a, _b;
33
+ const expression = parsed.attrExpression(this.options.key);
34
+ const { name, range } = this.options;
35
+ if (expression instanceof parser_expressions_1.ConstantExpression && range) {
36
+ const value = expression.value();
37
+ const min = (_a = range.min) !== null && _a !== void 0 ? _a : Number.NEGATIVE_INFINITY;
38
+ const max = (_b = range.max) !== null && _b !== void 0 ? _b : Number.POSITIVE_INFINITY;
39
+ if (value < min || value > max) {
40
+ context.report({
41
+ token: expression.tokens[0],
42
+ message: `${parsed.sourceElement.nodeName}: Attribute ${name}="${expression.raw()}" is outside of allowable range [${min}, ${max}].`
43
+ });
44
+ }
45
+ }
46
+ }
47
+ });
48
+ }
49
+ });
50
+ }
51
+ getEditorV5Syntax(helpers) {
52
+ return helpers.typedBindingOrFunction({
53
+ types: ['number'],
54
+ writable: false,
55
+ constants: false
56
+ });
57
+ }
58
+ serialize() {
59
+ return Object.assign(Object.assign({}, super.serialize()), { type: 'number' });
60
+ }
61
+ }
62
+ exports.V5NumberAttribute = V5NumberAttribute;
63
+ V5NumberAttribute.TYPE = 'number-attribute';
64
+ //# sourceMappingURL=V5NumberAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5NumberAttribute.js","sourceRoot":"","sources":["../../src/attributes/V5NumberAttribute.ts"],"names":[],"mappings":";;;AACA,wEAA0F;AAC1F,wEAA6D;AAC7D,2DAAsD;AACtD,+CAMuB;AAqBvB,uBAA+B,SAAQ,yBAAsC;IAG3E,MAAM,CAAC,YAAY,CAAC,IAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,KAAK,iBAAiB,CAAC,IAAI,CAAC;IAC9C,CAAC;IAED,YAAY,OAA6C;;QACvD,KAAK,CAAC,iBAAiB,CAAC,IAAI,kCACvB,OAAO,KACV,SAAS,QAAE,OAAO,CAAC,SAAS,mCAAI,+BAAU,EAC1C,gBAAgB,EAAE,8BAAgB,CAAC,IAAI,EACvC,YAAY,QAAE,OAAO,CAAC,YAAY,mCAAI,IAAI,IAC1C,CAAC;QACH,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,EAAE,CAAC;YACjD,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,IAAA,mCAAe,EAAC,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AC,GAAG,EAAE,oCAAoC,GAAG,KAAK,GAAG,IAAI;iCACrI,CAAC,CAAC;4BACL,CAAC;wBACH,CAAC;oBACH,CAAC;iBACF,CAAC,CAAC;YACL,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,iBAAiB,CAAI,OAA2B;QAC9C,OAAO,OAAO,CAAC,sBAAsB,CAAC;YACpC,KAAK,EAAE,CAAC,QAAQ,CAAC;YACjB,QAAQ,EAAE,KAAK;YACf,SAAS,EAAE,KAAK;SACjB,CAAC,CAAC;IACL,CAAC;IACD,SAAS;QACP,uCACK,KAAK,CAAC,SAAS,EAAE,KACpB,IAAI,EAAE,QAAQ,IACd;IACJ,CAAC;CACF;;AAhEQ,sBAAI,GAAG,kBAAkB,CAAC","sourcesContent":["import { AttributeParseEvent } from '../AttributeParseEvent';\nimport { EvaluatedExpression, ConstantExpression } from '@ja-platform/parser-expressions';\nimport { numberType } from '@ja-platform/parser-type-system';\nimport { fanDefaultValue } from './AttributeDefaults';\nimport {\n DefaultValueType,\n DefaultValueKind,\n V5Attribute,\n V5AttributeGenerics,\n V5AttributeOptions\n} from './V5Attribute';\nimport { V5EditorHelpers } from '../events/V5EditorContext';\nimport type { V5Node } from '../nodes/V5Node';\n\nexport type CombinedNumberExpression = EvaluatedExpression | ConstantExpression<number>;\n\nexport interface V5NumberAttributeRange {\n min?: number;\n max?: number;\n}\n\nexport interface V5NumberAttributeOptions extends V5AttributeOptions<DefaultValueType<number>, number> {\n range?: V5NumberAttributeRange;\n}\n\nexport interface V5NumberAttributeGenerics extends V5AttributeGenerics {\n Options: V5NumberAttributeOptions;\n Value: CombinedNumberExpression | null;\n NormalizedValue: number;\n}\n\nexport class V5NumberAttribute extends V5Attribute<V5NumberAttributeGenerics> {\n static TYPE = 'number-attribute';\n\n static isInstanceOf(attr: V5Attribute): attr is V5NumberAttribute {\n return attr.type === V5NumberAttribute.TYPE;\n }\n\n constructor(options: V5NumberAttributeGenerics['Options']) {\n super(V5NumberAttribute.TYPE, {\n ...options,\n valueType: options.valueType ?? numberType,\n defaultValueKind: DefaultValueKind.SIZE,\n configurable: options.configurable ?? true\n });\n if (typeof this.options.defaultValue == 'number') {\n this.options.defaultValue = fanDefaultValue(this.options.defaultValue);\n }\n }\n\n protected getParsedValue(event: AttributeParseEvent): V5NumberAttributeGenerics['Value'] {\n const value = event.input.value;\n if (value.trim() === '') {\n return null;\n }\n return super.getParsedValue(event);\n }\n\n setParent(parent: V5Node<any>) {\n super.setParent(parent);\n parent.registerListener({\n postParse: ({ parsed }) => {\n parsed.registerListener({\n postValidation: ({ context }) => {\n const expression = parsed.attrExpression(this.options.key);\n const { name, range } = this.options;\n if (expression instanceof ConstantExpression && range) {\n const value = expression.value();\n const min = range.min ?? Number.NEGATIVE_INFINITY;\n const max = range.max ?? Number.POSITIVE_INFINITY;\n if (value < min || value > max) {\n context.report({\n token: expression.tokens[0],\n message: `${parsed.sourceElement.nodeName}: Attribute ${name}=\"${expression.raw()}\" is outside of allowable range [${min}, ${max}].`\n });\n }\n }\n }\n });\n }\n });\n }\n\n getEditorV5Syntax<T>(helpers: V5EditorHelpers<T>): T {\n return helpers.typedBindingOrFunction({\n types: ['number'],\n writable: false,\n constants: false\n });\n }\n serialize(): any {\n return {\n ...super.serialize(),\n type: 'number'\n };\n }\n}\n"]}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5PathAttribute = void 0;
4
+ const V5Attribute_1 = require("./V5Attribute");
5
+ class V5PathAttribute extends V5Attribute_1.V5Attribute {
6
+ constructor(options) {
7
+ super(V5PathAttribute.TYPE, options);
8
+ }
9
+ serialize() {
10
+ return Object.assign(Object.assign({}, super.serialize()), { type: 'path' });
11
+ }
12
+ }
13
+ exports.V5PathAttribute = V5PathAttribute;
14
+ V5PathAttribute.TYPE = 'path-attribute';
15
+ //# sourceMappingURL=V5PathAttribue.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5PathAttribue.js","sourceRoot":"","sources":["../../src/attributes/V5PathAttribue.ts"],"names":[],"mappings":";;;AACA,+CAAqF;AAQrF,qBAA6B,SAAQ,yBAAoC;IAGvE,YAAY,OAAiD;QAC3D,KAAK,CAAC,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACvC,CAAC;IACD,SAAS;QACP,uCACK,KAAK,CAAC,SAAS,EAAE,KACpB,IAAI,EAAE,MAAM,IACZ;IACJ,CAAC;CACF;;AAXQ,oBAAI,GAAG,gBAAgB,CAAC","sourcesContent":["import type { EvaluatedExpression, ConstantExpression } from '@ja-platform/parser-expressions';\nimport { V5Attribute, V5AttributeOptions, V5AttributeGenerics } from './V5Attribute';\n\nexport type CombinedPathExpression = EvaluatedExpression | ConstantExpression;\n\nexport interface V5PathAttributeGenerics extends V5AttributeGenerics {\n Value: CombinedPathExpression | null;\n}\n\nexport class V5PathAttribute extends V5Attribute<V5PathAttributeGenerics> {\n static TYPE = 'path-attribute';\n\n constructor(options: Omit<V5AttributeOptions, 'configurable'>) {\n super(V5PathAttribute.TYPE, options);\n }\n serialize(): any {\n return {\n ...super.serialize(),\n type: 'path'\n };\n }\n}\n"]}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.V5SetAttribute = void 0;
4
+ const AttributeDefaults_1 = require("./AttributeDefaults");
5
+ const V5Attribute_1 = require("./V5Attribute");
6
+ class V5SetAttribute extends V5Attribute_1.V5Attribute {
7
+ constructor(options) {
8
+ var _a;
9
+ super(V5SetAttribute.TYPE, Object.assign(Object.assign({}, options), { defaultValueKind: V5Attribute_1.DefaultValueKind.SIZE, configurable: (_a = options.configurable) !== null && _a !== void 0 ? _a : true, options: options.options || [] }));
10
+ if (typeof this.options.defaultValue == 'string') {
11
+ this.options.defaultValue = (0, AttributeDefaults_1.fanDefaultValue)(this.options.defaultValue);
12
+ }
13
+ }
14
+ static isInstanceOf(attr) {
15
+ return attr.type === V5SetAttribute.TYPE;
16
+ }
17
+ getEditorV5Syntax(helpers) {
18
+ var _a;
19
+ return helpers.dynamicSet(this.options.options, (_a = (this.options.defaultValue || {})[V5Attribute_1.ComponentSize.MEDIUM]) !== null && _a !== void 0 ? _a : this.options.defaultValue);
20
+ }
21
+ serialize() {
22
+ return Object.assign(Object.assign({}, super.serialize()), { type: 'set', options: this.options.options });
23
+ }
24
+ }
25
+ exports.V5SetAttribute = V5SetAttribute;
26
+ V5SetAttribute.TYPE = 'set-attribute';
27
+ //# sourceMappingURL=V5SetAttribute.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"V5SetAttribute.js","sourceRoot":"","sources":["../../src/attributes/V5SetAttribute.ts"],"names":[],"mappings":";;;AAEA,2DAAsD;AACtD,+CAOuB;AAavB,oBAA4B,SAAQ,yBAAmC;IAErE,YAAY,OAA8B;;QACxC,KAAK,CAAC,cAAc,CAAC,IAAI,kCACpB,OAAO,KACV,gBAAgB,EAAE,8BAAgB,CAAC,IAAI,EACvC,YAAY,QAAE,OAAO,CAAC,YAAY,mCAAI,IAAI,EAC1C,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE,IAC9B,CAAC;QAEH,IAAI,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,QAAQ,EAAE,CAAC;YACjD,IAAI,CAAC,OAAO,CAAC,YAAY,GAAG,IAAA,mCAAe,EAAC,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,IAAiB;QACnC,OAAO,IAAI,CAAC,IAAI,KAAK,cAAc,CAAC,IAAI,CAAC;IAC3C,CAAC;IAED,iBAAiB,CAAI,OAA2B;;QAC9C,OAAO,OAAO,CAAC,UAAU,CACvB,IAAI,CAAC,OAAO,CAAC,OAAO,QACpB,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,IAAI,EAAE,CAAC,CAAC,2BAAa,CAAC,MAAM,CAAC,mCAAI,IAAI,CAAC,OAAO,CAAC,YAAY,CACrF,CAAC;IACJ,CAAC;IACD,SAAS;QACP,uCACK,KAAK,CAAC,SAAS,EAAE,KACpB,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO,IAC7B;IACJ,CAAC;CACF;;AA/BQ,mBAAI,GAAG,eAAe,CAAC","sourcesContent":["import type { EvaluatedExpression, ConstantExpression } from '@ja-platform/parser-expressions';\nimport { V5EditorHelpers } from '../events/V5EditorContext';\nimport { fanDefaultValue } from './AttributeDefaults';\nimport {\n ComponentSize,\n DefaultValueType,\n DefaultValueKind,\n V5Attribute,\n V5AttributeGenerics,\n V5AttributeOptions\n} from './V5Attribute';\n\nexport type CombinedSetExpression = EvaluatedExpression | ConstantExpression;\n\nexport interface V5SetAttributeOptions extends V5AttributeOptions<DefaultValueType<string>> {\n options: string[];\n}\n\nexport interface V5SetAttributeGenerics extends V5AttributeGenerics {\n Value: CombinedSetExpression | null;\n Options: V5SetAttributeOptions;\n}\n\nexport class V5SetAttribute extends V5Attribute<V5SetAttributeGenerics> {\n static TYPE = 'set-attribute';\n constructor(options: V5SetAttributeOptions) {\n super(V5SetAttribute.TYPE, {\n ...options,\n defaultValueKind: DefaultValueKind.SIZE,\n configurable: options.configurable ?? true,\n options: options.options || []\n });\n\n if (typeof this.options.defaultValue == 'string') {\n this.options.defaultValue = fanDefaultValue(this.options.defaultValue);\n }\n }\n\n static isInstanceOf(attr: V5Attribute): attr is V5SetAttribute {\n return attr.type === V5SetAttribute.TYPE;\n }\n\n getEditorV5Syntax<T>(helpers: V5EditorHelpers<T>): T {\n return helpers.dynamicSet(\n this.options.options,\n (this.options.defaultValue || {})[ComponentSize.MEDIUM] ?? this.options.defaultValue\n );\n }\n serialize(): any {\n return {\n ...super.serialize(),\n type: 'set',\n options: this.options.options\n };\n }\n}\n"]}