@arcanejs/toolkit 0.4.0 → 0.5.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/dist/backend/components/base.d.mts +1 -1
- package/dist/backend/components/base.d.ts +1 -1
- package/dist/backend/components/button.d.mts +1 -1
- package/dist/backend/components/button.d.ts +1 -1
- package/dist/backend/components/group.d.mts +1 -1
- package/dist/backend/components/group.d.ts +1 -1
- package/dist/backend/components/label.d.mts +1 -1
- package/dist/backend/components/label.d.ts +1 -1
- package/dist/backend/components/rect.d.mts +2 -4
- package/dist/backend/components/rect.d.ts +2 -4
- package/dist/backend/components/rect.js +2 -2
- package/dist/backend/components/rect.mjs +1 -1
- package/dist/backend/components/slider-button.d.mts +2 -5
- package/dist/backend/components/slider-button.d.ts +2 -5
- package/dist/backend/components/slider-button.js +2 -2
- package/dist/backend/components/slider-button.mjs +1 -1
- package/dist/backend/components/switch.d.mts +1 -1
- package/dist/backend/components/switch.d.ts +1 -1
- package/dist/backend/components/tabs.d.mts +1 -1
- package/dist/backend/components/tabs.d.ts +1 -1
- package/dist/backend/components/text-input.d.mts +1 -1
- package/dist/backend/components/text-input.d.ts +1 -1
- package/dist/backend/components/timeline.d.mts +1 -1
- package/dist/backend/components/timeline.d.ts +1 -1
- package/dist/backend/util/index.d.mts +8 -6
- package/dist/backend/util/index.d.ts +8 -6
- package/dist/backend/util/index.js +13 -1
- package/dist/backend/util/index.mjs +12 -0
- package/dist/{chunk-G7GFSIHY.js → chunk-53DEDXHG.js} +3 -1
- package/dist/{chunk-KOKUFP6V.mjs → chunk-ESMRIWOM.mjs} +1 -1
- package/dist/{chunk-K572ZPUS.js → chunk-IQ4SDDYP.js} +1 -1
- package/dist/{chunk-A2STBGBE.mjs → chunk-SN2XKRYX.mjs} +3 -1
- package/dist/frontend.js +146 -69
- package/dist/frontend.js.map +4 -4
- package/dist/id-map-DxQ3_gyA.d.mts +7 -0
- package/dist/id-map-DxQ3_gyA.d.ts +7 -0
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +2 -2
- package/package.json +3 -3
package/dist/frontend.js
CHANGED
|
@@ -1109,7 +1109,7 @@
|
|
|
1109
1109
|
var dispatcher = resolveDispatcher();
|
|
1110
1110
|
return dispatcher.useLayoutEffect(create, deps);
|
|
1111
1111
|
}
|
|
1112
|
-
function
|
|
1112
|
+
function useCallback2(callback, deps) {
|
|
1113
1113
|
var dispatcher = resolveDispatcher();
|
|
1114
1114
|
return dispatcher.useCallback(callback, deps);
|
|
1115
1115
|
}
|
|
@@ -1876,7 +1876,7 @@
|
|
|
1876
1876
|
exports.memo = memo;
|
|
1877
1877
|
exports.startTransition = startTransition;
|
|
1878
1878
|
exports.unstable_act = act;
|
|
1879
|
-
exports.useCallback =
|
|
1879
|
+
exports.useCallback = useCallback2;
|
|
1880
1880
|
exports.useContext = useContext2;
|
|
1881
1881
|
exports.useDebugValue = useDebugValue;
|
|
1882
1882
|
exports.useDeferredValue = useDeferredValue;
|
|
@@ -26144,11 +26144,13 @@ body {
|
|
|
26144
26144
|
transition: border-color 0s;
|
|
26145
26145
|
`;
|
|
26146
26146
|
|
|
26147
|
-
// ../toolkit-frontend/dist/chunk-
|
|
26147
|
+
// ../toolkit-frontend/dist/chunk-UJVH3PQF.mjs
|
|
26148
26148
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
26149
26149
|
var core_exports = {};
|
|
26150
26150
|
__export(core_exports, {
|
|
26151
|
-
Icon: () => Icon
|
|
26151
|
+
Icon: () => Icon,
|
|
26152
|
+
TRANSPARENCY_SVG: () => TRANSPARENCY_SVG,
|
|
26153
|
+
TRANSPARENCY_SVG_URI: () => TRANSPARENCY_SVG_URI
|
|
26152
26154
|
});
|
|
26153
26155
|
var ICON_CLASS = "icon";
|
|
26154
26156
|
var Span = dt.span`
|
|
@@ -26168,6 +26170,14 @@ body {
|
|
|
26168
26170
|
'GRAD' -25;
|
|
26169
26171
|
`;
|
|
26170
26172
|
var Icon = ({ icon, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Span, { className: calculateClass(props.className, ICON_CLASS), ...props, children: icon });
|
|
26173
|
+
var TRANSPARENCY_SVG = `
|
|
26174
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
|
|
26175
|
+
<rect width="10px" height="10px" fill="#333" />
|
|
26176
|
+
<rect width="5px" height="5px" fill="#ddd" y="5"/>
|
|
26177
|
+
<rect width="5px" height="5px" fill="#ddd" x="5"/>
|
|
26178
|
+
</svg>
|
|
26179
|
+
`;
|
|
26180
|
+
var TRANSPARENCY_SVG_URI = `data:image/svg+xml,${encodeURIComponent(TRANSPARENCY_SVG)}`;
|
|
26171
26181
|
|
|
26172
26182
|
// ../toolkit-frontend/dist/components/index.mjs
|
|
26173
26183
|
var import_react3 = __toESM(require_react(), 1);
|
|
@@ -26493,29 +26503,30 @@ body {
|
|
|
26493
26503
|
font-weight: ${(p2) => p2.info.bold ? "bold" : "normal"};
|
|
26494
26504
|
white-space: nowrap;
|
|
26495
26505
|
`;
|
|
26496
|
-
var
|
|
26497
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
|
|
26498
|
-
<rect width="10px" height="10px" fill="#333" />
|
|
26499
|
-
<rect width="5px" height="5px" fill="#ddd" y="5"/>
|
|
26500
|
-
<rect width="5px" height="5px" fill="#ddd" x="5"/>
|
|
26501
|
-
</svg>
|
|
26502
|
-
`;
|
|
26506
|
+
var CLS_GROW = "grow";
|
|
26503
26507
|
var Wrapper = dt.div`
|
|
26504
|
-
width: 30px;
|
|
26508
|
+
min-width: 30px;
|
|
26505
26509
|
height: 30px;
|
|
26506
26510
|
border-radius: 3px;
|
|
26507
26511
|
overflow: hidden;
|
|
26508
|
-
background: url('
|
|
26512
|
+
background: url('${TRANSPARENCY_SVG_URI}');
|
|
26509
26513
|
background-repeat: repeat;
|
|
26510
26514
|
background-size: 10px;
|
|
26515
|
+
border: 1px solid ${THEME.borderDark};
|
|
26516
|
+
|
|
26517
|
+
&.${CLS_GROW} {
|
|
26518
|
+
flex-grow: 1;
|
|
26519
|
+
}
|
|
26511
26520
|
`;
|
|
26512
26521
|
var Inner = dt.div`
|
|
26513
26522
|
width: 100%;
|
|
26514
26523
|
height: 100%;
|
|
26515
26524
|
`;
|
|
26516
|
-
var Rect = ({ className, info }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Wrapper, { className, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Inner, { style: { backgroundColor: info.color } }) });
|
|
26525
|
+
var Rect = ({ className, info }) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Wrapper, { className: calculateClass(className, info.grow && CLS_GROW), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Inner, { style: { backgroundColor: info.color } }) });
|
|
26517
26526
|
var CLASS_SLIDER_DISPLAY = "slider-display";
|
|
26518
26527
|
var CLASS_SLIDER_VALUE = "slider-value";
|
|
26528
|
+
var CLASS_GRADIENT = "gradient";
|
|
26529
|
+
var CLASS_GROW = "grow";
|
|
26519
26530
|
var OPEN_SLIDER_WIDTH = 400;
|
|
26520
26531
|
var SLIDER_PADDING = 15;
|
|
26521
26532
|
var SLIDER_VALUE_WIDTH = 60;
|
|
@@ -26535,37 +26546,49 @@ body {
|
|
|
26535
26546
|
const rect = elem.getBoundingClientRect();
|
|
26536
26547
|
return pageX - rect.left;
|
|
26537
26548
|
};
|
|
26538
|
-
var SliderButton = (
|
|
26549
|
+
var SliderButton = ({ info, sendMessage, className }) => {
|
|
26539
26550
|
const [state, setState] = import_react7.default.useState({ state: "closed" });
|
|
26540
26551
|
const input = import_react7.default.useRef(null);
|
|
26541
26552
|
const displayValue = (value2) => {
|
|
26542
|
-
if (
|
|
26553
|
+
if (info.max === 1 && info.min === 0) {
|
|
26543
26554
|
return `${Math.round(value2 * 100)}%`;
|
|
26544
26555
|
}
|
|
26545
26556
|
return NUMBER_FORMATTER.format(value2);
|
|
26546
26557
|
};
|
|
26547
|
-
const sendValue = (
|
|
26548
|
-
|
|
26549
|
-
|
|
26550
|
-
|
|
26551
|
-
|
|
26552
|
-
|
|
26553
|
-
|
|
26554
|
-
|
|
26555
|
-
|
|
26556
|
-
const sanitizeValue = (
|
|
26557
|
-
|
|
26558
|
-
|
|
26559
|
-
|
|
26560
|
-
|
|
26561
|
-
|
|
26562
|
-
|
|
26563
|
-
|
|
26564
|
-
|
|
26558
|
+
const sendValue = (0, import_react7.useCallback)(
|
|
26559
|
+
(value2) => sendMessage?.({
|
|
26560
|
+
type: "component-message",
|
|
26561
|
+
componentKey: info.key,
|
|
26562
|
+
component: "slider_button",
|
|
26563
|
+
value: value2
|
|
26564
|
+
}),
|
|
26565
|
+
[sendMessage, info.key]
|
|
26566
|
+
);
|
|
26567
|
+
const sanitizeValue = (0, import_react7.useCallback)(
|
|
26568
|
+
(value2) => {
|
|
26569
|
+
const i2 = Math.round((value2 - info.min) / info.step);
|
|
26570
|
+
const v2 = i2 * info.step + info.min;
|
|
26571
|
+
return Math.max(info.min, Math.min(info.max, v2));
|
|
26572
|
+
},
|
|
26573
|
+
[info.min, info.max, info.step]
|
|
26574
|
+
);
|
|
26575
|
+
const getNewValue = (0, import_react7.useCallback)(
|
|
26576
|
+
(startValue, diff) => {
|
|
26577
|
+
return sanitizeValue((startValue || 0) + diff);
|
|
26578
|
+
},
|
|
26579
|
+
[sanitizeValue]
|
|
26580
|
+
);
|
|
26581
|
+
const getCurrentInputValue = (0, import_react7.useCallback)(
|
|
26582
|
+
(e) => {
|
|
26583
|
+
const float = parseFloat(e.currentTarget.value);
|
|
26584
|
+
return sanitizeValue(isNaN(float) ? info.value || 0 : float);
|
|
26585
|
+
},
|
|
26586
|
+
[info.value, sanitizeValue]
|
|
26587
|
+
);
|
|
26565
26588
|
const onKeyDown = (e) => {
|
|
26566
26589
|
if (e.key === KEYS.ArrowDown || e.key === KEYS.ArrowUp) {
|
|
26567
26590
|
const currentValue = getCurrentInputValue(e);
|
|
26568
|
-
const diff = e.key === KEYS.ArrowUp ?
|
|
26591
|
+
const diff = e.key === KEYS.ArrowUp ? info.step : -info.step;
|
|
26569
26592
|
const newValue = sanitizeValue(currentValue + diff);
|
|
26570
26593
|
e.currentTarget.value = NUMBER_FORMATTER.format(newValue);
|
|
26571
26594
|
sendValue(newValue);
|
|
@@ -26579,7 +26602,7 @@ body {
|
|
|
26579
26602
|
};
|
|
26580
26603
|
const onFocus = (e) => {
|
|
26581
26604
|
setState({ state: "focused" });
|
|
26582
|
-
e.currentTarget.value = `${
|
|
26605
|
+
e.currentTarget.value = `${info.value || 0}`;
|
|
26583
26606
|
};
|
|
26584
26607
|
const onBlur = () => {
|
|
26585
26608
|
setState({ state: "closed" });
|
|
@@ -26596,13 +26619,13 @@ body {
|
|
|
26596
26619
|
touch,
|
|
26597
26620
|
(p2) => {
|
|
26598
26621
|
const amntDiff = (p2.pageX - originalPageX) / OPEN_SLIDER_INNER_WIDTH;
|
|
26599
|
-
const newValueDiff = (
|
|
26622
|
+
const newValueDiff = (info.max - info.min) * amntDiff;
|
|
26600
26623
|
sendValue(getNewValue(start.startValue, newValueDiff));
|
|
26601
26624
|
setState({ ...start, diff: newValueDiff });
|
|
26602
26625
|
},
|
|
26603
26626
|
(p2) => {
|
|
26604
26627
|
const amntDiff = (p2.pageX - originalPageX) / OPEN_SLIDER_INNER_WIDTH;
|
|
26605
|
-
const newValueDiff = (
|
|
26628
|
+
const newValueDiff = (info.max - info.min) * amntDiff;
|
|
26606
26629
|
sendValue(getNewValue(start.startValue, newValueDiff));
|
|
26607
26630
|
setState({ state: "closed" });
|
|
26608
26631
|
}
|
|
@@ -26611,12 +26634,12 @@ body {
|
|
|
26611
26634
|
}
|
|
26612
26635
|
};
|
|
26613
26636
|
const onDown = (cursorStartPosition) => {
|
|
26614
|
-
const value2 =
|
|
26615
|
-
const amnt = (value2 -
|
|
26637
|
+
const value2 = info.value === null ? 0 : info.value;
|
|
26638
|
+
const amnt = (value2 - info.min) / (info.max - info.min);
|
|
26616
26639
|
const innerLeft = cursorStartPosition - amnt * OPEN_SLIDER_INNER_WIDTH - SLIDER_PADDING * 2 - SLIDER_VALUE_WIDTH + "px";
|
|
26617
26640
|
const start = {
|
|
26618
26641
|
state: "touching",
|
|
26619
|
-
startValue:
|
|
26642
|
+
startValue: info.value,
|
|
26620
26643
|
startX: cursorStartPosition,
|
|
26621
26644
|
innerLeft,
|
|
26622
26645
|
diff: 0
|
|
@@ -26624,42 +26647,66 @@ body {
|
|
|
26624
26647
|
setState(start);
|
|
26625
26648
|
return start;
|
|
26626
26649
|
};
|
|
26627
|
-
const value = state.state === "touching" ? getNewValue(state.startValue, state.diff) :
|
|
26650
|
+
const value = state.state === "touching" ? getNewValue(state.startValue, state.diff) : info.value;
|
|
26628
26651
|
const valueDisplay = value !== null ? displayValue(value) : "";
|
|
26629
|
-
const valueCSSPercent = value ? (value -
|
|
26630
|
-
|
|
26652
|
+
const valueCSSPercent = value ? (value - info.min) / (info.max - info.min) * 100 + "%" : "0";
|
|
26653
|
+
const gradientStops = info.gradient && info.gradient.map((g2) => `${g2.color} ${g2.position * 100}%`);
|
|
26654
|
+
const sliderGradient = gradientStops ? {
|
|
26655
|
+
background: `linear-gradient(90deg, ${gradientStops.join(", ")}), url(${TRANSPARENCY_SVG_URI})`
|
|
26656
|
+
} : void 0;
|
|
26657
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
26631
26658
|
"div",
|
|
26632
26659
|
{
|
|
26633
|
-
className:
|
|
26634
|
-
|
|
26635
|
-
|
|
26636
|
-
|
|
26637
|
-
|
|
26638
|
-
children:
|
|
26639
|
-
|
|
26640
|
-
|
|
26641
|
-
|
|
26642
|
-
|
|
26643
|
-
|
|
26644
|
-
|
|
26645
|
-
|
|
26646
|
-
|
|
26647
|
-
|
|
26648
|
-
|
|
26649
|
-
|
|
26650
|
-
|
|
26651
|
-
|
|
26652
|
-
|
|
26660
|
+
className: calculateClass(
|
|
26661
|
+
className,
|
|
26662
|
+
`state-${state.state}`,
|
|
26663
|
+
info.grow && CLASS_GROW
|
|
26664
|
+
),
|
|
26665
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
26666
|
+
"div",
|
|
26667
|
+
{
|
|
26668
|
+
className: "inner",
|
|
26669
|
+
onMouseDown: () => setState({ state: "mouse-down" }),
|
|
26670
|
+
onMouseUp: () => input.current?.focus(),
|
|
26671
|
+
onTouchStart,
|
|
26672
|
+
style: state.state === "touching" ? { left: state.innerLeft } : {},
|
|
26673
|
+
children: [
|
|
26674
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
26675
|
+
"input",
|
|
26676
|
+
{
|
|
26677
|
+
type: "text",
|
|
26678
|
+
ref: input,
|
|
26679
|
+
onFocus,
|
|
26680
|
+
onBlur,
|
|
26681
|
+
onKeyDown
|
|
26682
|
+
}
|
|
26683
|
+
),
|
|
26684
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: CLASS_SLIDER_VALUE, children: valueDisplay }),
|
|
26685
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
26686
|
+
"div",
|
|
26687
|
+
{
|
|
26688
|
+
className: calculateClass(
|
|
26689
|
+
CLASS_SLIDER_DISPLAY,
|
|
26690
|
+
sliderGradient && CLASS_GRADIENT
|
|
26691
|
+
),
|
|
26692
|
+
style: sliderGradient,
|
|
26693
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "inner", style: { width: valueCSSPercent } })
|
|
26694
|
+
}
|
|
26695
|
+
),
|
|
26696
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: CLASS_SLIDER_VALUE, children: valueDisplay })
|
|
26697
|
+
]
|
|
26698
|
+
}
|
|
26699
|
+
)
|
|
26653
26700
|
}
|
|
26654
|
-
)
|
|
26701
|
+
);
|
|
26655
26702
|
};
|
|
26656
26703
|
var StyledSliderButton = dt(SliderButton)`
|
|
26657
26704
|
position: relative;
|
|
26658
|
-
width: 100px;
|
|
26659
|
-
height: 30px;
|
|
26705
|
+
min-width: 100px;
|
|
26706
|
+
min-height: 30px;
|
|
26660
26707
|
|
|
26661
|
-
|
|
26662
|
-
flex-
|
|
26708
|
+
&.${CLASS_GROW} {
|
|
26709
|
+
flex-grow: 1;
|
|
26663
26710
|
}
|
|
26664
26711
|
|
|
26665
26712
|
> .inner {
|
|
@@ -26703,6 +26750,36 @@ body {
|
|
|
26703
26750
|
height: 100%;
|
|
26704
26751
|
background: ${THEME.hint};
|
|
26705
26752
|
}
|
|
26753
|
+
|
|
26754
|
+
&.${CLASS_GRADIENT} {
|
|
26755
|
+
height: 10px;
|
|
26756
|
+
|
|
26757
|
+
> .inner {
|
|
26758
|
+
position: relative;
|
|
26759
|
+
background: none;
|
|
26760
|
+
border-right: 2px solid ${THEME.borderDark};
|
|
26761
|
+
|
|
26762
|
+
&::before {
|
|
26763
|
+
content: '';
|
|
26764
|
+
position: absolute;
|
|
26765
|
+
width: 4px;
|
|
26766
|
+
top: -5px;
|
|
26767
|
+
bottom: -5px;
|
|
26768
|
+
right: -3px;
|
|
26769
|
+
background: ${THEME.borderDark};
|
|
26770
|
+
}
|
|
26771
|
+
|
|
26772
|
+
&::after {
|
|
26773
|
+
content: '';
|
|
26774
|
+
position: absolute;
|
|
26775
|
+
width: 2px;
|
|
26776
|
+
top: -4px;
|
|
26777
|
+
bottom: -4px;
|
|
26778
|
+
right: -2px;
|
|
26779
|
+
background: ${THEME.textNormal};
|
|
26780
|
+
}
|
|
26781
|
+
}
|
|
26782
|
+
}
|
|
26706
26783
|
}
|
|
26707
26784
|
|
|
26708
26785
|
> .${CLASS_SLIDER_VALUE} {
|