@monimesl/dot-core 0.1.0-alpha.2 → 0.1.0-alpha.4

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/index.js CHANGED
@@ -87,17 +87,251 @@ var SourceError = class extends Error {
87
87
  }
88
88
  };
89
89
  //#endregion
90
+ //#region src/view/components/amount-input.ts
91
+ const AmountInput = defineComponent({
92
+ name: "AmountInput",
93
+ props: {
94
+ value: "number",
95
+ currency: "string",
96
+ decimals: "number",
97
+ label: "string",
98
+ placeholder: "string",
99
+ hint: "string",
100
+ error: "string",
101
+ disabled: "boolean"
102
+ },
103
+ events: ["change"],
104
+ children: "none"
105
+ });
106
+ //#endregion
90
107
  //#region src/view/components/button.ts
91
108
  const Button = defineComponent({
92
109
  name: "Button",
93
110
  props: {
94
111
  variant: ["primary", "secondary"],
95
- disabled: "boolean"
112
+ disabled: "boolean",
113
+ loading: "boolean"
96
114
  },
97
115
  events: ["click"],
98
116
  children: "text"
99
117
  });
100
118
  //#endregion
119
+ //#region src/view/components/options.ts
120
+ const SIZES = [
121
+ "small",
122
+ "medium",
123
+ "large"
124
+ ];
125
+ const SPACES = [
126
+ "none",
127
+ "small",
128
+ "medium",
129
+ "large"
130
+ ];
131
+ const TONES = [
132
+ "default",
133
+ "muted",
134
+ "info",
135
+ "success",
136
+ "warning",
137
+ "danger"
138
+ ];
139
+ const STATUS_TONES = [
140
+ "default",
141
+ "info",
142
+ "success",
143
+ "warning",
144
+ "danger"
145
+ ];
146
+ const ICON_NAMES = [
147
+ "arrow-down",
148
+ "arrow-left",
149
+ "arrow-right",
150
+ "arrow-up",
151
+ "bank",
152
+ "bell",
153
+ "bolt",
154
+ "calendar",
155
+ "card",
156
+ "cart",
157
+ "cash",
158
+ "check",
159
+ "chevron-down",
160
+ "chevron-left",
161
+ "chevron-right",
162
+ "chevron-up",
163
+ "clock",
164
+ "close",
165
+ "copy",
166
+ "download",
167
+ "edit",
168
+ "error",
169
+ "eye",
170
+ "eye-off",
171
+ "file",
172
+ "gift",
173
+ "grid",
174
+ "heart",
175
+ "help",
176
+ "history",
177
+ "home",
178
+ "image",
179
+ "info",
180
+ "list",
181
+ "location",
182
+ "lock",
183
+ "logout",
184
+ "mail",
185
+ "minus",
186
+ "mobile",
187
+ "more",
188
+ "phone",
189
+ "plus",
190
+ "qr-code",
191
+ "receipt",
192
+ "refresh",
193
+ "search",
194
+ "send",
195
+ "settings",
196
+ "share",
197
+ "star",
198
+ "success",
199
+ "trash",
200
+ "upload",
201
+ "user",
202
+ "users",
203
+ "wallet",
204
+ "warning",
205
+ "water",
206
+ "wifi"
207
+ ];
208
+ //#endregion
209
+ //#region src/view/components/carousel.ts
210
+ const Carousel = defineComponent({
211
+ name: "Carousel",
212
+ props: {
213
+ autoplay: "boolean",
214
+ interval: "number",
215
+ loop: "boolean",
216
+ indicator: ["dots", "none"],
217
+ gap: SPACES,
218
+ effect: ["slide", "scale"],
219
+ index: "number"
220
+ },
221
+ events: ["change"],
222
+ children: "elements"
223
+ });
224
+ //#endregion
225
+ //#region src/view/components/chip.ts
226
+ const Chip = defineComponent({
227
+ name: "Chip",
228
+ props: {
229
+ label: "string",
230
+ icon: ICON_NAMES,
231
+ selected: "boolean",
232
+ disabled: "boolean"
233
+ },
234
+ events: ["tap"],
235
+ children: "none"
236
+ });
237
+ //#endregion
238
+ //#region src/view/components/code-input.ts
239
+ const CodeInput = defineComponent({
240
+ name: "CodeInput",
241
+ props: {
242
+ value: "string",
243
+ length: "number",
244
+ label: "string",
245
+ hint: "string",
246
+ error: "string",
247
+ secure: "boolean",
248
+ disabled: "boolean"
249
+ },
250
+ events: ["change", "complete"],
251
+ children: "none"
252
+ });
253
+ //#endregion
254
+ //#region src/view/components/divider.ts
255
+ const Divider = defineComponent({
256
+ name: "Divider",
257
+ children: "none"
258
+ });
259
+ //#endregion
260
+ //#region src/view/components/empty-state.ts
261
+ const EmptyState = defineComponent({
262
+ name: "EmptyState",
263
+ props: {
264
+ icon: ICON_NAMES,
265
+ title: "string",
266
+ text: "string"
267
+ },
268
+ children: "elements"
269
+ });
270
+ //#endregion
271
+ //#region src/view/components/feedback.ts
272
+ const Spinner = defineComponent({
273
+ name: "Spinner",
274
+ props: { size: SIZES },
275
+ children: "none"
276
+ });
277
+ const ProgressBar = defineComponent({
278
+ name: "ProgressBar",
279
+ props: { value: "number" },
280
+ children: "none"
281
+ });
282
+ const Notice = defineComponent({
283
+ name: "Notice",
284
+ props: {
285
+ tone: STATUS_TONES,
286
+ title: "string"
287
+ },
288
+ children: "text"
289
+ });
290
+ const Badge = defineComponent({
291
+ name: "Badge",
292
+ props: { tone: STATUS_TONES },
293
+ children: "text"
294
+ });
295
+ //#endregion
296
+ //#region src/view/components/footer.ts
297
+ const Footer = defineComponent({
298
+ name: "Footer",
299
+ children: "elements"
300
+ });
301
+ //#endregion
302
+ //#region src/view/components/grid.ts
303
+ const Grid = defineComponent({
304
+ name: "Grid",
305
+ props: {
306
+ columns: "number",
307
+ gap: SPACES
308
+ },
309
+ children: "elements"
310
+ });
311
+ const GridItem = defineComponent({
312
+ name: "GridItem",
313
+ props: {
314
+ label: "string",
315
+ icon: ICON_NAMES,
316
+ image: "string",
317
+ badge: "string"
318
+ },
319
+ events: ["tap"],
320
+ children: "none"
321
+ });
322
+ //#endregion
323
+ //#region src/view/components/icon.ts
324
+ const Icon = defineComponent({
325
+ name: "Icon",
326
+ props: {
327
+ name: ICON_NAMES,
328
+ size: SIZES,
329
+ tone: TONES
330
+ },
331
+ children: "none",
332
+ inline: true
333
+ });
334
+ //#endregion
101
335
  //#region src/view/components/image.ts
