@venite/components 0.16.48 → 0.16.50
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/dist/cjs/index-01fdec29.js +2 -2
- package/dist/cjs/{ion-segment_16.cjs.entry.js → ion-segment_17.cjs.entry.js} +95 -32
- package/dist/cjs/ldf-editable-add-block-menu.cjs.entry.js +18 -2
- package/dist/cjs/ldf.cjs.js +1 -1
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/{image-527d7134.js → parallel-eb251490.js} +8 -0
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/editable-add-block-menu/dist/menu-options.js +218 -7
- package/dist/collection/components/editable-add-block-menu/menu-options.js +17 -1
- package/dist/collection/components/editable-metadata-buttons/editable-metadata-buttons.js +2 -2
- package/dist/collection/components/liturgical-document/dist/liturgical-document.js +3 -0
- package/dist/collection/components/liturgical-document/liturgical-document.js +3 -0
- package/dist/collection/components/parallel/dist/option.js +318 -0
- package/dist/collection/components/parallel/dist/parallel.js +146 -0
- package/dist/collection/components/parallel/parallel.css +8 -0
- package/dist/collection/components/parallel/parallel.i18n.en.json +3 -0
- package/dist/collection/components/parallel/parallel.js +213 -0
- package/dist/collection/i18n/parallel.i18n.en.json +3 -0
- package/dist/esm/index-034add74.js +2 -2
- package/dist/esm/{ion-segment_16.entry.js → ion-segment_17.entry.js} +92 -30
- package/dist/esm/ldf-editable-add-block-menu.entry.js +17 -1
- package/dist/esm/ldf.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{image-b773ce41.js → parallel-63ee2ef4.js} +8 -1
- package/dist/ldf/i18n/parallel.i18n.en.json +3 -0
- package/dist/ldf/ldf.esm.js +1 -1
- package/dist/ldf/p-2535778d.js +1 -0
- package/dist/ldf/p-78d738ad.entry.js +1 -0
- package/dist/ldf/p-f7251a11.entry.js +1 -0
- package/dist/types/components/editable-metadata-buttons/editable-metadata-buttons.d.ts +1 -1
- package/dist/types/components/parallel/parallel.d.ts +41 -0
- package/dist/types/components.d.ts +56 -3
- package/package.json +1 -1
- package/dist/ldf/p-5c897bef.entry.js +0 -1
- package/dist/ldf/p-cf9d5530.js +0 -1
- package/dist/ldf/p-e8bb8144.entry.js +0 -1
|
@@ -317,8 +317,8 @@ export class EditableMetadataButtonsComponent {
|
|
|
317
317
|
"type": "string",
|
|
318
318
|
"mutable": false,
|
|
319
319
|
"complexType": {
|
|
320
|
-
"original": "'liturgy' | 'cycle' | 'heading' | 'option' | 'refrain' | 'rubric' | 'text' | 'responsive' | 'bible-reading' | 'psalm' | 'meditation' | null",
|
|
321
|
-
"resolved": "\"bible-reading\" | \"cycle\" | \"heading\" | \"liturgy\" | \"meditation\" | \"option\" | \"psalm\" | \"refrain\" | \"responsive\" | \"rubric\" | \"text\"",
|
|
320
|
+
"original": "'liturgy' | 'cycle' | 'heading' | 'option' | 'parallel' | 'refrain' | 'rubric' | 'text' | 'responsive' | 'bible-reading' | 'psalm' | 'meditation' | null",
|
|
321
|
+
"resolved": "\"bible-reading\" | \"cycle\" | \"heading\" | \"liturgy\" | \"meditation\" | \"option\" | \"parallel\" | \"psalm\" | \"refrain\" | \"responsive\" | \"rubric\" | \"text\"",
|
|
322
322
|
"references": {}
|
|
323
323
|
},
|
|
324
324
|
"required": false,
|
|
@@ -216,6 +216,9 @@ var LiturgicalDocumentComponent = /** @class */ (function () {
|
|
|
216
216
|
case 'option':
|
|
217
217
|
node = React.createElement("ldf-option", { path: this.path, editable: editable, preview: this.preview, doc: doc });
|
|
218
218
|
break;
|
|
219
|
+
case 'parallel':
|
|
220
|
+
node = React.createElement("ldf-parallel", { path: this.path, editable: editable, preview: this.preview, doc: doc });
|
|
221
|
+
break;
|
|
219
222
|
case 'refrain':
|
|
220
223
|
node = React.createElement("ldf-refrain", { path: this.path, editable: editable, doc: doc });
|
|
221
224
|
break;
|
|
@@ -159,6 +159,9 @@ export class LiturgicalDocumentComponent {
|
|
|
159
159
|
case 'option':
|
|
160
160
|
node = h("ldf-option", { path: this.path, editable: editable, preview: this.preview, doc: doc });
|
|
161
161
|
break;
|
|
162
|
+
case 'parallel':
|
|
163
|
+
node = h("ldf-parallel", { path: this.path, editable: editable, preview: this.preview, doc: doc });
|
|
164
|
+
break;
|
|
162
165
|
case 'refrain':
|
|
163
166
|
node = h("ldf-refrain", { path: this.path, editable: editable, doc: doc });
|
|
164
167
|
break;
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
14
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
16
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
17
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
18
|
+
};
|
|
19
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
20
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
21
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
22
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
23
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
24
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
25
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
29
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
30
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
31
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
32
|
+
function step(op) {
|
|
33
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
34
|
+
while (_) try {
|
|
35
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
36
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
37
|
+
switch (op[0]) {
|
|
38
|
+
case 0: case 1: t = op; break;
|
|
39
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
40
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
41
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
42
|
+
default:
|
|
43
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
44
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
45
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
46
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
47
|
+
if (t[2]) _.ops.pop();
|
|
48
|
+
_.trys.pop(); continue;
|
|
49
|
+
}
|
|
50
|
+
op = body.call(thisArg, _);
|
|
51
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
52
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.__esModule = true;
|
|
56
|
+
exports.OptionComponent = void 0;
|
|
57
|
+
var core_1 = require("@stencil/core");
|
|
58
|
+
var ldf_1 = require("@venite/ldf");
|
|
59
|
+
var locale_1 = require("../../utils/locale");
|
|
60
|
+
var option_i18n_en_json_1 = require("./option.i18n.en.json");
|
|
61
|
+
var LOCALE = {
|
|
62
|
+
'en': option_i18n_en_json_1["default"]
|
|
63
|
+
};
|
|
64
|
+
var OptionComponent = /** @class */ (function () {
|
|
65
|
+
function OptionComponent() {
|
|
66
|
+
}
|
|
67
|
+
OptionComponent.prototype.docChanged = function (newDoc) {
|
|
68
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
69
|
+
try {
|
|
70
|
+
if (typeof newDoc == 'string') {
|
|
71
|
+
this.obj = new ldf_1.Option(JSON.parse(newDoc));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
this.obj = new ldf_1.Option(newDoc);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
catch (e) {
|
|
78
|
+
console.warn(e);
|
|
79
|
+
this.obj = new ldf_1.Option();
|
|
80
|
+
}
|
|
81
|
+
var selected = this.editable
|
|
82
|
+
? (_f = (_c = (_b = (_a = this.obj) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.editor_selected) !== null && _c !== void 0 ? _c : (_e = (_d = this.obj) === null || _d === void 0 ? void 0 : _d.metadata) === null || _e === void 0 ? void 0 : _e.selected) !== null && _f !== void 0 ? _f : 0 : (_j = (_h = (_g = this.obj) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.selected) !== null && _j !== void 0 ? _j : 0;
|
|
83
|
+
this.select(selected);
|
|
84
|
+
if (!((_k = this.obj) === null || _k === void 0 ? void 0 : _k.value) || !this.obj.value[selected] || !this.obj.value[selected].value) {
|
|
85
|
+
this.selectFirstDefined();
|
|
86
|
+
}
|
|
87
|
+
this.filterOptions();
|
|
88
|
+
};
|
|
89
|
+
// Lifecycle events
|
|
90
|
+
OptionComponent.prototype.componentWillLoad = function () {
|
|
91
|
+
this.docChanged(this.doc);
|
|
92
|
+
this.loadLocaleStrings();
|
|
93
|
+
this.ldfOptionAskForStoredSelection.emit({ el: this.el });
|
|
94
|
+
};
|
|
95
|
+
/** Asynchronously load localization strings */
|
|
96
|
+
OptionComponent.prototype.loadLocaleStrings = function () {
|
|
97
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
98
|
+
return __generator(this, function (_a) {
|
|
99
|
+
try {
|
|
100
|
+
this.localeStrings = LOCALE[locale_1.getComponentClosestLanguage(this.el)];
|
|
101
|
+
}
|
|
102
|
+
catch (e) {
|
|
103
|
+
console.warn(e);
|
|
104
|
+
}
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
/** Display the nth option */
|
|
110
|
+
OptionComponent.prototype.select = function (index, resultedFromUserAction) {
|
|
111
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
112
|
+
if (resultedFromUserAction === void 0) { resultedFromUserAction = false; }
|
|
113
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
114
|
+
var hadMetadata, oldValue;
|
|
115
|
+
return __generator(this, function (_j) {
|
|
116
|
+
if (((_a = this.obj) === null || _a === void 0 ? void 0 : _a.slug) && typeof index === 'number' && resultedFromUserAction) {
|
|
117
|
+
this.ldfOptionMakeSelection.emit({ slug: (_b = this.obj) === null || _b === void 0 ? void 0 : _b.slug, index: index });
|
|
118
|
+
}
|
|
119
|
+
hadMetadata = Boolean((_c = this.obj) === null || _c === void 0 ? void 0 : _c.metadata), oldValue = (_e = (_d = this.obj) === null || _d === void 0 ? void 0 : _d.metadata) === null || _e === void 0 ? void 0 : _e.editor_selected;
|
|
120
|
+
if (Number(index) >= 0) {
|
|
121
|
+
//this.selectedDoc = this.obj.value.filter(child => Boolean(child))[index];
|
|
122
|
+
if ((_f = this.obj) === null || _f === void 0 ? void 0 : _f.metadata) {
|
|
123
|
+
this.obj.metadata.selected = Number(index);
|
|
124
|
+
this.obj.metadata.editor_selected = Number(index);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this.obj.metadata = { selected: Number(index), editor_selected: Number(index) };
|
|
128
|
+
}
|
|
129
|
+
this.obj = new ldf_1.Option(__assign({}, this.obj));
|
|
130
|
+
// only change the selection at this point if it's not editable
|
|
131
|
+
// if it's editable, the editor will control when it changes
|
|
132
|
+
if (resultedFromUserAction && !this.editable) {
|
|
133
|
+
this.ldfDocShouldChange.emit(new ldf_1.Change({
|
|
134
|
+
path: this.path + "/metadata",
|
|
135
|
+
op: [{
|
|
136
|
+
type: 'set',
|
|
137
|
+
index: 'selected',
|
|
138
|
+
oldValue: oldValue,
|
|
139
|
+
value: Number(index)
|
|
140
|
+
}]
|
|
141
|
+
}));
|
|
142
|
+
}
|
|
143
|
+
if (this.editable) {
|
|
144
|
+
if (hadMetadata && index !== oldValue) {
|
|
145
|
+
this.ldfDocShouldChange.emit(new ldf_1.Change({
|
|
146
|
+
path: this.path + "/metadata",
|
|
147
|
+
op: [{
|
|
148
|
+
type: 'set',
|
|
149
|
+
index: 'editor_selected',
|
|
150
|
+
oldValue: oldValue,
|
|
151
|
+
value: Number(index)
|
|
152
|
+
}]
|
|
153
|
+
}));
|
|
154
|
+
}
|
|
155
|
+
else if (!hadMetadata && index !== oldValue) {
|
|
156
|
+
this.ldfDocShouldChange.emit(new ldf_1.Change({
|
|
157
|
+
path: "" + this.path,
|
|
158
|
+
op: [{
|
|
159
|
+
type: 'set',
|
|
160
|
+
index: 'metadata',
|
|
161
|
+
value: { editor_selected: Number(index) }
|
|
162
|
+
}]
|
|
163
|
+
}));
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
// sets metadata.selected to new index, and creates objects along the way if undefined
|
|
167
|
+
// without overriding any other metadata fields
|
|
168
|
+
Object.assign(this.obj, { metadata: __assign(__assign({}, this.obj.metadata), { selected: index }) });
|
|
169
|
+
Object.assign(this.obj, { metadata: __assign(__assign({}, this.obj.metadata), { editor_selected: index }) });
|
|
170
|
+
}
|
|
171
|
+
else if (index === 'add') {
|
|
172
|
+
this.ldfAddOptionToDoc.emit({
|
|
173
|
+
base: this.path,
|
|
174
|
+
index: (_h = (_g = this.obj) === null || _g === void 0 ? void 0 : _g.value) === null || _h === void 0 ? void 0 : _h.length,
|
|
175
|
+
obj: this.obj
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
return [2 /*return*/];
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
};
|
|
182
|
+
// Private methods
|
|
183
|
+
OptionComponent.prototype.onSelectChange = function (ev) {
|
|
184
|
+
var target = ev.target, value = parseInt(target.value);
|
|
185
|
+
this.select(value, true);
|
|
186
|
+
};
|
|
187
|
+
OptionComponent.prototype.selectFirstDefined = function () {
|
|
188
|
+
var first = this.obj.value.find(function (opt) { return (opt === null || opt === void 0 ? void 0 : opt.value) !== undefined; }), index = this.obj.value.filter(function (child) { return Boolean(child); }).indexOf(first);
|
|
189
|
+
this.select(index);
|
|
190
|
+
};
|
|
191
|
+
OptionComponent.prototype.filterOptions = function () {
|
|
192
|
+
var _this = this;
|
|
193
|
+
var _a;
|
|
194
|
+
if (this.obj) {
|
|
195
|
+
this.obj = new ldf_1.Option(__assign(__assign({}, this.obj), { value: (((_a = this.obj) === null || _a === void 0 ? void 0 : _a.value) || []).filter(function (entry) {
|
|
196
|
+
return _this.editable || (Boolean(entry) && (Boolean(entry.value) || Boolean((entry === null || entry === void 0 ? void 0 : entry.type) === "bible-reading" && entry.citation)));
|
|
197
|
+
}) }));
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
// Render helpers
|
|
201
|
+
/** Return an Ionic Select or Segment element if available, otherwise a vanilla HTML Select Element */
|
|
202
|
+
OptionComponent.prototype.selectNode = function () {
|
|
203
|
+
var _this = this;
|
|
204
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
205
|
+
var currentlySelected = this.editable ? (_f = (_c = (_b = (_a = this.obj) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.editor_selected) !== null && _c !== void 0 ? _c : (_e = (_d = this.obj) === null || _d === void 0 ? void 0 : _d.metadata) === null || _e === void 0 ? void 0 : _e.selected) !== null && _f !== void 0 ? _f : 0 : (_j = (_h = (_g = this.obj) === null || _g === void 0 ? void 0 : _g.metadata) === null || _h === void 0 ? void 0 : _h.selected) !== null && _j !== void 0 ? _j : 0;
|
|
206
|
+
if (((_l = (_k = this.obj) === null || _k === void 0 ? void 0 : _k.value) === null || _l === void 0 ? void 0 : _l.length) > 1 || this.editable) {
|
|
207
|
+
// Ionic available and
|
|
208
|
+
if (customElements && !!customElements.get('ion-select')) {
|
|
209
|
+
var optionsAreLong = (((_m = this.obj) === null || _m === void 0 ? void 0 : _m.value) || [])
|
|
210
|
+
.map(function (option, optionIndex) { var _a; return ((_a = _this.versionLabel(option, optionIndex)) === null || _a === void 0 ? void 0 : _a.length) > 20; })
|
|
211
|
+
.reduce(function (a, b) { return a || b; }, false);
|
|
212
|
+
// <= 3, short options
|
|
213
|
+
if (!optionsAreLong && ((_o = this.obj) === null || _o === void 0 ? void 0 : _o.value.length) <= 3) {
|
|
214
|
+
return (React.createElement("ion-segment", { color: "primary", value: currentlySelected.toString() }, (_p = this.obj) === null || _p === void 0 ? void 0 :
|
|
215
|
+
_p.value.map(function (option, optionIndex) {
|
|
216
|
+
return React.createElement("ion-segment-button", { value: optionIndex.toString(), onClick: function () { return _this.select(optionIndex, true); } },
|
|
217
|
+
React.createElement("ion-label", null, _this.versionLabel(option, optionIndex)));
|
|
218
|
+
}),
|
|
219
|
+
this.editable && React.createElement("ion-segment-button", { value: 'add', "class": 'add', onClick: function () { return _this.select('add', true); } },
|
|
220
|
+
React.createElement("ion-label", null, "+"))));
|
|
221
|
+
}
|
|
222
|
+
// >2 options, or options are longish
|
|
223
|
+
else {
|
|
224
|
+
console.log('>2 or longish');
|
|
225
|
+
return (React.createElement("ion-toolbar", null,
|
|
226
|
+
React.createElement("ion-select", { value: currentlySelected, slot: this.editable ? 'start' : 'end', onIonChange: function (e) { return _this.select(Number(e.detail.value), true); } }, (_q = this.obj) === null || _q === void 0 ? void 0 : _q.value.map(function (option, optionIndex) {
|
|
227
|
+
return React.createElement("ion-select-option", { value: optionIndex },
|
|
228
|
+
React.createElement("ion-label", null, _this.versionLabel(option, optionIndex)));
|
|
229
|
+
})),
|
|
230
|
+
this.editable && React.createElement("ion-buttons", { slot: 'end' },
|
|
231
|
+
React.createElement("ion-button", { onClick: function () { return _this.select('add', true); } },
|
|
232
|
+
React.createElement("ion-icon", { slot: 'icon-only', name: 'add' })))));
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
// Ionic not availabe
|
|
236
|
+
else {
|
|
237
|
+
return (React.createElement("ldf-label-bar", null,
|
|
238
|
+
React.createElement("select", { onInput: function (ev) { return _this.onSelectChange(ev); }, slot: this.editable ? 'start' : 'end' }, (_r = this.obj) === null || _r === void 0 ? void 0 : _r.value.map(function (option, optionIndex) {
|
|
239
|
+
return React.createElement("option", { value: optionIndex, selected: optionIndex == currentlySelected }, _this.versionLabel(option, optionIndex));
|
|
240
|
+
})),
|
|
241
|
+
this.editable && React.createElement("button", { slot: 'end', onClick: function () { return _this.select('add', true); } }, "+")));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
else {
|
|
245
|
+
return [];
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
OptionComponent.prototype.versionLabel = function (option, index) {
|
|
249
|
+
try {
|
|
250
|
+
return this.obj.getVersionLabel(option);
|
|
251
|
+
}
|
|
252
|
+
catch (e) {
|
|
253
|
+
console.warn(e);
|
|
254
|
+
return (this.localeStrings || {}).option + " " + (index + 1);
|
|
255
|
+
}
|
|
256
|
+
};
|
|
257
|
+
// Render
|
|
258
|
+
OptionComponent.prototype.render = function () {
|
|
259
|
+
var _a;
|
|
260
|
+
//console.log('ldf-option (render) ', this.obj?.metadata.selected, this.obj.value, this.selectedDoc)
|
|
261
|
+
var selectedIndex = this.editable ? (_a = this.obj.metadata.editor_selected) !== null && _a !== void 0 ? _a : this.obj.metadata.selected : this.obj.metadata.selected;
|
|
262
|
+
return (React.createElement(core_1.Host, { lang: this.obj.language },
|
|
263
|
+
React.createElement("div", { "class": 'select-control' },
|
|
264
|
+
React.createElement("ldf-label-bar", null, this.selectNode())),
|
|
265
|
+
(this.obj.value || this.editable) && React.createElement("ldf-liturgical-document", { doc: this.obj.value[selectedIndex], path: this.path + "/value/" + this.obj.metadata.selected, base: this.path + "/value", index: selectedIndex, editable: this.editable, parentType: 'option' })));
|
|
266
|
+
};
|
|
267
|
+
__decorate([
|
|
268
|
+
core_1.Element()
|
|
269
|
+
], OptionComponent.prototype, "el");
|
|
270
|
+
__decorate([
|
|
271
|
+
core_1.State()
|
|
272
|
+
], OptionComponent.prototype, "obj");
|
|
273
|
+
__decorate([
|
|
274
|
+
core_1.State()
|
|
275
|
+
], OptionComponent.prototype, "localeStrings");
|
|
276
|
+
__decorate([
|
|
277
|
+
core_1.State()
|
|
278
|
+
], OptionComponent.prototype, "filteredOptions");
|
|
279
|
+
__decorate([
|
|
280
|
+
core_1.Prop()
|
|
281
|
+
], OptionComponent.prototype, "doc");
|
|
282
|
+
__decorate([
|
|
283
|
+
core_1.Watch('doc')
|
|
284
|
+
], OptionComponent.prototype, "docChanged");
|
|
285
|
+
__decorate([
|
|
286
|
+
core_1.Prop({ reflect: true })
|
|
287
|
+
], OptionComponent.prototype, "path");
|
|
288
|
+
__decorate([
|
|
289
|
+
core_1.Prop()
|
|
290
|
+
], OptionComponent.prototype, "editable");
|
|
291
|
+
__decorate([
|
|
292
|
+
core_1.Prop()
|
|
293
|
+
], OptionComponent.prototype, "preview");
|
|
294
|
+
__decorate([
|
|
295
|
+
core_1.Event({ bubbles: true })
|
|
296
|
+
], OptionComponent.prototype, "ldfAddOptionToDoc");
|
|
297
|
+
__decorate([
|
|
298
|
+
core_1.Event({ bubbles: true })
|
|
299
|
+
], OptionComponent.prototype, "ldfDocShouldChange");
|
|
300
|
+
__decorate([
|
|
301
|
+
core_1.Event({ bubbles: true })
|
|
302
|
+
], OptionComponent.prototype, "ldfOptionAskForStoredSelection");
|
|
303
|
+
__decorate([
|
|
304
|
+
core_1.Event({ bubbles: true })
|
|
305
|
+
], OptionComponent.prototype, "ldfOptionMakeSelection");
|
|
306
|
+
__decorate([
|
|
307
|
+
core_1.Method()
|
|
308
|
+
], OptionComponent.prototype, "select");
|
|
309
|
+
OptionComponent = __decorate([
|
|
310
|
+
core_1.Component({
|
|
311
|
+
tag: 'ldf-option',
|
|
312
|
+
styleUrl: 'option.scss',
|
|
313
|
+
scoped: true
|
|
314
|
+
})
|
|
315
|
+
], OptionComponent);
|
|
316
|
+
return OptionComponent;
|
|
317
|
+
}());
|
|
318
|
+
exports.OptionComponent = OptionComponent;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
9
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
10
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
11
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
12
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
13
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
14
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
18
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
19
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
20
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
21
|
+
function step(op) {
|
|
22
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
23
|
+
while (_) try {
|
|
24
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
25
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
26
|
+
switch (op[0]) {
|
|
27
|
+
case 0: case 1: t = op; break;
|
|
28
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
29
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
30
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
31
|
+
default:
|
|
32
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
33
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
34
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
35
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
36
|
+
if (t[2]) _.ops.pop();
|
|
37
|
+
_.trys.pop(); continue;
|
|
38
|
+
}
|
|
39
|
+
op = body.call(thisArg, _);
|
|
40
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
41
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
exports.__esModule = true;
|
|
45
|
+
exports.ParallelComponent = void 0;
|
|
46
|
+
var core_1 = require("@stencil/core");
|
|
47
|
+
var ldf_1 = require("@venite/ldf");
|
|
48
|
+
var locale_1 = require("../../utils/locale");
|
|
49
|
+
var parallel_i18n_en_json_1 = require("./parallel.i18n.en.json");
|
|
50
|
+
var LOCALE = {
|
|
51
|
+
'en': parallel_i18n_en_json_1["default"]
|
|
52
|
+
};
|
|
53
|
+
var ParallelComponent = /** @class */ (function () {
|
|
54
|
+
function ParallelComponent() {
|
|
55
|
+
}
|
|
56
|
+
ParallelComponent.prototype.docChanged = function (newDoc) {
|
|
57
|
+
try {
|
|
58
|
+
if (typeof newDoc == 'string') {
|
|
59
|
+
this.obj = new ldf_1.Parallel(JSON.parse(newDoc));
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
this.obj = new ldf_1.Parallel(newDoc);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
console.warn(e);
|
|
67
|
+
this.obj = new ldf_1.Parallel();
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
// Lifecycle events
|
|
71
|
+
ParallelComponent.prototype.componentWillLoad = function () {
|
|
72
|
+
this.docChanged(this.doc);
|
|
73
|
+
this.loadLocaleStrings();
|
|
74
|
+
this.ldfOptionAskForStoredSelection.emit({ el: this.el });
|
|
75
|
+
};
|
|
76
|
+
/** Asynchronously load localization strings */
|
|
77
|
+
ParallelComponent.prototype.loadLocaleStrings = function () {
|
|
78
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
try {
|
|
81
|
+
this.localeStrings = LOCALE[locale_1.getComponentClosestLanguage(this.el)];
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
console.warn(e);
|
|
85
|
+
}
|
|
86
|
+
return [2 /*return*/];
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
// Render
|
|
91
|
+
ParallelComponent.prototype.render = function () {
|
|
92
|
+
var _this = this;
|
|
93
|
+
var _a;
|
|
94
|
+
return (React.createElement(core_1.Host, { lang: this.obj.language },
|
|
95
|
+
React.createElement("tr", null, (((_a = this.obj) === null || _a === void 0 ? void 0 : _a.value) || []).map(function (obj, ii) { return React.createElement("td", null,
|
|
96
|
+
React.createElement("ldf-liturgical-document", { doc: obj, path: _this.path + "/value/" + ii, base: _this.path + "/value", index: ii, editable: _this.editable, parentType: 'option' })); }))));
|
|
97
|
+
};
|
|
98
|
+
__decorate([
|
|
99
|
+
core_1.Element()
|
|
100
|
+
], ParallelComponent.prototype, "el");
|
|
101
|
+
__decorate([
|
|
102
|
+
core_1.State()
|
|
103
|
+
], ParallelComponent.prototype, "obj");
|
|
104
|
+
__decorate([
|
|
105
|
+
core_1.State()
|
|
106
|
+
], ParallelComponent.prototype, "localeStrings");
|
|
107
|
+
__decorate([
|
|
108
|
+
core_1.State()
|
|
109
|
+
], ParallelComponent.prototype, "filteredOptions");
|
|
110
|
+
__decorate([
|
|
111
|
+
core_1.Prop()
|
|
112
|
+
], ParallelComponent.prototype, "doc");
|
|
113
|
+
__decorate([
|
|
114
|
+
core_1.Watch('doc')
|
|
115
|
+
], ParallelComponent.prototype, "docChanged");
|
|
116
|
+
__decorate([
|
|
117
|
+
core_1.Prop({ reflect: true })
|
|
118
|
+
], ParallelComponent.prototype, "path");
|
|
119
|
+
__decorate([
|
|
120
|
+
core_1.Prop()
|
|
121
|
+
], ParallelComponent.prototype, "editable");
|
|
122
|
+
__decorate([
|
|
123
|
+
core_1.Prop()
|
|
124
|
+
], ParallelComponent.prototype, "preview");
|
|
125
|
+
__decorate([
|
|
126
|
+
core_1.Event({ bubbles: true })
|
|
127
|
+
], ParallelComponent.prototype, "ldfAddOptionToDoc");
|
|
128
|
+
__decorate([
|
|
129
|
+
core_1.Event({ bubbles: true })
|
|
130
|
+
], ParallelComponent.prototype, "ldfDocShouldChange");
|
|
131
|
+
__decorate([
|
|
132
|
+
core_1.Event({ bubbles: true })
|
|
133
|
+
], ParallelComponent.prototype, "ldfOptionAskForStoredSelection");
|
|
134
|
+
__decorate([
|
|
135
|
+
core_1.Event({ bubbles: true })
|
|
136
|
+
], ParallelComponent.prototype, "ldfOptionMakeSelection");
|
|
137
|
+
ParallelComponent = __decorate([
|
|
138
|
+
core_1.Component({
|
|
139
|
+
tag: 'ldf-parallel',
|
|
140
|
+
styleUrl: 'parallel.scss',
|
|
141
|
+
scoped: true
|
|
142
|
+
})
|
|
143
|
+
], ParallelComponent);
|
|
144
|
+
return ParallelComponent;
|
|
145
|
+
}());
|
|
146
|
+
exports.ParallelComponent = ParallelComponent;
|