@applicaster/zapp-react-native-utils 13.0.0-alpha.1909212433 → 13.0.0-alpha.2040752175

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applicaster/zapp-react-native-utils",
3
- "version": "13.0.0-alpha.1909212433",
3
+ "version": "13.0.0-alpha.2040752175",
4
4
  "description": "Applicaster Zapp React Native utilities package",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -28,7 +28,7 @@
28
28
  },
29
29
  "homepage": "https://github.com/applicaster/quickbrick#readme",
30
30
  "dependencies": {
31
- "@applicaster/applicaster-types": "13.0.0-alpha.1909212433",
31
+ "@applicaster/applicaster-types": "13.0.0-alpha.2040752175",
32
32
  "buffer": "^5.2.1",
33
33
  "camelize": "^1.0.0",
34
34
  "create-react-context": "^0.2.3",
@@ -1,304 +0,0 @@
1
- // @ts-nocheck
2
- import utils from "../utils";
3
-
4
- describe("generateFontConfiguration", () => {
5
- it("should generate default configuration for tvos", () => {
6
- const expected = [
7
- {
8
- initial_value: 20,
9
- label: "tvOS font Size",
10
- key: "tvos_font_size",
11
- type: "number_input",
12
- },
13
- {
14
- initial_value: 40,
15
- label: "tvOS line Height",
16
- key: "tvos_line_height",
17
- type: "number_input",
18
- },
19
- {
20
- initial_value: 0.4,
21
- label: "tvOS letter Spacing",
22
- key: "tvos_letter_spacing",
23
- type: "number_input",
24
- },
25
- ];
26
-
27
- const platforms = {
28
- tvos: "tvOS",
29
- };
30
-
31
- const generatedFontConfiguration =
32
- utils.generateFontConfiguration(platforms);
33
-
34
- expect(generatedFontConfiguration).toEqual(expected);
35
- });
36
-
37
- it("should generate default configuration for android_tv", () => {
38
- const expected = [
39
- {
40
- initial_value: 20,
41
- label: "Android TV font Size",
42
- key: "android_tv_font_size",
43
- type: "number_input",
44
- },
45
- {
46
- initial_value: 40,
47
- label: "Android TV line Height",
48
- key: "android_tv_line_height",
49
- type: "number_input",
50
- },
51
- {
52
- initial_value: 0.4,
53
- label: "Android TV letter Spacing",
54
- key: "android_tv_letter_spacing",
55
- type: "number_input",
56
- },
57
- ];
58
-
59
- const platforms = {
60
- android_tv: "Android TV",
61
- };
62
-
63
- const generatedFontConfiguration =
64
- utils.generateFontConfiguration(platforms);
65
-
66
- expect(generatedFontConfiguration).toEqual(expected);
67
- });
68
-
69
- it("should generate default configuration for lg_tv", () => {
70
- const expected = [
71
- {
72
- initial_value: 20,
73
- label: "LG TV font Size",
74
- key: "lg_tv_font_size",
75
- type: "number_input",
76
- },
77
- {
78
- initial_value: 40,
79
- label: "LG TV line Height",
80
- key: "lg_tv_line_height",
81
- type: "number_input",
82
- },
83
- {
84
- initial_value: 0.4,
85
- label: "LG TV letter Spacing",
86
- key: "lg_tv_letter_spacing",
87
- type: "number_input",
88
- },
89
- ];
90
-
91
- const platforms = {
92
- lg_tv: "LG TV",
93
- };
94
-
95
- const generatedFontConfiguration =
96
- utils.generateFontConfiguration(platforms);
97
-
98
- expect(generatedFontConfiguration).toEqual(expected);
99
- });
100
-
101
- it("should generate default configuration for samsung_tv", () => {
102
- const expected = [
103
- {
104
- initial_value: 20,
105
- label: "Samsung TV font Size",
106
- key: "samsung_tv_font_size",
107
- type: "number_input",
108
- },
109
- {
110
- initial_value: 40,
111
- label: "Samsung TV line Height",
112
- key: "samsung_tv_line_height",
113
- type: "number_input",
114
- },
115
- {
116
- initial_value: 0.4,
117
- label: "Samsung TV letter Spacing",
118
- key: "samsung_tv_letter_spacing",
119
- type: "number_input",
120
- },
121
- ];
122
-
123
- const platforms = {
124
- samsung_tv: "Samsung TV",
125
- };
126
-
127
- const generatedFontConfiguration =
128
- utils.generateFontConfiguration(platforms);
129
-
130
- expect(generatedFontConfiguration).toEqual(expected);
131
- });
132
- });
133
-
134
- test("conditional_rule helper should return correct object", () => {
135
- expect(utils.conditional_rule("a", "b")).toMatchObject({
136
- key: "a",
137
- condition_value: "b",
138
- });
139
- });
140
-
141
- test("createConditionalConfig helper should return correct object", () => {
142
- expect(
143
- utils.createConditionalConfig([
144
- ["a", "b"],
145
- ["c", "d"],
146
- ])
147
- ).toEqual({
148
- rules: "conditional",
149
- conditional_fields: [
150
- {
151
- key: "a",
152
- condition_value: "b",
153
- },
154
- {
155
- key: "c",
156
- condition_value: "d",
157
- },
158
- ],
159
- });
160
- });
161
-
162
- test("conditional_horizontal_type should contain correct parameters", () => {
163
- expect(
164
- utils.conditional_horizontal_type_item_fixed.conditional_fields[0]
165
- ).toMatchObject({
166
- key: "styles/screen_picker_type",
167
- condition_value: "horizontal",
168
- });
169
- });
170
-
171
- test("conditional_vertical_type should contain correct parameters", () => {
172
- expect(utils.conditional_vertical_type.conditional_fields[0]).toMatchObject({
173
- key: "styles/screen_picker_type",
174
- condition_value: "vertical",
175
- });
176
- });
177
-
178
- test("conditional_horizontal_type_item_fixed should contain correct parameters", () => {
179
- expect(
180
- utils.conditional_horizontal_type_item_fixed.conditional_fields[0]
181
- ).toMatchObject({
182
- key: "styles/screen_picker_type",
183
- condition_value: "horizontal",
184
- });
185
-
186
- expect(
187
- utils.conditional_horizontal_type_item_fixed.conditional_fields[1]
188
- ).toMatchObject({
189
- key: "styles/screen_picker_item_size",
190
- condition_value: "fixed",
191
- });
192
- });
193
-
194
- test("conditional_horizontal_display_type_fixed should contain correct parameters", () => {
195
- expect(
196
- utils.conditional_horizontal_display_type_fixed.conditional_fields[0]
197
- ).toMatchObject({
198
- key: "styles/screen_picker_type",
199
- condition_value: "horizontal",
200
- });
201
-
202
- expect(
203
- utils.conditional_horizontal_display_type_fixed.conditional_fields[1]
204
- ).toMatchObject({
205
- key: "styles/screen_picker_horizontal_display_type",
206
- condition_value: "fixed",
207
- });
208
- });
209
-
210
- test("conditional_horizontal_display_type_fixed should contain correct parameters", () => {
211
- expect(
212
- utils.conditional_horizontal_asset_on.conditional_fields[0]
213
- ).toMatchObject({
214
- key: "styles/screen_picker_type",
215
- condition_value: "horizontal",
216
- });
217
-
218
- expect(
219
- utils.conditional_horizontal_asset_on.conditional_fields[1]
220
- ).toMatchObject({
221
- key: "styles/screen_picker_asset_switch",
222
- condition_value: true,
223
- });
224
- });
225
-
226
- describe("createVariationFields", () => {
227
- const defaultInput = {
228
- key: "somekey",
229
- label: "default somekey label",
230
- variants: [
231
- {
232
- initial_value: "a",
233
- },
234
- {
235
- initial_value: "b",
236
- label: "custom label",
237
- },
238
- ],
239
- };
240
-
241
- const config = utils.createVariationFields(defaultInput);
242
-
243
- it("should return array containing object for conditional_vertical_type", () => {
244
- expect(config[0].rules).toBe("conditional");
245
-
246
- expect(config[0].conditional_fields).toEqual([
247
- {
248
- key: "styles/screen_picker_type",
249
- condition_value: "vertical",
250
- },
251
- ]);
252
-
253
- expect(config[0].type).toBe("number_input");
254
- expect(config[0].key).toBe("screen_picker_vertical_somekey");
255
- expect(config[0].label).toBe("default somekey label");
256
- expect(config[0].initial_value).toBe("a");
257
- });
258
-
259
- it("should return array containing object for conditional_horizontal_type", () => {
260
- expect(config[1].rules).toBe("conditional");
261
-
262
- expect(config[1].conditional_fields).toEqual([
263
- {
264
- key: "styles/screen_picker_type",
265
- condition_value: "horizontal",
266
- },
267
- ]);
268
-
269
- expect(config[1].type).toBe("number_input");
270
- expect(config[1].key).toBe("screen_picker_horizontal_somekey");
271
- expect(config[1].label).toBe("custom label");
272
- expect(config[1].initial_value).toBe("b");
273
- });
274
-
275
- it("should accept custom prefix (empty)", () => {
276
- const config = utils.createVariationFields({
277
- ...defaultInput,
278
- prefix: "",
279
- });
280
-
281
- expect(config[0].key).toBe("vertical_somekey");
282
- expect(config[1].key).toBe("horizontal_somekey");
283
- });
284
-
285
- it("should accept custom prefix (string)", () => {
286
- const config = utils.createVariationFields({
287
- ...defaultInput,
288
- prefix: "string",
289
- });
290
-
291
- expect(config[0].key).toBe("string_vertical_somekey");
292
- expect(config[1].key).toBe("string_horizontal_somekey");
293
- });
294
-
295
- it("should accept custom type (string)", () => {
296
- const config = utils.createVariationFields({
297
- ...defaultInput,
298
- type: "text_input",
299
- });
300
-
301
- expect(config[0].type).toBe("text_input");
302
- expect(config[1].type).toBe("text_input");
303
- });
304
- });
@@ -1,875 +0,0 @@
1
- const {
2
- fieldsGroup,
3
- } = require("@applicaster/zapp-react-native-utils/manifestUtils");
4
-
5
- const {
6
- generateFontConfiguration,
7
- createVariationFields,
8
- conditional_horizontal_type,
9
- conditional_vertical_type,
10
- conditional_horizontal_type_item_fixed,
11
- conditional_horizontal_type_item_dynamic,
12
- conditional_horizontal_asset_on,
13
- conditional_horizontal_display_type_fixed,
14
- } = require("./utils");
15
-
16
- const TRANSPARENT = "rgba(0, 0, 0, 0)";
17
- const fontFamily = "Ubuntu-Medium";
18
-
19
- const componentConfigurationFields = [
20
- {
21
- type: "select",
22
- key: "screen_picker_type",
23
- label: "Screen picker type",
24
- initial_value: "vertical",
25
- options: [
26
- { text: "Vertical", value: "vertical" },
27
- { text: "Horizontal (Beta)", value: "horizontal" },
28
- ],
29
- },
30
- {
31
- type: "select",
32
- key: "screen_picker_horizontal_display_type",
33
- label: "Display",
34
- initial_value: "fixed",
35
- options: [
36
- { text: "Fixed", value: "fixed" },
37
- { text: "Dynamic", value: "dynamic" },
38
- ],
39
- ...conditional_horizontal_type,
40
- },
41
- {
42
- type: "select",
43
- label: "Alignment for Picker container",
44
- key: "screen_picker_items_alignment",
45
- initial_value: "left",
46
- options: [
47
- { text: "Left", value: "left" },
48
- { text: "Right", value: "right" },
49
- { text: "Center", value: "center" },
50
- ],
51
- ...conditional_horizontal_type_item_dynamic,
52
- },
53
- {
54
- type: "select",
55
- label: "Alignment for Picker container items",
56
- key: "screen_picker_horizontal_items_alignment_inner",
57
- initial_value: "left",
58
- options: [
59
- { text: "Left", value: "left" },
60
- { text: "Right", value: "right" },
61
- { text: "Center", value: "center" },
62
- ],
63
- ...conditional_horizontal_display_type_fixed,
64
- },
65
- {
66
- type: "number_input",
67
- label: "Width",
68
- key: "screen_picker_vertical_width",
69
- initial_value: 300,
70
- ...conditional_vertical_type,
71
- },
72
- {
73
- type: "number_input",
74
- label: "Width",
75
- key: "screen_picker_horizontal_width",
76
- initial_value: 1920,
77
- ...conditional_horizontal_display_type_fixed,
78
- },
79
- ...createVariationFields({
80
- label: "X position",
81
- key: "x_position",
82
- variants: [
83
- {
84
- initial_value: 124,
85
- },
86
- {
87
- initial_value: 0,
88
- },
89
- ],
90
- }),
91
- ...createVariationFields({
92
- label: "Y position",
93
- key: "y_position",
94
- variants: [
95
- {
96
- initial_value: 200,
97
- },
98
- {
99
- initial_value: 200,
100
- },
101
- ],
102
- }),
103
- {
104
- type: "number_input",
105
- label: "Padding Top",
106
- key: "component_padding_top",
107
- initial_value: 0,
108
- ...conditional_horizontal_type,
109
- },
110
- {
111
- type: "number_input",
112
- label: "Padding Right",
113
- key: "component_padding_right",
114
- initial_value: 124,
115
- ...conditional_horizontal_type,
116
- },
117
- {
118
- type: "number_input",
119
- label: "Padding Bottom",
120
- key: "component_padding_bottom",
121
- initial_value: 0,
122
- ...conditional_horizontal_type,
123
- },
124
- {
125
- type: "number_input",
126
- label: "Padding Left",
127
- key: "component_padding_left",
128
- initial_value: 124,
129
- },
130
- {
131
- type: "color_picker_rgba",
132
- label: "Background color",
133
- key: "screen_picker_background_color",
134
- initial_value: TRANSPARENT,
135
- ...conditional_horizontal_type,
136
- },
137
- {
138
- type: "uploader",
139
- label: "Background image",
140
- key: "screen_picker_background_image",
141
- initial_value: null,
142
- ...conditional_horizontal_type,
143
- },
144
- {
145
- type: "color_picker_rgba",
146
- label: "Border color",
147
- key: "screen_picker_border_color",
148
- initial_value: TRANSPARENT,
149
- ...conditional_horizontal_type,
150
- },
151
- {
152
- type: "number_input",
153
- label: "Border thickness",
154
- key: "screen_picker_border_thickness",
155
- initial_value: 0,
156
- ...conditional_horizontal_type,
157
- },
158
- {
159
- type: "number_input",
160
- label: "Corner Radius",
161
- key: "screen_picker_corner_radius",
162
- initial_value: 0,
163
- ...conditional_horizontal_type,
164
- },
165
- /* Disabled due to blocker issues with Android TV
166
- Task: https://applicaster.monday.com/boards/1615228456/pulses/4130776042
167
- Discussion: https://applicaster.monday.com/boards/1615228456/pulses/4130775820/posts/2031049491
168
- */
169
- // ...loopFields
170
- ];
171
-
172
- const assetFields = [
173
- {
174
- type: "switch",
175
- key: "screen_picker_asset_switch",
176
- label: "Enable",
177
- initial_value: false,
178
- ...conditional_horizontal_type,
179
- },
180
- {
181
- type: "text_input",
182
- key: "screen_picker_asset_key",
183
- label: "Default data key",
184
- initial_value: "image_base",
185
- ...conditional_horizontal_asset_on,
186
- },
187
- {
188
- type: "switch",
189
- key: "screen_picker_asset_focused_switch",
190
- label: "Enable focused asset",
191
- initial_value: false,
192
- ...conditional_horizontal_asset_on,
193
- },
194
- {
195
- type: "text_input",
196
- key: "screen_picker_asset_focused_key",
197
- label: "Focused data key",
198
- initial_value: "thumb_1",
199
- ...conditional_horizontal_asset_on,
200
- },
201
- {
202
- type: "switch",
203
- key: "screen_picker_asset_selected_switch",
204
- label: "Enable selected asset",
205
- initial_value: false,
206
- ...conditional_horizontal_asset_on,
207
- },
208
- {
209
- type: "text_input",
210
- key: "screen_picker_asset_selected_key",
211
- label: "Selected data key",
212
- initial_value: "thumb_2",
213
- ...conditional_horizontal_asset_on,
214
- },
215
- {
216
- type: "switch",
217
- key: "screen_picker_asset_selectedfocused_switch",
218
- label: "Enable selected & focused asset",
219
- initial_value: false,
220
- ...conditional_horizontal_asset_on,
221
- },
222
- {
223
- type: "text_input",
224
- key: "screen_picker_asset_selectedfocused_key",
225
- label: "Selected & Focused data key",
226
- initial_value: "thumb_3",
227
- ...conditional_horizontal_asset_on,
228
- },
229
- {
230
- type: "number_input",
231
- key: "screen_picker_asset_width",
232
- label: "Width",
233
- initial_value: 40,
234
- ...conditional_horizontal_asset_on,
235
- },
236
- {
237
- type: "number_input",
238
- key: "screen_picker_asset_height",
239
- label: "Height",
240
- initial_value: 40,
241
- ...conditional_horizontal_asset_on,
242
- },
243
- {
244
- type: "number_input",
245
- key: "screen_picker_asset_margin_top",
246
- label: "Margin Top",
247
- initial_value: 0,
248
- ...conditional_horizontal_asset_on,
249
- },
250
- {
251
- type: "number_input",
252
- key: "screen_picker_asset_margin_right",
253
- label: "Margin Right",
254
- initial_value: 16,
255
- ...conditional_horizontal_asset_on,
256
- },
257
- {
258
- type: "number_input",
259
- key: "screen_picker_asset_margin_bottom",
260
- label: "Margin Bottom",
261
- initial_value: 0,
262
- ...conditional_horizontal_asset_on,
263
- },
264
- {
265
- type: "number_input",
266
- key: "screen_picker_asset_margin_left",
267
- label: "Margin Left",
268
- initial_value: 0,
269
- ...conditional_horizontal_asset_on,
270
- },
271
- {
272
- type: "select",
273
- label: "Alignment",
274
- key: "screen_picker_asset_alignment",
275
- initial_value: "left",
276
- options: [
277
- { text: "Top", value: "top" },
278
- { text: "Right", value: "right" },
279
- { text: "Bottom", value: "bottom" },
280
- { text: "Left", value: "left" },
281
- ],
282
- ...conditional_horizontal_asset_on,
283
- },
284
- ];
285
-
286
- const screenPickerItemsFields = [
287
- ...createVariationFields({
288
- key: "gutter",
289
- variants: [
290
- {
291
- label: "Vertical gutter",
292
- initial_value: 10,
293
- },
294
- {
295
- label: "Horizontal gutter",
296
- initial_value: 80,
297
- },
298
- ],
299
- }),
300
- {
301
- type: "select",
302
- label: "Item Size",
303
- key: "screen_picker_item_size",
304
- initial_value: "dynamic",
305
- options: [
306
- { text: "Dynamic", value: "dynamic" },
307
- { text: "Fixed", value: "fixed" },
308
- ],
309
- ...conditional_horizontal_type,
310
- },
311
- {
312
- type: "number_input",
313
- label: "Item Width",
314
- key: "screen_picker_item_width",
315
- initial_value: 200,
316
- ...conditional_horizontal_type_item_fixed,
317
- },
318
- {
319
- type: "select",
320
- label: "Alignment for item content",
321
- key: "screen_picker_item_alignment",
322
- initial_value: "left",
323
- options: [
324
- { text: "Left", value: "left" },
325
- { text: "Right", value: "right" },
326
- { text: "Center", value: "center" },
327
- ],
328
- ...conditional_horizontal_type_item_fixed,
329
- },
330
- ];
331
-
332
- const titleFields = [
333
- {
334
- type: "switch",
335
- label: "Enable",
336
- key: "title_enable",
337
- initial_value: true,
338
- ...conditional_horizontal_type,
339
- },
340
- // font color
341
- ...createVariationFields({
342
- prefix: "default",
343
- type: "color_picker_rgba",
344
- label: "Default font color",
345
- key: "font_color",
346
- variants: [
347
- {
348
- initial_value: "rgba(239, 239, 239, 0.5)",
349
- },
350
- {
351
- initial_value: "rgba(239, 239, 239, 0.5)",
352
- },
353
- ],
354
- }),
355
- ...createVariationFields({
356
- prefix: "focused",
357
- type: "color_picker_rgba",
358
- label: "Focused font color",
359
- key: "font_color",
360
- variants: [
361
- {
362
- initial_value: "rgba(239, 239, 239, 1)",
363
- },
364
- {
365
- initial_value: "rgba(254, 20, 72, 1)",
366
- },
367
- ],
368
- }),
369
- ...createVariationFields({
370
- prefix: "selected",
371
- type: "color_picker_rgba",
372
- label: "Selected font color",
373
- key: "font_color",
374
- variants: [
375
- {
376
- initial_value: "rgba(239, 239, 239, 1)",
377
- },
378
- {
379
- initial_value: "rgba(239, 239, 239, 1)",
380
- },
381
- ],
382
- }),
383
- ...createVariationFields({
384
- prefix: "selected_focused",
385
- type: "color_picker_rgba",
386
- label: "Selected & Focused font color",
387
- key: "font_color",
388
- variants: [
389
- {
390
- initial_value: "rgba(239, 239, 239, 1)",
391
- },
392
- {
393
- initial_value: "rgba(254, 20, 72, 1)",
394
- },
395
- ],
396
- }),
397
- // fonts
398
- {
399
- type: "tvos_font_selector",
400
- label: "tvOS Font Family",
401
- key: "tvos_font_family",
402
- initial_value: fontFamily,
403
- },
404
- {
405
- type: "android_font_selector",
406
- label: "Android TV Font Family",
407
- key: "android_tv_font_family",
408
- initial_value: fontFamily,
409
- },
410
- {
411
- type: "lg_tv_font_selector",
412
- label: "LG TV Font Family",
413
- key: "lg_tv_font_family",
414
- initial_value: fontFamily,
415
- },
416
- {
417
- type: "samsung_font_selector",
418
- label: "Samsung TV Font Family",
419
- key: "samsung_tv_font_family",
420
- initial_value: fontFamily,
421
- },
422
- {
423
- type: "vizio_font_selector",
424
- label: "Vizio TV Font Family",
425
- key: "vizio_font_family",
426
- initial_value: fontFamily,
427
- },
428
- ...generateFontConfiguration(),
429
- // text transform
430
- {
431
- type: "select",
432
- label: "Text Transform",
433
- key: "text_transform",
434
- initial_value: "uppercase",
435
- options: ["default", "uppercase", "lowercase", "capitalize"],
436
- },
437
- // number of lines
438
- {
439
- type: "number_input",
440
- label: "number of lines",
441
- key: "number_of_lines",
442
- initial_value: 1,
443
- ...conditional_vertical_type,
444
- },
445
- ];
446
-
447
- const itemFields = [
448
- // underline color
449
- ...createVariationFields({
450
- prefix: "default",
451
- type: "color_picker_rgba",
452
- label: "Default underline color",
453
- key: "underline_color",
454
- variants: [
455
- {
456
- initial_value: TRANSPARENT,
457
- },
458
- {
459
- initial_value: TRANSPARENT,
460
- },
461
- ],
462
- }),
463
- ...createVariationFields({
464
- prefix: "focused",
465
- type: "color_picker_rgba",
466
- label: "Focused underline color",
467
- key: "underline_color",
468
- variants: [
469
- {
470
- initial_value: TRANSPARENT,
471
- },
472
- {
473
- initial_value: "rgba(254, 20, 72, 1)",
474
- },
475
- ],
476
- }),
477
- ...createVariationFields({
478
- prefix: "selected",
479
- type: "color_picker_rgba",
480
- label: "Selected underline color",
481
- key: "underline_color",
482
- variants: [
483
- {
484
- initial_value: TRANSPARENT,
485
- },
486
- {
487
- initial_value: "rgba(239, 239, 239, 1)",
488
- },
489
- ],
490
- }),
491
- ...createVariationFields({
492
- prefix: "selected_focused",
493
- type: "color_picker_rgba",
494
- label: "Selected & Focused underline color",
495
- key: "underline_color",
496
- variants: [
497
- {
498
- initial_value: TRANSPARENT,
499
- },
500
- {
501
- initial_value: "rgba(254, 20, 72, 1)",
502
- },
503
- ],
504
- }),
505
- // underline thickness
506
- ...createVariationFields({
507
- prefix: "",
508
- label: "Underline Thickness",
509
- key: "underline_thickness",
510
- variants: [
511
- {
512
- initial_value: 0,
513
- },
514
- {
515
- initial_value: 6,
516
- },
517
- ],
518
- }),
519
- // underline corner radius
520
- ...createVariationFields({
521
- prefix: "",
522
- label: "Underline corner radius",
523
- key: "underline_corner_radius",
524
- variants: [
525
- {
526
- initial_value: 0,
527
- },
528
- {
529
- initial_value: 3,
530
- },
531
- ],
532
- }),
533
- // text bg color
534
- {
535
- type: "color_picker_rgba",
536
- label: "Default Text Background color",
537
- key: "default_text_background_color",
538
- initial_value: TRANSPARENT,
539
- ...conditional_vertical_type,
540
- },
541
- {
542
- type: "color_picker_rgba",
543
- label: "Focused Text Background color",
544
- key: "focused_text_background_color",
545
- initial_value: TRANSPARENT,
546
- ...conditional_vertical_type,
547
- },
548
- {
549
- type: "color_picker_rgba",
550
- label: "Selected Text Background color",
551
- key: "selected_text_background_color",
552
- initial_value: TRANSPARENT,
553
- ...conditional_vertical_type,
554
- },
555
- {
556
- type: "color_picker_rgba",
557
- label: "Selected & Focused Text Background color",
558
- key: "selected_focused_text_background_color",
559
- initial_value: TRANSPARENT,
560
- ...conditional_vertical_type,
561
- },
562
- // text item border_thickness
563
- {
564
- type: "number_input",
565
- label: "Text Item border thickness",
566
- key: "text_border_thickness",
567
- initial_value: 0,
568
- ...conditional_vertical_type,
569
- },
570
- // text item corner radius
571
- {
572
- type: "number_input",
573
- label: "Text Item corner radius",
574
- key: "text_corner_radius",
575
- initial_value: 0,
576
- ...conditional_vertical_type,
577
- },
578
- // text border color
579
- {
580
- type: "color_picker_rgba",
581
- label: "Default Text border color",
582
- key: "default_text_border_color",
583
- initial_value: TRANSPARENT,
584
- ...conditional_vertical_type,
585
- },
586
- {
587
- type: "color_picker_rgba",
588
- label: "Focused Text border color",
589
- key: "focused_text_border_color",
590
- initial_value: TRANSPARENT,
591
- ...conditional_vertical_type,
592
- },
593
- {
594
- type: "color_picker_rgba",
595
- label: "Selected Text border color",
596
- key: "selected_text_border_color",
597
- initial_value: TRANSPARENT,
598
- ...conditional_vertical_type,
599
- },
600
- {
601
- type: "color_picker_rgba",
602
- label: "Selected & Focused Text border color",
603
- key: "selected_focused_text_border_color",
604
- initial_value: TRANSPARENT,
605
- ...conditional_vertical_type,
606
- },
607
- // item margin
608
- {
609
- type: "number_input",
610
- label: "Item Margin top",
611
- key: "item_margin_top",
612
- initial_value: 0,
613
- },
614
- {
615
- type: "number_input",
616
- label: "Item Margin Right",
617
- key: "item_margin_right",
618
- initial_value: 0,
619
- },
620
- {
621
- type: "number_input",
622
- label: "Item Margin Bottom",
623
- key: "item_margin_bottom",
624
- initial_value: 0,
625
- },
626
- {
627
- type: "number_input",
628
- label: "Item Margin Left",
629
- key: "item_margin_left",
630
- initial_value: 0,
631
- },
632
- // text item padding
633
- {
634
- type: "number_input",
635
- label: "Text Item Padding Top",
636
- key: "item_padding_top",
637
- initial_value: 12,
638
- ...conditional_vertical_type,
639
- },
640
- {
641
- type: "number_input",
642
- label: "Text Item Padding Right",
643
- key: "item_padding_right",
644
- initial_value: 24,
645
- ...conditional_vertical_type,
646
- },
647
- {
648
- type: "number_input",
649
- label: "Text Item Padding Bottom",
650
- key: "item_padding_bottom",
651
- initial_value: 12,
652
- ...conditional_vertical_type,
653
- },
654
- {
655
- type: "number_input",
656
- label: "Text Item Padding Left",
657
- key: "item_padding_left",
658
- initial_value: 24,
659
- ...conditional_vertical_type,
660
- },
661
- // text padding
662
- ...createVariationFields({
663
- prefix: "text",
664
- type: "number_input",
665
- label: "Text Padding Top",
666
- key: "padding_top",
667
- variants: [
668
- {
669
- initial_value: 0,
670
- },
671
- {
672
- initial_value: 12,
673
- },
674
- ],
675
- }),
676
- ...createVariationFields({
677
- prefix: "text",
678
- type: "number_input",
679
- label: "Text Padding Right",
680
- key: "padding_right",
681
- variants: [
682
- {
683
- initial_value: 0,
684
- },
685
- {
686
- initial_value: 0,
687
- },
688
- ],
689
- }),
690
- ...createVariationFields({
691
- prefix: "text",
692
- type: "number_input",
693
- label: "Text Padding Bottom",
694
- key: "padding_bottom",
695
- variants: [
696
- {
697
- initial_value: 0,
698
- },
699
- {
700
- initial_value: 12,
701
- },
702
- ],
703
- }),
704
- ...createVariationFields({
705
- prefix: "text",
706
- type: "number_input",
707
- label: "Text Padding Left",
708
- key: "padding_left",
709
- variants: [
710
- {
711
- initial_value: 0,
712
- },
713
- {
714
- initial_value: 0,
715
- },
716
- ],
717
- }),
718
- // item bg color
719
- ...createVariationFields({
720
- prefix: "default",
721
- type: "color_picker_rgba",
722
- label: "Default Item background color",
723
- key: "item_background_color",
724
- variants: [
725
- {
726
- initial_value: TRANSPARENT,
727
- },
728
- {
729
- initial_value: TRANSPARENT,
730
- },
731
- ],
732
- }),
733
- ...createVariationFields({
734
- prefix: "focused",
735
- type: "color_picker_rgba",
736
- label: "Focused Item background color",
737
- key: "item_background_color",
738
- variants: [
739
- {
740
- initial_value: "rgba(254, 20, 72, 1)",
741
- },
742
- {
743
- initial_value: TRANSPARENT,
744
- },
745
- ],
746
- }),
747
- ...createVariationFields({
748
- prefix: "selected",
749
- type: "color_picker_rgba",
750
- label: "Selected Item background color",
751
- key: "item_background_color",
752
- variants: [
753
- {
754
- initial_value: TRANSPARENT,
755
- },
756
- {
757
- initial_value: TRANSPARENT,
758
- },
759
- ],
760
- }),
761
- ...createVariationFields({
762
- prefix: "selected_focused",
763
- type: "color_picker_rgba",
764
- label: "Selected & Focused Item background color",
765
- key: "item_background_color",
766
- variants: [
767
- {
768
- initial_value: "rgba(254, 20, 72, 1)",
769
- },
770
- {
771
- initial_value: TRANSPARENT,
772
- },
773
- ],
774
- }),
775
- // item border color
776
- ...createVariationFields({
777
- prefix: "default",
778
- type: "color_picker_rgba",
779
- label: "Default Item border color",
780
- key: "item_border_color",
781
- variants: [
782
- {
783
- initial_value: TRANSPARENT,
784
- },
785
- {
786
- initial_value: TRANSPARENT,
787
- },
788
- ],
789
- }),
790
- ...createVariationFields({
791
- prefix: "focused",
792
- type: "color_picker_rgba",
793
- label: "Focused Item border color",
794
- key: "item_border_color",
795
- variants: [
796
- {
797
- initial_value: TRANSPARENT,
798
- },
799
- {
800
- initial_value: TRANSPARENT,
801
- },
802
- ],
803
- }),
804
- ...createVariationFields({
805
- prefix: "selected",
806
- type: "color_picker_rgba",
807
- label: "Selected Item border color",
808
- key: "item_border_color",
809
- variants: [
810
- {
811
- initial_value: "rgba(239, 239, 239, 0.5)",
812
- },
813
- {
814
- initial_value: TRANSPARENT,
815
- },
816
- ],
817
- }),
818
- ...createVariationFields({
819
- prefix: "selected_focused",
820
- type: "color_picker_rgba",
821
- label: "Selected & Focused Item border color",
822
- key: "item_border_color",
823
- variants: [
824
- {
825
- initial_value: TRANSPARENT,
826
- },
827
- {
828
- initial_value: TRANSPARENT,
829
- },
830
- ],
831
- }),
832
- // item border thickness
833
- ...createVariationFields({
834
- prefix: "",
835
- label: "Item Border Thickness",
836
- key: "item_border_thickness",
837
- variants: [
838
- {
839
- initial_value: 2,
840
- },
841
- {
842
- initial_value: 0,
843
- },
844
- ],
845
- }),
846
- // item corner radius
847
- ...createVariationFields({
848
- prefix: "",
849
- label: "Item Corner radius",
850
- key: "item_corner_radius",
851
- variants: [
852
- {
853
- initial_value: 8,
854
- },
855
- {
856
- initial_value: 0,
857
- },
858
- ],
859
- }),
860
- ];
861
-
862
- const stylesFields = [
863
- fieldsGroup(
864
- "Component Configuration",
865
- "",
866
- componentConfigurationFields,
867
- false
868
- ),
869
- fieldsGroup("Screen Picker Items", "", screenPickerItemsFields, false),
870
- fieldsGroup("Asset", "", assetFields, false),
871
- fieldsGroup("Title", "", titleFields, false),
872
- fieldsGroup("Item", "", itemFields, false),
873
- ];
874
-
875
- module.exports = stylesFields;
@@ -1,130 +0,0 @@
1
- const defaultPlatforms = {
2
- tvos: "tvOS",
3
- android_tv: "Android TV",
4
- lg_tv: "LG TV",
5
- samsung_tv: "Samsung TV",
6
- };
7
-
8
- const global_defaults = {
9
- fontSize: 20,
10
- lineHeight: 40,
11
- letterSpacing: 0.4,
12
- };
13
-
14
- const generateFontConfiguration = (platforms = defaultPlatforms) => {
15
- const platformEntries = Object.entries(platforms);
16
- const defaultsEntries = Object.entries(global_defaults);
17
- const splitCamelCase = (str) => str.replace(/([a-z](?=[A-Z]))/g, "$1_");
18
-
19
- return platformEntries.reduce((acc, [platformKey, platformValue]) => {
20
- acc.push(
21
- ...defaultsEntries.reduce((acc2, [valueKey, defaultValue]) => {
22
- acc2.push({
23
- type: "number_input",
24
- label: `${platformValue} ${splitCamelCase(valueKey).replace(
25
- "_",
26
- " "
27
- )}`,
28
- key: `${platformKey}_${splitCamelCase(valueKey)}`.toLowerCase(),
29
- initial_value: defaultValue,
30
- });
31
-
32
- return acc2;
33
- }, [])
34
- );
35
-
36
- return acc;
37
- }, []);
38
- };
39
-
40
- const conditional_rule = (key, condition_value) => ({
41
- key,
42
- condition_value,
43
- });
44
-
45
- const createConditionalConfig = (rules, matchAll = false) => ({
46
- rules: matchAll ? "all_conditions" : "conditional",
47
- conditional_fields: rules.map((field) => conditional_rule(...field)),
48
- });
49
-
50
- const conditional_horizontal_type = createConditionalConfig([
51
- ["styles/screen_picker_type", "horizontal"],
52
- ]);
53
-
54
- const conditional_vertical_type = createConditionalConfig([
55
- ["styles/screen_picker_type", "vertical"],
56
- ]);
57
-
58
- const conditional_horizontal_type_item_fixed = createConditionalConfig(
59
- [
60
- ["styles/screen_picker_type", "horizontal"],
61
- ["styles/screen_picker_item_size", "fixed"],
62
- ],
63
- true
64
- );
65
-
66
- const conditional_horizontal_type_item_dynamic = createConditionalConfig(
67
- [
68
- ["styles/screen_picker_type", "horizontal"],
69
- ["screen_picker_horizontal_display_type", "dynamic"],
70
- ],
71
- true
72
- );
73
-
74
- const conditional_horizontal_display_type_fixed = createConditionalConfig(
75
- [
76
- ["styles/screen_picker_type", "horizontal"],
77
- ["styles/screen_picker_horizontal_display_type", "fixed"],
78
- ],
79
- true
80
- );
81
-
82
- const conditional_horizontal_asset_on = createConditionalConfig(
83
- [
84
- ["styles/screen_picker_type", "horizontal"],
85
- ["styles/screen_picker_asset_switch", true],
86
- ],
87
- true
88
- );
89
-
90
- const createVariationFields = ({
91
- prefix = "screen_picker",
92
- key,
93
- type = "number_input",
94
- label = "",
95
- variants: [a, b],
96
- }) => {
97
- return [
98
- {
99
- type,
100
- key: `${prefix}${prefix.length > 0 ? "_" : ""}${
101
- a?.key ?? "vertical"
102
- }_${key}`,
103
- label: a?.label ?? label,
104
- initial_value: a.initial_value,
105
- ...conditional_vertical_type,
106
- },
107
- {
108
- type,
109
- key: `${prefix}${prefix.length > 0 ? "_" : ""}${
110
- b.key ?? "horizontal"
111
- }_${key}`,
112
- label: b?.label ?? label,
113
- initial_value: b.initial_value,
114
- ...conditional_horizontal_type,
115
- },
116
- ];
117
- };
118
-
119
- module.exports = {
120
- generateFontConfiguration,
121
- createVariationFields,
122
- createConditionalConfig,
123
- conditional_rule,
124
- conditional_horizontal_type,
125
- conditional_vertical_type,
126
- conditional_horizontal_type_item_fixed,
127
- conditional_horizontal_type_item_dynamic,
128
- conditional_horizontal_display_type_fixed,
129
- conditional_horizontal_asset_on,
130
- };