@rogieking/figui3 2.10.0 → 2.10.2
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/LICENSE +21 -0
- package/README.md +696 -203
- package/components.css +107 -129
- package/dist/fig.js +74 -0
- package/fig.js +207 -118
- package/package.json +31 -8
- package/.vscode/settings.json +0 -3
- package/AUDIT.md +0 -183
- package/example.html +0 -3135
- package/glitch.html +0 -70
- package/index.ts +0 -1
- package/test.html +0 -843
- package/tracer.html +0 -584
- package/tsconfig.json +0 -27
package/components.css
CHANGED
|
@@ -193,9 +193,10 @@
|
|
|
193
193
|
:root {
|
|
194
194
|
/* Typography & Sizing */
|
|
195
195
|
--font-size: 16px;
|
|
196
|
-
--font-family:
|
|
197
|
-
|
|
198
|
-
arial,
|
|
196
|
+
--font-family:
|
|
197
|
+
"Inter", AppleSystemUIFont, BlinkMacSystemFont, avenir next, avenir,
|
|
198
|
+
segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial,
|
|
199
|
+
sans-serif;
|
|
199
200
|
--body-medium-fontSize: 0.6875rem;
|
|
200
201
|
--body-large-fontSize: 0.8125rem;
|
|
201
202
|
--body-letter-spacing: 0.055px;
|
|
@@ -304,15 +305,19 @@
|
|
|
304
305
|
--icon-swap: url("data:image/svg+xml,%3Csvg width='24' height='24' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath fill-rule='evenodd' clip-rule='evenodd' d='M8.35355 6.35355C8.54882 6.15829 8.54882 5.84171 8.35355 5.64645C8.15829 5.45118 7.84171 5.45118 7.64645 5.64645L5.14645 8.14645C4.95118 8.34171 4.95118 8.65829 5.14645 8.85355L7.64645 11.3536C7.84171 11.5488 8.15829 11.5488 8.35355 11.3536C8.54882 11.1583 8.54882 10.8417 8.35355 10.6464L6.70711 9H18.5C18.7761 9 19 8.77614 19 8.5C19 8.22386 18.7761 8 18.5 8H6.70711L8.35355 6.35355ZM15.6464 13.3536C15.4512 13.1583 15.4512 12.8417 15.6464 12.6464C15.8417 12.4512 16.1583 12.4512 16.3536 12.6464L18.8536 15.1464C19.0488 15.3417 19.0488 15.6583 18.8536 15.8536L16.3536 18.3536C16.1583 18.5488 15.8417 18.5488 15.6464 18.3536C15.4512 18.1583 15.4512 17.8417 15.6464 17.6464L17.2929 16H5.5C5.22386 16 5 15.7761 5 15.5C5 15.2239 5.22386 15 5.5 15H17.2929L15.6464 13.3536Z' fill='currentColor'/%3E%3C/svg%3E");
|
|
305
306
|
|
|
306
307
|
/* Elevations - light theme defaults */
|
|
307
|
-
--elevation-500-modal-window:
|
|
308
|
-
0px
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
308
|
+
--elevation-500-modal-window:
|
|
309
|
+
0px 0px 0.5px rgba(0, 0, 0, 0.08), 0px 10px 24px rgba(0, 0, 0, 0.18),
|
|
310
|
+
0px 2px 5px rgba(0, 0, 0, 0.15);
|
|
311
|
+
--figma-elevation-100:
|
|
312
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.3), 0px 1px 3px 0px rgba(0, 0, 0, 0.15);
|
|
313
|
+
--figma-elevation-200:
|
|
314
|
+
0px 1px 3px 0px rgba(0, 0, 0, 0.102), 0px 3px 8px 0px rgba(0, 0, 0, 0.102),
|
|
315
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.18);
|
|
316
|
+
--figma-elevation-400-menu-panel:
|
|
317
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.12),
|
|
314
318
|
0px 10px 16px 0px rgba(0, 0, 0, 0.12), 0px 2px 5px 0px rgba(0, 0, 0, 0.15);
|
|
315
|
-
--figma-elevation-500-modal-window:
|
|
319
|
+
--figma-elevation-500-modal-window:
|
|
320
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.08),
|
|
316
321
|
0px 10px 24px 0px rgba(0, 0, 0, 0.18), 0px 2px 5px 0px rgba(0, 0, 0, 0.15);
|
|
317
322
|
--handle-shadow: 0px 0 0 0.5px rgba(0, 0, 0, 0.1), var(--figma-elevation-200);
|
|
318
323
|
}
|
|
@@ -321,44 +326,48 @@
|
|
|
321
326
|
/* These cannot use light-dark() as they are complex values */
|
|
322
327
|
@media (prefers-color-scheme: dark) {
|
|
323
328
|
:root {
|
|
324
|
-
--handle-shadow:
|
|
329
|
+
--handle-shadow:
|
|
330
|
+
0px 0 0 0.75px 0px 0 0 0.75px rgba(0, 0, 0, 0.1),
|
|
325
331
|
0px 0px 0.5px 0px rgba(255, 255, 255, 0.1);
|
|
326
|
-
--figma-elevation-100:
|
|
332
|
+
--figma-elevation-100:
|
|
333
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.5),
|
|
327
334
|
0px 0.75px 0px 0px rgba(255, 255, 255, 0.1) inset,
|
|
328
335
|
0px 1px 3px 0px rgba(0, 0, 0, 0.4);
|
|
329
|
-
--figma-elevation-200:
|
|
330
|
-
0px 1px 3px rgba(0, 0, 0, 0.5),
|
|
336
|
+
--figma-elevation-200:
|
|
337
|
+
0px 3px 8px rgba(0, 0, 0, 0.35), 0px 1px 3px rgba(0, 0, 0, 0.5),
|
|
331
338
|
inset 0px 0.5px 0px rgba(255, 255, 255, 0.08),
|
|
332
339
|
inset 0px 0px 0.5px rgba(255, 255, 255, 0.3);
|
|
333
|
-
--figma-elevation-400-menu-panel:
|
|
334
|
-
|
|
340
|
+
--figma-elevation-400-menu-panel:
|
|
341
|
+
0px 0.5px 0px 0px rgba(255, 255, 255, 0.08) inset,
|
|
335
342
|
0px 10px 16px 0px rgba(0, 0, 0, 0.35),
|
|
336
343
|
inset 0px 0.75px 0px rgba(255, 255, 255, 0.075),
|
|
337
344
|
0px 2px 5px 0px rgba(0, 0, 0, 0.35);
|
|
338
|
-
--figma-elevation-500-modal-window:
|
|
339
|
-
0px 3px 5px rgba(0, 0, 0, 0.35),
|
|
345
|
+
--figma-elevation-500-modal-window:
|
|
346
|
+
0px 10px 24px rgba(0, 0, 0, 0.45), 0px 3px 5px rgba(0, 0, 0, 0.35),
|
|
340
347
|
inset 0px 0.75px 0px rgba(255, 255, 255, 0.1);
|
|
341
348
|
}
|
|
342
349
|
}
|
|
343
350
|
|
|
344
351
|
/* Class-based dark theme override (for manual theme switching) */
|
|
345
352
|
:root.figma-dark {
|
|
346
|
-
--handle-shadow:
|
|
353
|
+
--handle-shadow:
|
|
354
|
+
0px 0 0 0.75px 0px 0 0 0.75px rgba(0, 0, 0, 0.1),
|
|
347
355
|
0px 0px 0.5px 0px rgba(255, 255, 255, 0.1);
|
|
348
|
-
--figma-elevation-100:
|
|
356
|
+
--figma-elevation-100:
|
|
357
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.5),
|
|
349
358
|
0px 0.75px 0px 0px rgba(255, 255, 255, 0.1) inset,
|
|
350
359
|
0px 1px 3px 0px rgba(0, 0, 0, 0.4);
|
|
351
|
-
--figma-elevation-200:
|
|
352
|
-
0px 1px 3px rgba(0, 0, 0, 0.5),
|
|
360
|
+
--figma-elevation-200:
|
|
361
|
+
0px 3px 8px rgba(0, 0, 0, 0.35), 0px 1px 3px rgba(0, 0, 0, 0.5),
|
|
353
362
|
inset 0px 0.5px 0px rgba(255, 255, 255, 0.08),
|
|
354
363
|
inset 0px 0px 0.5px rgba(255, 255, 255, 0.3);
|
|
355
|
-
--figma-elevation-400-menu-panel:
|
|
356
|
-
|
|
364
|
+
--figma-elevation-400-menu-panel:
|
|
365
|
+
0px 0.5px 0px 0px rgba(255, 255, 255, 0.08) inset,
|
|
357
366
|
0px 10px 16px 0px rgba(0, 0, 0, 0.35),
|
|
358
367
|
inset 0px 0.75px 0px rgba(255, 255, 255, 0.075),
|
|
359
368
|
0px 2px 5px 0px rgba(0, 0, 0, 0.35);
|
|
360
|
-
--figma-elevation-500-modal-window:
|
|
361
|
-
0px 3px 5px rgba(0, 0, 0, 0.35),
|
|
369
|
+
--figma-elevation-500-modal-window:
|
|
370
|
+
0px 10px 24px rgba(0, 0, 0, 0.45), 0px 3px 5px rgba(0, 0, 0, 0.35),
|
|
362
371
|
inset 0px 0.75px 0px rgba(255, 255, 255, 0.1);
|
|
363
372
|
}
|
|
364
373
|
|
|
@@ -469,6 +478,17 @@ input[type="text"][list] {
|
|
|
469
478
|
|
|
470
479
|
@supports (appearance: base-select) {
|
|
471
480
|
fig-dropdown[variant="neue"] {
|
|
481
|
+
&[type="dropdown"] {
|
|
482
|
+
select:before {
|
|
483
|
+
content: attr(aria-label);
|
|
484
|
+
}
|
|
485
|
+
option::checkmark {
|
|
486
|
+
display: none;
|
|
487
|
+
}
|
|
488
|
+
option {
|
|
489
|
+
padding-left: var(--spacer-3);
|
|
490
|
+
}
|
|
491
|
+
}
|
|
472
492
|
select {
|
|
473
493
|
appearance: base-select;
|
|
474
494
|
--option-height: 1.5rem;
|
|
@@ -502,7 +522,7 @@ input[type="text"][list] {
|
|
|
502
522
|
&:not(:disabled) {
|
|
503
523
|
&:hover,
|
|
504
524
|
&:active,
|
|
505
|
-
&:focus {
|
|
525
|
+
&:focus-visible {
|
|
506
526
|
background-color: transparent;
|
|
507
527
|
outline: 0;
|
|
508
528
|
&:before {
|
|
@@ -518,8 +538,11 @@ input[type="text"][list] {
|
|
|
518
538
|
position: relative;
|
|
519
539
|
padding: 0 var(--spacer-1) 0 calc(var(--spacer-1) * 2 + var(--spacer-1));
|
|
520
540
|
font-weight: var(--body-medium-fontWeight);
|
|
521
|
-
|
|
522
|
-
|
|
541
|
+
&[label] {
|
|
542
|
+
padding-top: var(--spacer-2);
|
|
543
|
+
option:first-child {
|
|
544
|
+
margin-top: var(--spacer-2);
|
|
545
|
+
}
|
|
523
546
|
}
|
|
524
547
|
legend {
|
|
525
548
|
padding: var(--spacer-1, 0.3rem) var(--spacer-1, 1rem);
|
|
@@ -530,7 +553,7 @@ input[type="text"][list] {
|
|
|
530
553
|
}
|
|
531
554
|
&:not(:first-child) {
|
|
532
555
|
margin-top: var(--spacer-2);
|
|
533
|
-
padding-top: var(--spacer-
|
|
556
|
+
padding-top: var(--spacer-3);
|
|
534
557
|
|
|
535
558
|
&:before {
|
|
536
559
|
content: "";
|
|
@@ -547,7 +570,7 @@ input[type="text"][list] {
|
|
|
547
570
|
}
|
|
548
571
|
option[hidden="true"]:first-child + optgroup {
|
|
549
572
|
margin-top: 0;
|
|
550
|
-
padding-top:
|
|
573
|
+
padding-top: var(--spacer-2);
|
|
551
574
|
&:before {
|
|
552
575
|
display: none;
|
|
553
576
|
}
|
|
@@ -558,10 +581,8 @@ input[type="text"][list] {
|
|
|
558
581
|
}
|
|
559
582
|
|
|
560
583
|
::picker(select) {
|
|
561
|
-
position-area: auto;
|
|
562
|
-
align-self: auto;
|
|
563
|
-
max-block-size: 100vh;
|
|
564
584
|
appearance: base-select;
|
|
585
|
+
|
|
565
586
|
scrollbar-width: thin;
|
|
566
587
|
outline: 0;
|
|
567
588
|
scrollbar-color: var(--figma-color-text-menu-tertiary)
|
|
@@ -572,61 +593,6 @@ input[type="text"][list] {
|
|
|
572
593
|
padding: var(--spacer-2) 0;
|
|
573
594
|
box-shadow: var(--figma-elevation-400-menu-panel);
|
|
574
595
|
}
|
|
575
|
-
select {
|
|
576
|
-
&:has(:nth-child(1):checked) {
|
|
577
|
-
&::picker(select) {
|
|
578
|
-
top: calc(var(--option-height) * -1 - var(--spacer-2));
|
|
579
|
-
}
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
&:has(:nth-child(2):checked) {
|
|
583
|
-
&::picker(select) {
|
|
584
|
-
top: calc(var(--option-height) * -2 - var(--spacer-2));
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
|
|
588
|
-
&:has(:nth-child(3):checked) {
|
|
589
|
-
&::picker(select) {
|
|
590
|
-
top: calc(var(--option-height) * -3 - var(--spacer-2));
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
|
|
594
|
-
&:has(:nth-child(4):checked) {
|
|
595
|
-
&::picker(select) {
|
|
596
|
-
top: calc(var(--option-height) * -4 - var(--spacer-2));
|
|
597
|
-
}
|
|
598
|
-
}
|
|
599
|
-
&:has(:nth-child(5):checked) {
|
|
600
|
-
&::picker(select) {
|
|
601
|
-
top: calc(var(--option-height) * -5 - var(--spacer-2));
|
|
602
|
-
}
|
|
603
|
-
}
|
|
604
|
-
&:has(:nth-child(6):checked) {
|
|
605
|
-
&::picker(select) {
|
|
606
|
-
top: calc(var(--option-height) * -6 - var(--spacer-2));
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
&:has(:nth-child(7):checked) {
|
|
610
|
-
&::picker(select) {
|
|
611
|
-
top: calc(var(--option-height) * -7 - var(--spacer-2));
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
&:has(:nth-child(8):checked) {
|
|
615
|
-
&::picker(select) {
|
|
616
|
-
top: calc(var(--option-height) * -8 - var(--spacer-2));
|
|
617
|
-
}
|
|
618
|
-
}
|
|
619
|
-
&:has(:nth-child(9):checked) {
|
|
620
|
-
&::picker(select) {
|
|
621
|
-
top: calc(var(--option-height) * -9 - var(--spacer-2));
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
&:has(:nth-child(10):checked) {
|
|
625
|
-
&::picker(select) {
|
|
626
|
-
top: calc(var(--option-height) * -10 - var(--spacer-2));
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
596
|
}
|
|
631
597
|
}
|
|
632
598
|
|
|
@@ -1056,7 +1022,6 @@ input[type="color"] {
|
|
|
1056
1022
|
grid-area: 1/1;
|
|
1057
1023
|
color-scheme: inherit;
|
|
1058
1024
|
outline: 0;
|
|
1059
|
-
|
|
1060
1025
|
}
|
|
1061
1026
|
|
|
1062
1027
|
&::-webkit-color-swatch {
|
|
@@ -1099,7 +1064,7 @@ fig-chit {
|
|
|
1099
1064
|
--chit-background: #d9d9d9;
|
|
1100
1065
|
--chit-bg-size: cover;
|
|
1101
1066
|
--chit-bg-position: center;
|
|
1102
|
-
--alpha:1;
|
|
1067
|
+
--alpha: 1;
|
|
1103
1068
|
|
|
1104
1069
|
display: inline-grid;
|
|
1105
1070
|
width: var(--size);
|
|
@@ -1146,7 +1111,8 @@ fig-chit {
|
|
|
1146
1111
|
}
|
|
1147
1112
|
|
|
1148
1113
|
&[selected]:not([selected="false"])::before {
|
|
1149
|
-
box-shadow:
|
|
1114
|
+
box-shadow:
|
|
1115
|
+
inset 0 0 0 1px var(--figma-color-border-selected),
|
|
1150
1116
|
inset 0 0 0 3px var(--figma-color-bg);
|
|
1151
1117
|
}
|
|
1152
1118
|
|
|
@@ -1156,7 +1122,6 @@ fig-chit {
|
|
|
1156
1122
|
width: var(--size);
|
|
1157
1123
|
height: var(--size);
|
|
1158
1124
|
border-radius: var(--radius-medium);
|
|
1159
|
-
|
|
1160
1125
|
}
|
|
1161
1126
|
}
|
|
1162
1127
|
|
|
@@ -1180,7 +1145,6 @@ fig-chit {
|
|
|
1180
1145
|
background-repeat: repeat;
|
|
1181
1146
|
border-radius: 0.125rem;
|
|
1182
1147
|
box-shadow: inset 0 0 0 1px var(--figma-color-bordertranslucent);
|
|
1183
|
-
|
|
1184
1148
|
}
|
|
1185
1149
|
&[data-type="image"]::after {
|
|
1186
1150
|
mask-image: linear-gradient(
|
|
@@ -1286,7 +1250,7 @@ fig-image {
|
|
|
1286
1250
|
align-items: center;
|
|
1287
1251
|
gap: 1px;
|
|
1288
1252
|
|
|
1289
|
-
& > label{
|
|
1253
|
+
& > label {
|
|
1290
1254
|
align-self: stretch;
|
|
1291
1255
|
color: inherit;
|
|
1292
1256
|
}
|
|
@@ -1504,8 +1468,10 @@ input[type="radio"] {
|
|
|
1504
1468
|
border-radius: 100%;
|
|
1505
1469
|
background-color: var(--figma-color-icon-onbrand);
|
|
1506
1470
|
transform: scale(0);
|
|
1507
|
-
box-shadow:
|
|
1508
|
-
0px
|
|
1471
|
+
box-shadow:
|
|
1472
|
+
0px 0 0 0.75px rgba(0, 0, 0, 0.1),
|
|
1473
|
+
0px 1px 3px 0px rgba(0, 0, 0, 0.1),
|
|
1474
|
+
0px 3px 8px 0px rgba(0, 0, 0, 0.1),
|
|
1509
1475
|
0px 0px 0.5px 0px rgba(0, 0, 0, 0.18);
|
|
1510
1476
|
}
|
|
1511
1477
|
}
|
|
@@ -1602,12 +1568,12 @@ fig-slider {
|
|
|
1602
1568
|
--slider-percent: calc(var(--slider-complete) * 100%);
|
|
1603
1569
|
--start-percent: calc(var(--default, 0) * 100%);
|
|
1604
1570
|
--slider-tick-size: calc(var(--slider-height) / 4);
|
|
1605
|
-
--slider-handle-shadow:
|
|
1606
|
-
|
|
1571
|
+
--slider-handle-shadow:
|
|
1572
|
+
inset 0 0 0 calc(4px + 0.5rem * var(--unchanged)) var(--handle-color),
|
|
1607
1573
|
0px 0 0 0.5px rgba(0, 0, 0, 0.1), var(--figma-elevation-200);
|
|
1608
|
-
--slider-handle-shadow-focus:
|
|
1609
|
-
inset 0 0 0 5px rgba(0, 0, 0, 0.1),
|
|
1610
|
-
0 0 0 1px var(--figma-color-border-selected);
|
|
1574
|
+
--slider-handle-shadow-focus:
|
|
1575
|
+
inset 0 0 0 4px var(--handle-color), inset 0 0 0 5px rgba(0, 0, 0, 0.1),
|
|
1576
|
+
var(--handle-shadow), 0 0 0 1px var(--figma-color-border-selected);
|
|
1611
1577
|
--slider-transition: all 0.1s ease-in-out;
|
|
1612
1578
|
--handle-transition: var(--slider-transition);
|
|
1613
1579
|
|
|
@@ -1671,11 +1637,10 @@ fig-slider {
|
|
|
1671
1637
|
);
|
|
1672
1638
|
--width: calc(var(--slider-percent) - var(--start-percent));
|
|
1673
1639
|
--abs-width: max(
|
|
1674
|
-
var(--width) + var(--slider-height) / 2 +
|
|
1675
|
-
var(--slider-height),
|
|
1676
|
-
-1 * var(--width) + var(--slider-height) / 2 +
|
|
1677
|
-
|
|
1678
|
-
) * var(--slider-height)
|
|
1640
|
+
var(--width) + var(--slider-height) / 2 +
|
|
1641
|
+
(1 - var(--slider-complete)) * var(--slider-height),
|
|
1642
|
+
-1 * var(--width) + var(--slider-height) / 2 +
|
|
1643
|
+
(var(--slider-complete)) * var(--slider-height)
|
|
1679
1644
|
);
|
|
1680
1645
|
width: var(--abs-width);
|
|
1681
1646
|
--delta: calc(var(--slider-complete) - var(--default));
|
|
@@ -1765,7 +1730,8 @@ fig-slider {
|
|
|
1765
1730
|
}
|
|
1766
1731
|
|
|
1767
1732
|
&.opacity::-webkit-slider-runnable-track {
|
|
1768
|
-
background:
|
|
1733
|
+
background:
|
|
1734
|
+
linear-gradient(to right, transparent, var(--color)),
|
|
1769
1735
|
var(--checkerboard);
|
|
1770
1736
|
}
|
|
1771
1737
|
}
|
|
@@ -1839,7 +1805,8 @@ fig-slider {
|
|
|
1839
1805
|
}
|
|
1840
1806
|
|
|
1841
1807
|
&.opacity::-moz-range-track {
|
|
1842
|
-
background:
|
|
1808
|
+
background:
|
|
1809
|
+
linear-gradient(to right, transparent, var(--color)),
|
|
1843
1810
|
var(--checkerboard);
|
|
1844
1811
|
}
|
|
1845
1812
|
}
|
|
@@ -1888,8 +1855,8 @@ fig-slider {
|
|
|
1888
1855
|
--slider-tick-size: calc(var(--slider-height) / 2);
|
|
1889
1856
|
--handle-transition: none;
|
|
1890
1857
|
--slider-transition: none;
|
|
1891
|
-
--slider-handle-shadow:
|
|
1892
|
-
|
|
1858
|
+
--slider-handle-shadow:
|
|
1859
|
+
inset 0 0 0 calc(6px + 0.5rem * var(--unchanged)) var(--handle-color),
|
|
1893
1860
|
0 0 0 0.75px rgba(0, 0, 0, 0.075), inset 0 0 0 5px rgba(0, 0, 0, 0.1),
|
|
1894
1861
|
var(--figma-elevation-200);
|
|
1895
1862
|
|
|
@@ -1917,8 +1884,8 @@ fig-slider {
|
|
|
1917
1884
|
--slider-tick-size: calc(var(--slider-height) / 2);
|
|
1918
1885
|
--handle-transition: none;
|
|
1919
1886
|
--slider-transition: none;
|
|
1920
|
-
--slider-handle-shadow:
|
|
1921
|
-
|
|
1887
|
+
--slider-handle-shadow:
|
|
1888
|
+
inset 0 0 0 calc(6px + 0.5rem * var(--unchanged)) var(--handle-color),
|
|
1922
1889
|
0 0 0 0.75px rgba(0, 0, 0, 0.075), inset 0 0 0 5px rgba(0, 0, 0, 0.1),
|
|
1923
1890
|
var(--figma-elevation-200);
|
|
1924
1891
|
|
|
@@ -2022,8 +1989,10 @@ dialog,
|
|
|
2022
1989
|
text-overflow: ellipsis;
|
|
2023
1990
|
|
|
2024
1991
|
border-radius: var(--radius-medium, 0.3125rem);
|
|
2025
|
-
box-shadow:
|
|
2026
|
-
0px
|
|
1992
|
+
box-shadow:
|
|
1993
|
+
0px 0px 0.5px 0px rgba(0, 0, 0, 0.15),
|
|
1994
|
+
0px 5px 12px 0px rgba(0, 0, 0, 0.13),
|
|
1995
|
+
0px 1px 3px 0px rgba(0, 0, 0, 0.1);
|
|
2027
1996
|
|
|
2028
1997
|
@supports (-webkit-line-clamp: 2) {
|
|
2029
1998
|
white-space: initial;
|
|
@@ -2215,6 +2184,7 @@ fig-content,
|
|
|
2215
2184
|
fig-slider,
|
|
2216
2185
|
fig-switch,
|
|
2217
2186
|
fig-input-color,
|
|
2187
|
+
fig-input-fill,
|
|
2218
2188
|
fig-checkbox,
|
|
2219
2189
|
fig-radio,
|
|
2220
2190
|
fig-tab,
|
|
@@ -2382,9 +2352,8 @@ fig-input-number {
|
|
|
2382
2352
|
}
|
|
2383
2353
|
}
|
|
2384
2354
|
|
|
2385
|
-
fig-input-color,
|
|
2355
|
+
fig-input-color,
|
|
2386
2356
|
fig-input-fill {
|
|
2387
|
-
|
|
2388
2357
|
& > .input-combo > fig-chit:not(:only-child),
|
|
2389
2358
|
& > .input-combo > fig-chit:not(:only-child) > input,
|
|
2390
2359
|
& > .input-combo > fig-fill-picker:not(:only-child),
|
|
@@ -2394,7 +2363,7 @@ fig-input-fill {
|
|
|
2394
2363
|
border-bottom-right-radius: 0 !important;
|
|
2395
2364
|
}
|
|
2396
2365
|
|
|
2397
|
-
& > .input-combo{
|
|
2366
|
+
& > .input-combo {
|
|
2398
2367
|
flex: 1;
|
|
2399
2368
|
min-width: 0;
|
|
2400
2369
|
}
|
|
@@ -2407,7 +2376,6 @@ fig-input-fill {
|
|
|
2407
2376
|
&[disabled]:not([disabled="false"]) {
|
|
2408
2377
|
.input-combo {
|
|
2409
2378
|
gap: 0;
|
|
2410
|
-
|
|
2411
2379
|
}
|
|
2412
2380
|
}
|
|
2413
2381
|
}
|
|
@@ -2600,7 +2568,8 @@ fig-input-joystick {
|
|
|
2600
2568
|
}
|
|
2601
2569
|
}
|
|
2602
2570
|
.fig-input-joystick-plane.dragging .fig-input-joystick-guides {
|
|
2603
|
-
background:
|
|
2571
|
+
background:
|
|
2572
|
+
linear-gradient(
|
|
2604
2573
|
45deg,
|
|
2605
2574
|
transparent calc(50% - 0.5px),
|
|
2606
2575
|
var(--figma-color-border) calc(50% - 0.5px),
|
|
@@ -2912,13 +2881,17 @@ fig-fill-picker {
|
|
|
2912
2881
|
height: 1rem;
|
|
2913
2882
|
border-radius: 50%;
|
|
2914
2883
|
background: var(--picker-color);
|
|
2915
|
-
box-shadow:
|
|
2916
|
-
|
|
2884
|
+
box-shadow:
|
|
2885
|
+
inset 0 0 0 0.125rem var(--handle-color),
|
|
2886
|
+
0px 0 0 0.5px rgba(0, 0, 0, 0.1),
|
|
2887
|
+
var(--figma-elevation-200);
|
|
2917
2888
|
transform: translate(-50%, -50%);
|
|
2918
2889
|
z-index: 1;
|
|
2919
2890
|
&:hover {
|
|
2920
|
-
box-shadow:
|
|
2921
|
-
|
|
2891
|
+
box-shadow:
|
|
2892
|
+
inset 0 0 0 0.25rem var(--handle-color),
|
|
2893
|
+
0px 0 0 0.5px rgba(0, 0, 0, 0.1),
|
|
2894
|
+
var(--figma-elevation-200);
|
|
2922
2895
|
transform: translate(-50%, -50%);
|
|
2923
2896
|
}
|
|
2924
2897
|
}
|
|
@@ -3074,16 +3047,21 @@ fig-fill-picker {
|
|
|
3074
3047
|
.fig-fill-picker-checkerboard {
|
|
3075
3048
|
position: absolute;
|
|
3076
3049
|
inset: 0;
|
|
3077
|
-
background-image:
|
|
3078
|
-
|
|
3050
|
+
background-image:
|
|
3051
|
+
linear-gradient(45deg, var(--figma-color-bg-tertiary) 25%, transparent 25%),
|
|
3052
|
+
linear-gradient(
|
|
3053
|
+
-45deg,
|
|
3079
3054
|
var(--figma-color-bg-tertiary) 25%,
|
|
3080
3055
|
transparent 25%
|
|
3081
3056
|
),
|
|
3082
|
-
linear-gradient(-45deg, var(--figma-color-bg-tertiary) 25%, transparent 25%),
|
|
3083
3057
|
linear-gradient(45deg, transparent 75%, var(--figma-color-bg-tertiary) 75%),
|
|
3084
3058
|
linear-gradient(-45deg, transparent 75%, var(--figma-color-bg-tertiary) 75%);
|
|
3085
3059
|
background-size: 16px 16px;
|
|
3086
|
-
background-position:
|
|
3060
|
+
background-position:
|
|
3061
|
+
0 0,
|
|
3062
|
+
0 8px,
|
|
3063
|
+
8px -8px,
|
|
3064
|
+
-8px 0px;
|
|
3087
3065
|
}
|
|
3088
3066
|
|
|
3089
3067
|
.fig-fill-picker-image-preview {
|
package/dist/fig.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
function U(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}if(window.customElements&&!window.customElements.get("fig-button")){class j extends HTMLElement{type;#j;constructor(){super();this.attachShadow({mode:"open"})}connectedCallback(){this.type=this.getAttribute("type")||"button",this.shadowRoot.innerHTML=`
|
|
2
|
+
<style>
|
|
3
|
+
button, button:hover, button:active {
|
|
4
|
+
padding: 0 var(--spacer-2);
|
|
5
|
+
appearance: none;
|
|
6
|
+
display: flex;
|
|
7
|
+
border: 0;
|
|
8
|
+
flex: 1;
|
|
9
|
+
text-align: center;
|
|
10
|
+
align-items: stretch;
|
|
11
|
+
justify-content: center;
|
|
12
|
+
font: inherit;
|
|
13
|
+
color: inherit;
|
|
14
|
+
outline: 0;
|
|
15
|
+
place-items: center;
|
|
16
|
+
background: transparent;
|
|
17
|
+
margin: calc(var(--spacer-2)*-1);
|
|
18
|
+
height: var(--spacer-4);
|
|
19
|
+
}
|
|
20
|
+
</style>
|
|
21
|
+
<button type="${this.type}">
|
|
22
|
+
<slot></slot>
|
|
23
|
+
</button>
|
|
24
|
+
`,this.#j=this.hasAttribute("selected")&&this.getAttribute("selected")!=="false",requestAnimationFrame(()=>{this.button=this.shadowRoot.querySelector("button"),this.button.addEventListener("click",this.#J.bind(this))})}get type(){return this.type}set type(K){this.setAttribute("type",K)}get selected(){return this.#j}set selected(K){this.setAttribute("selected",K)}#J(){if(this.type==="toggle")this.toggleAttribute("selected",!this.hasAttribute("selected"));if(this.type==="submit")this.closest("form").dispatchEvent(new Event("submit"))}static get observedAttributes(){return["disabled","selected"]}attributeChangedCallback(K,J,Q){if(this.button)switch(this.button[K]=Q,K){case"disabled":this.disabled=this.button.disabled=Q==="true"||Q===void 0&&Q!==null;break;case"type":this.type=Q,this.button.type=this.type,this.button.setAttribute("type",this.type);break;case"selected":this.#j=Q==="true";break}}}window.customElements.define("fig-button",j)}if(window.customElements&&!window.customElements.get("fig-dropdown")){class j extends HTMLElement{constructor(){super();this.select=document.createElement("select"),this.optionsSlot=document.createElement("slot"),this.attachShadow({mode:"open"})}#j(){this.select.addEventListener("input",this.#J.bind(this)),this.select.addEventListener("change",this.#K.bind(this))}connectedCallback(){this.type=this.getAttribute("type")||"select",this.appendChild(this.select),this.shadowRoot.appendChild(this.optionsSlot),this.optionsSlot.addEventListener("slotchange",this.slotChange.bind(this)),this.#j()}slotChange(){while(this.select.firstChild)this.select.firstChild.remove();if(this.type==="dropdown"){const K=document.createElement("option");K.setAttribute("hidden","true"),K.setAttribute("selected","true"),this.select.appendChild(K)}if(this.optionsSlot.assignedNodes().forEach((K)=>{if(K.nodeName==="OPTION"||K.nodeName==="OPTGROUP")this.select.appendChild(K.cloneNode(!0))}),this.#Q(this.value),this.type==="dropdown")this.select.selectedIndex=-1}#J(K){this.value=K.target.value,this.setAttribute("value",this.value)}#K(){if(this.type==="dropdown")this.select.selectedIndex=-1}focus(){this.select.focus()}blur(){this.select.blur()}get value(){return this.select?.value}set value(K){this.setAttribute("value",K)}static get observedAttributes(){return["value","type"]}#Q(K){if(this.select)this.select.querySelectorAll("option").forEach((J,Q)=>{if(J.value===this.getAttribute("value"))this.select.selectedIndex=Q})}attributeChangedCallback(K,J,Q){if(K==="value")this.#Q(Q);if(K==="type")this.type=Q}}customElements.define("fig-dropdown",j)}class P extends HTMLElement{constructor(){super();this.action=this.getAttribute("action")||"hover",this.delay=parseInt(this.getAttribute("delay"))||500,this.isOpen=!1}connectedCallback(){this.setup(),this.setupEventListeners()}disconnectedCallback(){this.destroy()}setup(){this.style.display="contents"}render(){this.destroy(),this.popup=document.createElement("span"),this.popup.setAttribute("class","fig-tooltip"),this.popup.style.position="fixed",this.popup.style.visibility="hidden",this.popup.style.display="inline-flex",this.popup.style.pointerEvents="none",this.popup.innerText=this.getAttribute("text"),document.body.append(this.popup)}destroy(){if(this.popup)this.popup.remove();document.body.addEventListener("click",this.hidePopupOutsideClick)}setupEventListeners(){if(this.action==="hover")this.addEventListener("pointerenter",this.showDelayedPopup.bind(this)),this.addEventListener("pointerleave",this.hidePopup.bind(this));else if(this.action==="click")this.addEventListener("click",this.showDelayedPopup.bind(this)),document.body.addEventListener("click",this.hidePopupOutsideClick.bind(this))}getOffset(){const j={left:8,top:4,right:8,bottom:4},K=this.getAttribute("offset");if(!K)return j;const[J,Q,X,W]=K.split(",").map(Number);return{left:isNaN(J)?j.left:J,top:isNaN(Q)?j.top:Q,right:isNaN(X)?j.right:X,bottom:isNaN(W)?j.bottom:W}}showDelayedPopup(){this.render(),clearTimeout(this.timeout),this.timeout=setTimeout(this.showPopup.bind(this),this.delay)}showPopup(){const j=this.firstElementChild.getBoundingClientRect(),K=this.popup.getBoundingClientRect(),J=this.getOffset();let Q=j.top-K.height-J.top,X=j.left+(j.width-K.width)/2;if(this.popup.setAttribute("position","top"),Q<0)this.popup.setAttribute("position","bottom"),Q=j.bottom+J.bottom;if(X<J.left)X=J.left;else if(X+K.width>window.innerWidth-J.right)X=window.innerWidth-K.width-J.right;this.popup.style.top=`${Q}px`,this.popup.style.left=`${X}px`,this.popup.style.opacity="1",this.popup.style.visibility="visible",this.popup.style.display="block",this.popup.style.pointerEvents="all",this.popup.style.zIndex=parseInt(new Date().getTime()/1000),this.isOpen=!0}hidePopup(){clearTimeout(this.timeout),this.popup.style.opacity="0",this.popup.style.display="block",this.popup.style.pointerEvents="none",this.destroy(),this.isOpen=!1}hidePopupOutsideClick(j){if(this.isOpen&&!this.popup.contains(j.target))this.hidePopup()}}customElements.define("fig-tooltip",P);class y extends P{static observedAttributes=["action","size"];constructor(){super();this.action=this.getAttribute("action")||"click",this.delay=parseInt(this.getAttribute("delay"))||0}render(){this.popup=this.popup||this.querySelector("[popover]"),this.popup.setAttribute("class","fig-popover"),this.popup.style.position="fixed",this.popup.style.display="block",this.popup.style.pointerEvents="none",document.body.append(this.popup)}destroy(){}}customElements.define("fig-popover",y);class L extends HTMLElement{constructor(){super();this.attachShadow({mode:"open"}),this.dialog=document.createElement("dialog"),this.contentSlot=document.createElement("slot")}connectedCallback(){this.modal=this.hasAttribute("modal")&&this.getAttribute("modal")!=="false",this.appendChild(this.dialog),this.shadowRoot.appendChild(this.contentSlot),this.contentSlot.addEventListener("slotchange",this.slotChange.bind(this)),requestAnimationFrame(()=>{this.#j()})}#j(){this.dialog.querySelectorAll("fig-button[close-dialog]").forEach((j)=>{j.removeEventListener("click",this.close),j.addEventListener("click",this.close.bind(this))})}disconnectedCallback(){this.contentSlot.removeEventListener("slotchange",this.slotChange)}slotChange(){while(this.dialog.firstChild)this.dialog.firstChild.remove();this.contentSlot.assignedNodes().forEach((j)=>{if(j!==this.dialog)this.dialog.appendChild(j.cloneNode(!0))}),this.#j()}static get observedAttributes(){return["open","modal"]}attributeChangedCallback(j,K,J){switch(j){case"open":if(this.open=J==="true"&&J!=="false",this?.show)this[this.open?"show":"close"]();break;case"modal":this.modal=J==="true"&&J!=="false";break}}show(){if(this.modal)this.dialog.showModal();else this.dialog.show()}close(){this.dialog.close()}}customElements.define("fig-dialog",L);class k extends HTMLElement{#j;#J;#K;#Q;#W;#X;constructor(){super()}connectedCallback(){if(this.#j=this.querySelector("[popover]"),this.#J=this,this.#Q=Number(this.getAttribute("delay"))||0,this.#X=this.getAttribute("trigger-action")||"click",this.#K=`tooltip-${U()}`,this.#j){if(this.#j.setAttribute("id",this.#K),this.#j.setAttribute("role","tooltip"),this.#j.setAttribute("popover","manual"),this.#j.style["position-anchor"]=`--${this.#K}`,this.#J.setAttribute("popovertarget",this.#K),this.#J.setAttribute("popovertargetaction","toggle"),this.#J.style["anchor-name"]=`--${this.#K}`,this.#X==="hover")this.#J.addEventListener("mouseover",this.handleOpen.bind(this)),this.#J.addEventListener("mouseout",this.handleClose.bind(this));else this.#J.addEventListener("click",this.handleToggle.bind(this));document.body.append(this.#j)}}handleClose(){clearTimeout(this.#W),this.#j.hidePopover()}handleToggle(){if(this.#j.matches(":popover-open"))this.handleClose();else this.handleOpen()}handleOpen(){clearTimeout(this.#W),this.#W=setTimeout(()=>{this.#j.showPopover()},this.#Q)}}window.customElements.define("fig-popover-2",k);class A extends HTMLElement{constructor(){super()}connectedCallback(){this.setAttribute("label",this.innerText),this.addEventListener("click",this.handleClick.bind(this))}disconnectedCallback(){this.removeEventListener("click",this.handleClick)}handleClick(){this.setAttribute("selected","true")}}window.customElements.define("fig-tab",A);class O extends HTMLElement{constructor(){super()}connectedCallback(){this.name=this.getAttribute("name")||"tabs",this.addEventListener("click",this.handleClick.bind(this))}disconnectedCallback(){this.removeEventListener("click",this.handleClick)}handleClick(j){const K=j.target;if(K.nodeName.toLowerCase()==="fig-tab"){const J=this.querySelectorAll("fig-tab");for(let Q of J)if(Q===K)this.selectedTab=Q;else Q.removeAttribute("selected")}}}window.customElements.define("fig-tabs",O);class B extends HTMLElement{#j;#J;constructor(){super()}connectedCallback(){this.addEventListener("click",this.handleClick.bind(this))}disconnectedCallback(){this.removeEventListener("click",this.handleClick)}handleClick(){this.setAttribute("selected","true")}get value(){return this.#j}set value(j){this.#j=j,this.setAttribute("value",j)}get selected(){return this.#J}set selected(j){this.#J=j,this.setAttribute("selected",j)}static get observedAttributes(){return["selected","value"]}attributeChangedCallback(j,K,J){switch(j){case"value":this.#j=J;break;case"selected":this.#J=J;break}}}window.customElements.define("fig-segment",B);class R extends HTMLElement{constructor(){super()}connectedCallback(){this.name=this.getAttribute("name")||"segmented-control",this.addEventListener("click",this.handleClick.bind(this))}handleClick(j){const K=j.target;if(K.nodeName.toLowerCase()==="fig-segment"){const J=this.querySelectorAll("fig-segment");for(let Q of J)if(Q===K)this.selectedSegment=Q;else Q.removeAttribute("selected")}}}window.customElements.define("fig-segmented-control",R);class N extends HTMLElement{#j={range:{min:0,max:100,step:1},hue:{min:0,max:255,step:1},delta:{min:-100,max:100,step:1},stepper:{min:0,max:100,step:25},opacity:{min:0,max:100,step:0.1,color:"#FF0000"}};constructor(){super()}#J(){this.value=Number(this.getAttribute("value")||0),this.default=this.getAttribute("default")||null,this.type=this.getAttribute("type")||"range",this.text=this.getAttribute("text")||!1,this.units=this.getAttribute("units")||"",this.transform=Number(this.getAttribute("transform")||1),this.disabled=this.getAttribute("disabled")?!0:!1;const j=this.#j[this.type];if(this.min=Number(this.getAttribute("min")||j.min),this.max=Number(this.getAttribute("max")||j.max),this.step=Number(this.getAttribute("step")||j.step),this.color=this.getAttribute("color")||j?.color,this.color)this.style.setProperty("--color",this.color);let K="",J=`<div class="fig-slider-input-container">
|
|
25
|
+
<input
|
|
26
|
+
type="range"
|
|
27
|
+
${this.disabled?"disabled":""}
|
|
28
|
+
min="${this.min}"
|
|
29
|
+
max="${this.max}"
|
|
30
|
+
step="${this.step}"
|
|
31
|
+
class="${this.type}"
|
|
32
|
+
value="${this.value}">
|
|
33
|
+
${this.initialInnerHTML}
|
|
34
|
+
</div>`;if(this.text)K=`${J}
|
|
35
|
+
<fig-input-text
|
|
36
|
+
placeholder="##"
|
|
37
|
+
type="number"
|
|
38
|
+
min="${this.min}"
|
|
39
|
+
max="${this.max}"
|
|
40
|
+
transform="${this.transform}"
|
|
41
|
+
step="${this.step}"
|
|
42
|
+
value="${this.value}">
|
|
43
|
+
${this.units?`<span slot="append">${this.units}</span>`:""}
|
|
44
|
+
</fig-input-text>`;else K=J;this.innerHTML=K,requestAnimationFrame(()=>{if(this.input=this.querySelector("[type=range]"),this.input.removeEventListener("input",this.handleInput),this.input.addEventListener("input",this.handleInput.bind(this)),this.default)this.style.setProperty("--default",this.#K(this.default));if(this.datalist=this.querySelector("datalist"),this.figInputText=this.querySelector("fig-input-text"),this.datalist)this.datalist.setAttribute("id",this.datalist.getAttribute("id")||U()),this.input.setAttribute("list",this.datalist.getAttribute("id"));if(this.figInputText)this.figInputText.removeEventListener("input",this.handleTextInput),this.figInputText.addEventListener("input",this.handleTextInput.bind(this));this.handleInput()})}connectedCallback(){this.initialInnerHTML=this.innerHTML,this.#J()}static get observedAttributes(){return["value","step","min","max","type","disabled","color","units","transform"]}focus(){this.input.focus()}attributeChangedCallback(j,K,J){if(this.input)switch(j){case"color":this.color=J,this.style.setProperty("--color",this.color);break;case"disabled":if(this.disabled=this.input.disabled=J==="true"||J===void 0&&J!==null,this.figInputText)this.figInputText.disabled=this.disabled,this.figInputText.setAttribute("disabled",this.disabled);break;case"value":if(this.value=J,this.figInputText)this.figInputText.setAttribute("value",J);break;case"transform":if(this.transform=Number(J)||1,this.figInputText)this.figInputText.setAttribute("transform",this.transform);break;case"min":case"max":case"step":case"type":case"text":case"units":this[j]=J,this.#J();break;default:this[j]=this.input[j]=J,this.handleInput();break}}handleTextInput(){if(this.figInputText)this.value=this.input.value=this.figInputText.value,this.#Q()}#K(j){let K=Number(this.input.min),J=Number(this.input.max);return(j-K)/(J-K)}#Q(){let j=this.#K(this.value),K=this.#K(this.default);this.style.setProperty("--slider-complete",j),this.style.setProperty("--default",K),this.style.setProperty("--unchanged",j===K?1:0)}handleInput(){let j=this.input.value;if(this.value=j,this.#Q(),this.figInputText)this.figInputText.setAttribute("value",j)}}window.customElements.define("fig-slider",N);class q extends HTMLElement{constructor(){super()}connectedCallback(){if(this.multiline=this.hasAttribute("multiline")||!1,this.value=this.getAttribute("value")||"",this.type=this.getAttribute("type")||"text",this.type==="number"){if(this.getAttribute("step"))this.step=Number(this.getAttribute("step"));if(this.getAttribute("min"))this.min=Number(this.getAttribute("min"));if(this.getAttribute("max"))this.max=Number(this.getAttribute("max"));if(this.transform=Number(this.getAttribute("transform")||1),this.getAttribute("value"))this.value=Number(this.value)}this.placeholder=this.getAttribute("placeholder")||"";let j=`<input
|
|
45
|
+
type="${this.type}"
|
|
46
|
+
placeholder="${this.placeholder}"
|
|
47
|
+
value="${this.type==="number"?this.#j(this.value):this.value}" />`;if(this.multiline)j=`<textarea
|
|
48
|
+
placeholder="${this.placeholder}">${this.value}</textarea>`;requestAnimationFrame(()=>{const K=this.querySelector("[slot=append]"),J=this.querySelector("[slot=prepend]");if(this.innerHTML=j,J)J.addEventListener("click",this.focus.bind(this)),this.prepend(J);if(K)K.addEventListener("click",this.focus.bind(this)),this.append(K);if(this.input=this.querySelector("input,textarea"),this.type==="number"){if(this.getAttribute("min"))this.input.setAttribute("min",this.#j(this.min));if(this.getAttribute("max"))this.input.setAttribute("max",this.#j(this.max));if(this.getAttribute("step"))this.input.setAttribute("step",this.#j(this.step))}this.input.addEventListener("input",this.#J.bind(this))})}focus(){this.input.focus()}#j(j){return j*(this.transform||1)}#J(j){let K=j.target.value;if(this.type==="number")this.value=K/(this.transform||1);else this.value=K}static get observedAttributes(){return["value","placeholder","label","disabled","type","step","min","max","transform"]}attributeChangedCallback(j,K,J){if(this.input)switch(j){case"disabled":this.disabled=this.input.disabled=J;break;case"transform":if(this.type==="number")this.transform=Number(J)||1,this.min=this.#j(this.min),this.max=this.#j(this.max),this.step=this.#j(this.step),this.value=this.#j(this.value);break;default:let Q=J;if(this.type==="number")Q=this.#j(Q);if(this[j]=this.input[j]=Q,this.input)this.input.setAttribute(j,Q);break}}}window.customElements.define("fig-input-text",q);class T extends HTMLElement{constructor(){super()}connectedCallback(){this.src=this.getAttribute("src"),this.name=this.getAttribute("name"),this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials),this.setSrc(this.src),requestAnimationFrame(()=>{this.img=this.querySelector("img")})}setSrc(j){if(this.src=j,j)this.innerHTML=`<img src="${this.src}" ${this.name?`alt="${this.name}"`:""} />`}getInitials(j){return j?j.split(" ").map((K)=>K[0]).join(""):""}static get observedAttributes(){return["src","href","name"]}attributeChangedCallback(j,K,J){if(this[j]=J,j==="name")this.img?.setAttribute("alt",J),this.name=J,this.initials=this.getInitials(this.name),this.setAttribute("initials",this.initials);else if(j==="src")this.src=J,this.setSrc(this.src)}}window.customElements.define("fig-avatar",T);class S extends HTMLElement{constructor(){super()}connectedCallback(){requestAnimationFrame(()=>{if(this.label=this.querySelector("label"),this.input=Array.from(this.childNodes).find((j)=>j.nodeName.toLowerCase().startsWith("fig-")),this.input&&this.label){this.label.addEventListener("click",this.focus.bind(this));let j=this.input.getAttribute("id")||U();this.input.setAttribute("id",j),this.label.setAttribute("for",j)}})}focus(){this.input.focus()}}window.customElements.define("fig-field",S);class C extends HTMLElement{#j;#J;textInput;#K;constructor(){super()}connectedCallback(){this.#j=this.convertToRGBA(this.getAttribute("value"));const j=(this.#j.a*100).toFixed(0);this.value=this.rgbAlphaToHex({r:this.#j.r,g:this.#j.g,b:this.#j.b},j);let K="";if(this.getAttribute("text")){let J=`<fig-input-text placeholder="Text" value="${this.getAttribute("value")}"></fig-input-text>`;if(this.getAttribute("alpha")==="true")J+=`<fig-tooltip text="Opacity">
|
|
49
|
+
<fig-input-text
|
|
50
|
+
placeholder="##"
|
|
51
|
+
type="number"
|
|
52
|
+
min="0"
|
|
53
|
+
max="100"
|
|
54
|
+
value="${j}">
|
|
55
|
+
<span slot="append">%</slot>
|
|
56
|
+
</fig-input-text>
|
|
57
|
+
</fig-tooltip>`;K=`<div class="input-combo">
|
|
58
|
+
<fig-chit type="color" disabled="false" value="${this.value}"></fig-chit>
|
|
59
|
+
${J}
|
|
60
|
+
</div>`}else K=`<fig-chit type="color" disabled="false" value="${this.value}"></fig-chit>`;this.innerHTML=K,this.style.setProperty("--alpha",this.#j.a),requestAnimationFrame(()=>{if(this.#J=this.querySelector("input[type=color]"),this.textInput=this.querySelector("input[type=text]"),this.#K=this.querySelector("input[type=number]"),this.#J.disabled=this.hasAttribute("disabled"),this.#J.addEventListener("input",this.handleInput.bind(this)),this.textInput)this.textInput.value=this.#J.value=this.rgbAlphaToHex(this.#j,1);if(this.#K)this.#K.addEventListener("input",this.handleAlphaInput.bind(this))})}handleAlphaInput(j){j.stopPropagation(),this.#j=this.convertToRGBA(this.#J.value),this.#j.a=Number(this.#K.value)/100,this.value=this.rgbAlphaToHex({r:this.#j.r,g:this.#j.g,b:this.#j.b},this.#j.a),this.style.setProperty("--alpha",this.#j.a);const K=new CustomEvent("input",{bubbles:!0,cancelable:!0});this.dispatchEvent(K)}focus(){this.#J.focus()}handleInput(j){j.stopPropagation();let K=this.#j.a;if(this.#j=this.convertToRGBA(this.#J.value),this.#j.a=K,this.textInput)this.textInput.value=this.#J.value;if(this.style.setProperty("--alpha",this.#j.a),this.value=this.rgbAlphaToHex({r:this.#j.r,g:this.#j.g,b:this.#j.b},K),this.alpha=K,this.#K)this.#K.value=this.#j.a.toFixed(0);const J=new CustomEvent("input",{bubbles:!0,cancelable:!0});this.dispatchEvent(J)}static get observedAttributes(){return["value","style"]}attributeChangedCallback(j,K,J){}rgbAlphaToHex({r:j,g:K,b:J},Q=1){j=Math.max(0,Math.min(255,Math.round(j))),K=Math.max(0,Math.min(255,Math.round(K))),J=Math.max(0,Math.min(255,Math.round(J))),Q=Math.max(0,Math.min(1,Q));const X=j.toString(16).padStart(2,"0"),W=K.toString(16).padStart(2,"0"),_=J.toString(16).padStart(2,"0");if(Q===1)return`#${X}${W}${_}`;const Z=Math.round(Q*255).toString(16).padStart(2,"0");return`#${X}${W}${_}${Z}`}convertToRGBA(j){let K,J,Q,X=1;if(j.startsWith("#")){let W=j.slice(1);if(W.length===8)X=parseInt(W.slice(6),16)/255,W=W.slice(0,6);K=parseInt(W.slice(0,2),16),J=parseInt(W.slice(2,4),16),Q=parseInt(W.slice(4,6),16)}else if(j.startsWith("rgba")||j.startsWith("rgb")){let W=j.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+(?:\.\d+)?))?\)/);if(W)K=parseInt(W[1]),J=parseInt(W[2]),Q=parseInt(W[3]),X=W[4]?parseFloat(W[4]):1}else if(j.startsWith("hsla")||j.startsWith("hsl")){let W=j.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%(?:,\s*(\d+(?:\.\d+)?))?\)/);if(W){let _=parseInt(W[1])/360,$=parseInt(W[2])/100,Z=parseInt(W[3])/100;if(X=W[4]?parseFloat(W[4]):1,$===0)K=J=Q=Z;else{let H=(z,D,Y)=>{if(Y<0)Y+=1;if(Y>1)Y-=1;if(Y<0.16666666666666666)return z+(D-z)*6*Y;if(Y<0.5)return D;if(Y<0.6666666666666666)return z+(D-z)*(0.6666666666666666-Y)*6;return z},E=Z<0.5?Z*(1+$):Z+$-Z*$,M=2*Z-E;K=H(M,E,_+0.3333333333333333),J=H(M,E,_),Q=H(M,E,_-0.3333333333333333)}K=Math.round(K*255),J=Math.round(J*255),Q=Math.round(Q*255)}}else return null;return{r:K,g:J,b:Q,a:X}}}window.customElements.define("fig-input-color",C);class G extends HTMLElement{constructor(){super();this.input=document.createElement("input"),this.name=this.getAttribute("name")||"checkbox",this.value=this.getAttribute("value")||"",this.input.setAttribute("id",U()),this.input.setAttribute("name",this.name),this.input.setAttribute("type","checkbox"),this.labelElement=document.createElement("label"),this.labelElement.setAttribute("for",this.input.id)}connectedCallback(){if(this.checked=this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false",this.input.addEventListener("change",this.handleInput.bind(this)),this.hasAttribute("disabled"))this.input.disabled=!0;if(this.hasAttribute("indeterminate"))this.input.indeterminate=!0,this.input.setAttribute("indeterminate","true");this.append(this.input),this.append(this.labelElement),this.render()}static get observedAttributes(){return["disabled","label","checked","name","value"]}render(){}focus(){this.input.focus()}disconnectedCallback(){this.input.remove()}attributeChangedCallback(j,K,J){switch(j){case"label":this.labelElement.innerText=J;break;case"checked":this.checked=this.input.checked=this.hasAttribute("checked")&&this.getAttribute("checked")!=="false";break;default:this.input[j]=J,this.input.setAttribute(j,J);break}}handleInput(j){this.input.indeterminate=!1,this.input.removeAttribute("indeterminate"),this.value=this.input.value}}window.customElements.define("fig-checkbox",G);class x extends G{constructor(){super();this.input.setAttribute("type","radio"),this.input.setAttribute("name",this.getAttribute("name")||"radio")}}window.customElements.define("fig-radio",x);class I extends G{render(){this.input.setAttribute("class","switch")}}window.customElements.define("fig-switch",I);class v extends HTMLElement{constructor(){super()}}window.customElements.define("fig-bell",v);class F extends HTMLElement{constructor(){super()}}window.customElements.define("fig-badge",F);class f extends HTMLElement{constructor(){super()}}window.customElements.define("fig-accordion",f);class b extends HTMLElement{constructor(){super()}getOptionsFromAttribute(){return(this.getAttribute("options")||"").split(",")}connectedCallback(){this.options=this.getOptionsFromAttribute(),this.placeholder=this.getAttribute("placeholder")||"",this.value=this.getAttribute("value")||"",this.innerHTML=`<div class="input-combo">
|
|
61
|
+
<fig-input-text placeholder="${this.placeholder}">
|
|
62
|
+
</fig-input-text>
|
|
63
|
+
<fig-button type="select" variant="input" icon>
|
|
64
|
+
<svg width='16' height='16' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'>
|
|
65
|
+
<path d='M5.87868 7.12132L8 9.24264L10.1213 7.12132' stroke='currentColor' stroke-opacity="0.9" stroke-linecap='round'/>
|
|
66
|
+
</svg>
|
|
67
|
+
<fig-dropdown type="dropdown">
|
|
68
|
+
${this.options.map((j)=>`<option>${j}</option>`).join("")}
|
|
69
|
+
</fig-dropdown>
|
|
70
|
+
</fig-button>
|
|
71
|
+
</div>`,requestAnimationFrame(()=>{this.input=this.querySelector("fig-input-text"),this.select=this.querySelector("fig-dropdown"),this.select.addEventListener("input",this.handleSelectInput.bind(this))})}handleSelectInput(j){this.value=j.target.parentNode.value,this.setAttribute("value",this.value)}handleInput(j){this.value=this.input.value}static get observedAttributes(){return["options","placeholder","value"]}attributeChangedCallback(j,K,J){if(j==="options"){if(this.options=J.split(","),this.dropdown)this.dropdown.innerHTML=this.options.map((Q)=>`<option>${Q}</option>`).join("")}if(j==="placeholder")this.placeholder=J;if(j==="value")this.value=J,this.input.setAttribute("value",J)}}window.customElements.define("fig-combo-input",b);class h extends HTMLElement{constructor(){super()}connectedCallback(){this.type=this.getAttribute("type")||"color",this.src=this.getAttribute("src")||"",this.value=this.getAttribute("value")||"",this.size=this.getAttribute("size")||"small",this.disabled=this.getAttribute("disabled")==="true"?!0:!1,this.innerHTML=`<input type="color" value="${this.value}" />`,this.#j(this.src),requestAnimationFrame(()=>{this.input=this.querySelector("input")})}#j(j){if(j)this.src=j,this.style.setProperty("--src",`url(${j})`);else this.style.removeProperty("--src")}static get observedAttributes(){return["src","value","disabled"]}attributeChangedCallback(j,K,J){switch(j){case"src":this.#j(J);break;case"disabled":this.disabled=J.toLowerCase()==="true";break;default:if(this.input)this.input[j]=J;this.#j(this.src);break}}}window.customElements.define("fig-chit",h);class d extends HTMLElement{constructor(){super()}#j(){return`<fig-chit type="image" size="large" ${this.src?`src="${this.src}"`:""} disabled="true"></fig-chit>${this.upload?`<fig-button variant="primary" type="upload">
|
|
72
|
+
${this.label}
|
|
73
|
+
<input type="file" accept="image/*" />
|
|
74
|
+
</fig-button>`:""}`}connectedCallback(){this.src=this.getAttribute("src")||"",this.upload=this.getAttribute("upload")==="true",this.label=this.getAttribute("label")||"Upload",this.size=this.getAttribute("size")||"small",this.innerHTML=this.#j(),this.#J()}#J(){requestAnimationFrame(()=>{if(this.chit=this.querySelector("fig-chit"),this.upload)this.uploadButton=this.querySelector("fig-button"),this.fileInput=this.uploadButton?.querySelector("input"),this.fileInput.addEventListener("change",this.handleFileInput.bind(this))})}handleFileInput(j){this.src=URL.createObjectURL(j.target.files[0]),this.setAttribute("src",this.src),this.chit.setAttribute("src",this.src)}static get observedAttributes(){return["src","upload"]}attributeChangedCallback(j,K,J){if(j==="src"){if(this.src=J,this.chit)this.chit.setAttribute("src",this.src)}if(j==="upload")this.upload=J.toLowerCase()==="true",this.innerHTML=this.#j(),this.#J();if(j==="size")this.size=J}}window.customElements.define("fig-image",d);
|