@rogieking/figui3 2.17.4 → 2.18.0
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/components.css +12 -0
- package/fig.js +25 -1
- package/index.html +56 -63
- package/package.json +1 -1
package/components.css
CHANGED
|
@@ -2512,6 +2512,12 @@ fig-input-fill {
|
|
|
2512
2512
|
gap: 0;
|
|
2513
2513
|
}
|
|
2514
2514
|
}
|
|
2515
|
+
|
|
2516
|
+
fig-field[direction="horizontal"] &,
|
|
2517
|
+
fig-field[direction="row"] & {
|
|
2518
|
+
flex: 1;
|
|
2519
|
+
min-width: 0;
|
|
2520
|
+
}
|
|
2515
2521
|
}
|
|
2516
2522
|
|
|
2517
2523
|
fig-slider {
|
|
@@ -2524,6 +2530,12 @@ fig-slider {
|
|
|
2524
2530
|
& fig-input-number {
|
|
2525
2531
|
flex-basis: 5rem;
|
|
2526
2532
|
}
|
|
2533
|
+
|
|
2534
|
+
fig-field[direction="horizontal"] &,
|
|
2535
|
+
fig-field[direction="row"] & {
|
|
2536
|
+
flex: 1;
|
|
2537
|
+
min-width: 0;
|
|
2538
|
+
}
|
|
2527
2539
|
}
|
|
2528
2540
|
|
|
2529
2541
|
fig-field,
|
package/fig.js
CHANGED
|
@@ -2022,6 +2022,7 @@ customElements.define("fig-segmented-control", FigSegmentedControl);
|
|
|
2022
2022
|
* @attr {string} color - The color for the slider track (for opacity type)
|
|
2023
2023
|
*/
|
|
2024
2024
|
class FigSlider extends HTMLElement {
|
|
2025
|
+
#isInteracting = false;
|
|
2025
2026
|
// Private fields declarations
|
|
2026
2027
|
#typeDefaults = {
|
|
2027
2028
|
range: { min: 0, max: 100, step: 1 },
|
|
@@ -2088,6 +2089,7 @@ class FigSlider extends HTMLElement {
|
|
|
2088
2089
|
let slider = `<div class="fig-slider-input-container" role="group">
|
|
2089
2090
|
<input
|
|
2090
2091
|
type="range"
|
|
2092
|
+
${this.text ? 'tabindex="-1"' : ""}
|
|
2091
2093
|
${this.disabled ? "disabled" : ""}
|
|
2092
2094
|
min="${this.min}"
|
|
2093
2095
|
max="${this.max}"
|
|
@@ -2124,6 +2126,8 @@ class FigSlider extends HTMLElement {
|
|
|
2124
2126
|
this.input.addEventListener("input", this.#boundHandleInput);
|
|
2125
2127
|
this.input.removeEventListener("change", this.#boundHandleChange);
|
|
2126
2128
|
this.input.addEventListener("change", this.#boundHandleChange);
|
|
2129
|
+
this.input.addEventListener("pointerdown", () => { this.#isInteracting = true; });
|
|
2130
|
+
this.input.addEventListener("pointerup", () => { this.#isInteracting = false; });
|
|
2127
2131
|
|
|
2128
2132
|
if (this.default) {
|
|
2129
2133
|
this.style.setProperty(
|
|
@@ -2253,6 +2257,7 @@ class FigSlider extends HTMLElement {
|
|
|
2253
2257
|
}
|
|
2254
2258
|
|
|
2255
2259
|
#handleChange() {
|
|
2260
|
+
this.#isInteracting = false;
|
|
2256
2261
|
this.#syncValue();
|
|
2257
2262
|
this.dispatchEvent(
|
|
2258
2263
|
new CustomEvent("change", { detail: this.value, bubbles: true })
|
|
@@ -2306,6 +2311,7 @@ class FigSlider extends HTMLElement {
|
|
|
2306
2311
|
}
|
|
2307
2312
|
break;
|
|
2308
2313
|
case "value":
|
|
2314
|
+
if (this.#isInteracting) break;
|
|
2309
2315
|
this.value = newValue;
|
|
2310
2316
|
this.input.value = newValue;
|
|
2311
2317
|
this.#syncProperties();
|
|
@@ -2365,6 +2371,7 @@ customElements.define("fig-slider", FigSlider);
|
|
|
2365
2371
|
* @attr {number} transform - A multiplier for displayed number values
|
|
2366
2372
|
*/
|
|
2367
2373
|
class FigInputText extends HTMLElement {
|
|
2374
|
+
#isInteracting = false;
|
|
2368
2375
|
#boundMouseMove;
|
|
2369
2376
|
#boundMouseUp;
|
|
2370
2377
|
#boundMouseDown;
|
|
@@ -2507,6 +2514,7 @@ class FigInputText extends HTMLElement {
|
|
|
2507
2514
|
#handleMouseDown(e) {
|
|
2508
2515
|
if (this.type !== "number") return;
|
|
2509
2516
|
if (e.altKey) {
|
|
2517
|
+
this.#isInteracting = true;
|
|
2510
2518
|
this.input.style.cursor =
|
|
2511
2519
|
this.style.cursor =
|
|
2512
2520
|
document.body.style.cursor =
|
|
@@ -2519,6 +2527,7 @@ class FigInputText extends HTMLElement {
|
|
|
2519
2527
|
}
|
|
2520
2528
|
#handleMouseUp(e) {
|
|
2521
2529
|
if (this.type !== "number") return;
|
|
2530
|
+
this.#isInteracting = false;
|
|
2522
2531
|
this.input.style.cursor =
|
|
2523
2532
|
this.style.cursor =
|
|
2524
2533
|
document.body.style.cursor =
|
|
@@ -2594,6 +2603,7 @@ class FigInputText extends HTMLElement {
|
|
|
2594
2603
|
}
|
|
2595
2604
|
break;
|
|
2596
2605
|
case "value":
|
|
2606
|
+
if (this.#isInteracting) break;
|
|
2597
2607
|
let value = newValue;
|
|
2598
2608
|
if (this.type === "number") {
|
|
2599
2609
|
value = this.#sanitizeInput(value, false);
|
|
@@ -2651,6 +2661,7 @@ class FigInputNumber extends HTMLElement {
|
|
|
2651
2661
|
#units;
|
|
2652
2662
|
#unitPosition;
|
|
2653
2663
|
#precision;
|
|
2664
|
+
#isInteracting = false;
|
|
2654
2665
|
|
|
2655
2666
|
constructor() {
|
|
2656
2667
|
super();
|
|
@@ -2830,6 +2841,7 @@ class FigInputNumber extends HTMLElement {
|
|
|
2830
2841
|
}
|
|
2831
2842
|
|
|
2832
2843
|
#handleFocus(e) {
|
|
2844
|
+
this.#isInteracting = true;
|
|
2833
2845
|
setTimeout(() => {
|
|
2834
2846
|
const value = e.target.value;
|
|
2835
2847
|
if (value && this.#units) {
|
|
@@ -2846,6 +2858,7 @@ class FigInputNumber extends HTMLElement {
|
|
|
2846
2858
|
}
|
|
2847
2859
|
|
|
2848
2860
|
#handleBlur(e) {
|
|
2861
|
+
this.#isInteracting = false;
|
|
2849
2862
|
let numericValue = this.#getNumericValue(e.target.value);
|
|
2850
2863
|
if (numericValue !== "") {
|
|
2851
2864
|
let val = Number(numericValue) / (this.transform || 1);
|
|
@@ -2939,6 +2952,7 @@ class FigInputNumber extends HTMLElement {
|
|
|
2939
2952
|
#handleMouseDown(e) {
|
|
2940
2953
|
if (this.disabled) return;
|
|
2941
2954
|
if (e.altKey) {
|
|
2955
|
+
this.#isInteracting = true;
|
|
2942
2956
|
this.input.style.cursor =
|
|
2943
2957
|
this.style.cursor =
|
|
2944
2958
|
document.body.style.cursor =
|
|
@@ -2951,6 +2965,7 @@ class FigInputNumber extends HTMLElement {
|
|
|
2951
2965
|
}
|
|
2952
2966
|
|
|
2953
2967
|
#handleMouseUp(e) {
|
|
2968
|
+
this.#isInteracting = false;
|
|
2954
2969
|
this.input.style.cursor =
|
|
2955
2970
|
this.style.cursor =
|
|
2956
2971
|
document.body.style.cursor =
|
|
@@ -3019,6 +3034,7 @@ class FigInputNumber extends HTMLElement {
|
|
|
3019
3034
|
this.input.value = this.#formatWithUnit(this.value);
|
|
3020
3035
|
break;
|
|
3021
3036
|
case "value":
|
|
3037
|
+
if (this.#isInteracting) break;
|
|
3022
3038
|
let value =
|
|
3023
3039
|
newValue !== null && newValue !== "" ? Number(newValue) : "";
|
|
3024
3040
|
if (value !== "") {
|
|
@@ -4167,9 +4183,15 @@ class FigInputFill extends HTMLElement {
|
|
|
4167
4183
|
|
|
4168
4184
|
switch (name) {
|
|
4169
4185
|
case "value":
|
|
4186
|
+
const prevType = this.#fillType;
|
|
4170
4187
|
this.#parseValue();
|
|
4171
4188
|
if (this.#fillPicker) {
|
|
4172
|
-
this.#
|
|
4189
|
+
if (this.#fillType !== prevType) {
|
|
4190
|
+
this.#render();
|
|
4191
|
+
} else {
|
|
4192
|
+
this.#updateFillPicker();
|
|
4193
|
+
this.#updateControls();
|
|
4194
|
+
}
|
|
4173
4195
|
}
|
|
4174
4196
|
break;
|
|
4175
4197
|
case "disabled":
|
|
@@ -5314,6 +5336,7 @@ class FigInputJoystick extends HTMLElement {
|
|
|
5314
5336
|
}
|
|
5315
5337
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
5316
5338
|
if (name === "value") {
|
|
5339
|
+
if (this.isDragging) return;
|
|
5317
5340
|
this.value = newValue;
|
|
5318
5341
|
}
|
|
5319
5342
|
if (name === "precision") {
|
|
@@ -5771,6 +5794,7 @@ class FigInputAngle extends HTMLElement {
|
|
|
5771
5794
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
5772
5795
|
switch (name) {
|
|
5773
5796
|
case "value":
|
|
5797
|
+
if (this.isDragging) break;
|
|
5774
5798
|
this.value = Number(newValue);
|
|
5775
5799
|
break;
|
|
5776
5800
|
case "precision":
|
package/index.html
CHANGED
|
@@ -1267,69 +1267,62 @@
|
|
|
1267
1267
|
</fig-field>
|
|
1268
1268
|
|
|
1269
1269
|
<h3>Horizontal Fields with Different Inputs</h3>
|
|
1270
|
-
<
|
|
1271
|
-
|
|
1272
|
-
<
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
</fig-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
<fig-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
<
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
<fig-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
<label>Segmented</label>
|
|
1327
|
-
<fig-segmented-control>
|
|
1328
|
-
<fig-segment value="left">Left</fig-segment>
|
|
1329
|
-
<fig-segment value="center">Center</fig-segment>
|
|
1330
|
-
<fig-segment value="right">Right</fig-segment>
|
|
1331
|
-
</fig-segmented-control>
|
|
1332
|
-
</fig-field>
|
|
1270
|
+
<p class="description">Drag the right edge to test at different widths.</p>
|
|
1271
|
+
<div class="resize-test" style="width: 240px;">
|
|
1272
|
+
<fig-field direction="horizontal">
|
|
1273
|
+
<label>Text Input</label>
|
|
1274
|
+
<fig-input-text placeholder="Enter text" full></fig-input-text>
|
|
1275
|
+
</fig-field>
|
|
1276
|
+
<fig-field direction="horizontal">
|
|
1277
|
+
<label>Number Input</label>
|
|
1278
|
+
<fig-input-number value="100"
|
|
1279
|
+
units="px" full></fig-input-number>
|
|
1280
|
+
</fig-field>
|
|
1281
|
+
<fig-field direction="horizontal">
|
|
1282
|
+
<label>Dropdown</label>
|
|
1283
|
+
<fig-dropdown full>
|
|
1284
|
+
<option>Option One</option>
|
|
1285
|
+
<option>Option Two</option>
|
|
1286
|
+
<option>Option Three</option>
|
|
1287
|
+
</fig-dropdown>
|
|
1288
|
+
</fig-field>
|
|
1289
|
+
<fig-field direction="horizontal">
|
|
1290
|
+
<label>Slider</label>
|
|
1291
|
+
<fig-slider value="50"
|
|
1292
|
+
text="true" full></fig-slider>
|
|
1293
|
+
</fig-field>
|
|
1294
|
+
<fig-field direction="horizontal">
|
|
1295
|
+
<label>Color</label>
|
|
1296
|
+
<fig-input-color value="#0D99FF"
|
|
1297
|
+
text="true" full></fig-input-color>
|
|
1298
|
+
</fig-field>
|
|
1299
|
+
<fig-field direction="horizontal">
|
|
1300
|
+
<label>Angle</label>
|
|
1301
|
+
<fig-input-angle value="45"
|
|
1302
|
+
text="true" full></fig-input-angle>
|
|
1303
|
+
</fig-field>
|
|
1304
|
+
<fig-field direction="horizontal">
|
|
1305
|
+
<label>Joystick</label>
|
|
1306
|
+
<fig-input-joystick text="true"
|
|
1307
|
+
value="50,50" full></fig-input-joystick>
|
|
1308
|
+
</fig-field>
|
|
1309
|
+
<fig-field direction="horizontal">
|
|
1310
|
+
<label>Switch</label>
|
|
1311
|
+
<fig-switch></fig-switch>
|
|
1312
|
+
</fig-field>
|
|
1313
|
+
<fig-field direction="horizontal">
|
|
1314
|
+
<label>Checkbox</label>
|
|
1315
|
+
<fig-checkbox></fig-checkbox>
|
|
1316
|
+
</fig-field>
|
|
1317
|
+
<fig-field direction="horizontal">
|
|
1318
|
+
<label>Segmented</label>
|
|
1319
|
+
<fig-segmented-control full>
|
|
1320
|
+
<fig-segment value="left">Left</fig-segment>
|
|
1321
|
+
<fig-segment value="center">Center</fig-segment>
|
|
1322
|
+
<fig-segment value="right">Right</fig-segment>
|
|
1323
|
+
</fig-segmented-control>
|
|
1324
|
+
</fig-field>
|
|
1325
|
+
</div>
|
|
1333
1326
|
</section>
|
|
1334
1327
|
<hr>
|
|
1335
1328
|
|
package/package.json
CHANGED