102
336
  const Image = defineComponent({
103
337
  name: "Image",
@@ -105,7 +339,13 @@ const Image = defineComponent({
105
339
  src: "string",
106
340
  alt: "string",
107
341
  width: "number",
108
- height: "number"
342
+ height: "number",
343
+ fit: ["cover", "contain"],
344
+ shape: [
345
+ "rounded",
346
+ "square",
347
+ "circle"
348
+ ]
109
349
  },
110
350
  events: ["load", "error"],
111
351
  children: "none"
@@ -118,6 +358,10 @@ const Input = defineComponent({
118
358
  value: "string",
119
359
  placeholder: "string",
120
360
  label: "string",
361
+ hint: "string",
362
+ error: "string",
363
+ prefix: "string",
364
+ suffix: "string",
121
365
  type: [
122
366
  "text",
123
367
  "number",
@@ -132,35 +376,223 @@ const Input = defineComponent({
132
376
  children: "none"
133
377
  });
134
378
  //#endregion
379
+ //#region src/view/components/list.ts
380
+ const List = defineComponent({
381
+ name: "List",
382
+ children: "elements"
383
+ });
384
+ const ListItem = defineComponent({
385
+ name: "ListItem",
386
+ props: {
387
+ title: "string",
388
+ subtitle: "string",
389
+ value: "string",
390
+ icon: ICON_NAMES,
391
+ image: "string"
392
+ },
393
+ events: ["tap"],
394
+ children: "elements"
395
+ });
396
+ //#endregion
397
+ //#region src/view/components/overlays.ts
398
+ const Sheet = defineComponent({
399
+ name: "Sheet",
400
+ props: {
401
+ open: "boolean",
402
+ title: "string"
403
+ },
404
+ events: ["close"],
405
+ children: "elements"
406
+ });
407
+ const Toast = defineComponent({
408
+ name: "Toast",
409
+ props: {
410
+ message: "string",
411
+ tone: STATUS_TONES,
412
+ duration: "number"
413
+ },
414
+ events: ["hide"],
415
+ children: "none"
416
+ });
417
+ //#endregion
418
+ //#region src/view/components/qr-code.ts
419
+ const QRCode = defineComponent({
420
+ name: "QRCode",
421
+ props: {
422
+ value: "string",
423
+ size: "number",
424
+ label: "string"
425
+ },
426
+ children: "none"
427
+ });
428
+ //#endregion
429
+ //#region src/view/components/select.ts
430
+ const Select = defineComponent({
431
+ name: "Select",
432
+ props: {
433
+ value: "string",
434
+ label: "string",
435
+ placeholder: "string",
436
+ hint: "string",
437
+ error: "string",
438
+ disabled: "boolean"
439
+ },
440
+ events: ["change"],
441
+ children: "elements"
442
+ });
443
+ const Option = defineComponent({
444
+ name: "Option",
445
+ props: {
446
+ value: "string",
447
+ label: "string"
448
+ },
449
+ children: "none"
450
+ });
451
+ //#endregion
452
+ //#region src/view/components/skeleton.ts
453
+ const Skeleton = defineComponent({
454
+ name: "Skeleton",
455
+ props: {
456
+ shape: [
457
+ "text",
458
+ "circle",
459
+ "box"
460
+ ],
461
+ lines: "number",
462
+ height: "number"
463
+ },
464
+ children: "none"
465
+ });
466
+ //#endregion
467
+ //#region src/view/components/tabs.ts
468
+ const Tabs = defineComponent({
469
+ name: "Tabs",
470
+ props: {
471
+ value: "string",
472
+ variant: ["underline", "segmented"]
473
+ },
474
+ events: ["change"],
475
+ children: "elements"
476
+ });
477
+ const Tab = defineComponent({
478
+ name: "Tab",
479
+ props: {
480
+ value: "string",
481
+ label: "string",
482
+ badge: "number"
483
+ },
484
+ children: "none"
485
+ });
486
+ //#endregion
135
487
  //#region src/view/components/text.ts
136
488
  const Text = defineComponent({
137
489
  name: "Text",
138
- props: { variant: [
139
- "title",
140
- "body",
141
- "caption"
142
- ] },
490
+ props: {
491
+ variant: [
492
+ "title",
493
+ "body",
494
+ "caption"
495
+ ],
496
+ tone: TONES,
497
+ weight: [
498
+ "regular",
499
+ "medium",
500
+ "bold"
501
+ ],
502
+ align: [
503
+ "start",
504
+ "center",
505
+ "end"
506
+ ],
507
+ maxLines: "number"
508
+ },
143
509
  children: "text",
144
510
  inline: true
145
511
  });
146
512
  //#endregion
513
+ //#region src/view/components/text-area.ts
514
+ const TextArea = defineComponent({
515
+ name: "TextArea",
516
+ props: {
517
+ value: "string",
518
+ placeholder: "string",
519
+ label: "string",
520
+ hint: "string",
521
+ error: "string",
522
+ rows: "number",
523
+ maxLength: "number",
524
+ disabled: "boolean"
525
+ },
526
+ events: ["change"],
527
+ children: "none"
528
+ });
529
+ //#endregion
530
+ //#region src/view/components/toggles.ts
531
+ const Switch = defineComponent({
532
+ name: "Switch",
533
+ props: {
534
+ checked: "boolean",
535
+ label: "string",
536
+ disabled: "boolean"
537
+ },
538
+ events: ["change"],
539
+ children: "none"
540
+ });
541
+ const Checkbox = defineComponent({
542
+ name: "Checkbox",
543
+ props: {
544
+ checked: "boolean",
545
+ label: "string",
546
+ disabled: "boolean"
547
+ },
548
+ events: ["change"],
549
+ children: "none"
550
+ });
551
+ const RadioGroup = defineComponent({
552
+ name: "RadioGroup",
553
+ props: {
554
+ value: "string",
555
+ label: "string",
556
+ disabled: "boolean"
557
+ },
558
+ events: ["change"],
559
+ children: "elements"
560
+ });
561
+ const Radio = defineComponent({
562
+ name: "Radio",
563
+ props: {
564
+ value: "string",
565
+ label: "string",
566
+ disabled: "boolean"
567
+ },
568
+ children: "none"
569
+ });
570
+ //#endregion
147
571
  //#region src/view/components/view.ts
148
572
  const View = defineComponent({
149
573
  name: "View",
150
574
  props: {
575
+ gap: SPACES,
151
576
  direction: ["column", "row"],
152
- gap: [
153
- "none",
154
- "small",
155
- "medium",
156
- "large"
157
- ],
158
577
  align: [
159
578
  "stretch",
160
579
  "start",
161
580
  "center",
162
581
  "end"
163
582
  ],
583
+ justify: [
584
+ "start",
585
+ "center",
586
+ "end",
587
+ "between"
588
+ ],
589
+ wrap: "boolean",
590
+ grow: "boolean",
591
+ padding: SPACES,
592
+ paddingTop: SPACES,
593
+ paddingStart: SPACES,
594
+ paddingEnd: SPACES,
595
+ paddingBottom: SPACES,
164
596
  variant: ["plain", "card"]
165
597
  },
166
598
  events: ["tap"],
@@ -169,10 +601,39 @@ const View = defineComponent({
169
601
  //#endregion
170
602
  //#region src/view/components/index.ts
171
603
  const builtinComponents = {
604
+ AmountInput,
605
+ Badge,
172
606
  Button,
607
+ Carousel,
608
+ Checkbox,
609
+ Chip,
610
+ CodeInput,
611
+ Divider,
612
+ EmptyState,
613
+ Footer,
614
+ Grid,
615
+ GridItem,
616
+ Icon,
173
617
  Image,
174
618
  Input,
619
+ List,
620
+ ListItem,
621
+ Notice,
622
+ Option,
623
+ ProgressBar,
624
+ QRCode,
625
+ Radio,
626
+ RadioGroup,
627
+ Select,
628
+ Sheet,
629
+ Skeleton,
630
+ Spinner,
631
+ Switch,
632
+ Tab,
633
+ Tabs,
175
634
  Text,
635
+ TextArea,
636
+ Toast,
176
637
  View
177
638
  };
178
639
  const builtinRegistry = componentRegistry(Object.values(builtinComponents));
@@ -192,10 +653,11 @@ var EventEmitter = class {
192
653
  };
193
654
  //#endregion
194
655
  //#region src/event/core.ts
195
- function createEvent(type, detail = {}) {
656
+ function createEvent(type, detail = {}, data = {}) {
196
657
  return {
197
658
  type,
198
- detail
659
+ detail,
660
+ data
199
661
  };
200
662
  }
201
663
  //#endregion
@@ -244,6 +706,33 @@ function isPermission(value) {
244
706
  return PERMISSIONS.includes(value);
245
707
  }
246
708
  //#endregion
709
+ //#region src/host/files.ts
710
+ const DOT_FILE_PATH_MAX_LENGTH = 512;
711
+ const MAX_NAME_LENGTH = 255;
712
+ function dotFilePathProblem(path, { allowRoot = false } = {}) {
713
+ if (path === "") return allowRoot ? null : "A path is needed, such as \"receipts/42.pdf\"";
714
+ if (path.length > 512) return `"${path.slice(0, 40)}…" is longer than 512 characters`;
715
+ if (path.startsWith("/")) return `"${path}" starts with "/": paths are relative to the dot's storage, such as "receipts/42.pdf"`;
716
+ if ([...path].some((char) => char === "\\" || char.charCodeAt(0) < 32)) return `"${path}" has a backslash or a control character`;
717
+ for (const name of path.split("/")) {
718
+ if (name === "" || name === "." || name === "..") return `"${path}" has an empty, "." or ".." part: write each folder once, such as "receipts/42.pdf"`;
719
+ if (name.length > MAX_NAME_LENGTH) return `"${path}" has a name longer than ${MAX_NAME_LENGTH} characters`;
720
+ }
721
+ return null;
722
+ }
723
+ //#endregion
724
+ //#region src/host/network.ts
725
+ const LABEL = "[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?";
726
+ const NETWORK_HOST_PATTERN = new RegExp(`^(?:\\*\\.${LABEL}(?:\\.${LABEL})+|${LABEL}(?:\\.${LABEL})*)$`);
727
+ const NETWORK_HOST_MAX_LENGTH = 253;
728
+ function isNetworkHost(value) {
729
+ return value.length <= 253 && NETWORK_HOST_PATTERN.test(value);
730
+ }
731
+ function allowsHost(hosts, host) {
732
+ const name = host.toLowerCase().replace(/\.$/, "");
733
+ return hosts.some((pattern) => pattern.startsWith("*.") ? name.endsWith(pattern.slice(1)) : name === pattern);
734
+ }
735
+ //#endregion
247
736
  //#region src/version/semantic-version.ts
248
737
  const SEMVER_PATTERN = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
249
738
  function isSemanticVersion(value) {
@@ -405,6 +894,42 @@ function applyChanges(state, changes) {
405
894
  return next;
406
895
  }
407
896
  //#endregion
897
+ //#region src/page/bars.ts
898
+ const HEX_COLOR = /^#[0-9a-fA-F]{6}$/;
899
+ function checkNavigationBar(options) {
900
+ const { title, hidden, backgroundColor, textColor } = options;
901
+ if (title !== void 0 && typeof title !== "string") throw new TypeError("The navigation bar's title must be text");
902
+ if (hidden !== void 0 && typeof hidden !== "boolean") throw new TypeError("The navigation bar's `hidden` must be true or false");
903
+ for (const [name, color] of Object.entries({
904
+ backgroundColor,
905
+ textColor
906
+ })) if (color !== void 0 && (typeof color !== "string" || !HEX_COLOR.test(color))) throw new TypeError(`The navigation bar's ${name} must be a color such as "#1A73E8"`);
907
+ }
908
+ function checkTabBar(options) {
909
+ if (options.hidden !== void 0 && typeof options.hidden !== "boolean") throw new TypeError("The tab bar's `hidden` must be true or false");
910
+ }
911
+ function checkConfigs(configs) {
912
+ checkNavigationBar(configs.navigationBar ?? {});
913
+ checkTabBar(configs.tabBar ?? {});
914
+ }
915
+ function mergeConfigs(...configs) {
916
+ const bars = {
917
+ navigationBar: {},
918
+ tabBar: {}
919
+ };
920
+ for (const config of configs) {
921
+ bars.navigationBar = {
922
+ ...bars.navigationBar,
923
+ ...config?.navigationBar
924
+ };
925
+ bars.tabBar = {
926
+ ...bars.tabBar,
927
+ ...config?.tabBar
928
+ };
929
+ }
930
+ return bars;
931
+ }
932
+ //#endregion
408
933
  //#region src/messageChannel.ts
409
934
  var MessageChannel = class {
410
935
  #transport;
@@ -440,6 +965,6 @@ var MessageChannel = class {
440
965
  }
441
966
  };
442
967
  //#endregion
443
- export { Button, DEFAULT_SYSTEM_CONTEXT, EventEmitter, HostError, Image, Input, MAX_STACK_DEPTH, MessageChannel, NavigationStack, PAGE_HOOKS, PERMISSIONS, REACT_HOST_MODULES, REACT_HOST_PATH, SEMVER_PATTERN, SourceError, Text, View, applyChanges, builtinComponents, builtinRegistry, callHost, compareVersions, componentRegistry, connectHost, createAdaptorTransport, createEvent, createHostRequest, createLocator, createTransportPair, defineComponent, eventName, eventProp, hostTransport, isEventProp, isPageId, isPermission, isReactCompatible, isSemanticVersion, isVersionAtLeast, locatedMessage, locationAt, majorVersion, newestReactOfMajor, reactHostUrl, toList, toText };
968
+ export { AmountInput, Badge, Button, Carousel, Checkbox, Chip, CodeInput, DEFAULT_SYSTEM_CONTEXT, DOT_FILE_PATH_MAX_LENGTH, Divider, EmptyState, EventEmitter, Footer, Grid, GridItem, HostError, ICON_NAMES, Icon, Image, Input, List, ListItem, MAX_STACK_DEPTH, MessageChannel, NETWORK_HOST_MAX_LENGTH, NETWORK_HOST_PATTERN, NavigationStack, Notice, Option, PAGE_HOOKS, PERMISSIONS, ProgressBar, QRCode, REACT_HOST_MODULES, REACT_HOST_PATH, Radio, RadioGroup, SEMVER_PATTERN, SIZES, STATUS_TONES, Select, Sheet, Skeleton, SourceError, Spinner, Switch, TONES, Tab, Tabs, Text, TextArea, Toast, View, allowsHost, applyChanges, builtinComponents, builtinRegistry, callHost, checkConfigs, checkNavigationBar, checkTabBar, compareVersions, componentRegistry, connectHost, createAdaptorTransport, createEvent, createHostRequest, createLocator, createTransportPair, defineComponent, dotFilePathProblem, eventName, eventProp, hostTransport, isEventProp, isNetworkHost, isPageId, isPermission, isReactCompatible, isSemanticVersion, isVersionAtLeast, locatedMessage, locationAt, majorVersion, mergeConfigs, newestReactOfMajor, reactHostUrl, toList, toText };
444
969
 
445
970
  //# sourceMappingURL=index.js.map