dirk-cfx-react 1.1.73 → 1.1.76
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/components/index.cjs +300 -0
- package/dist/components/index.cjs.map +1 -1
- package/dist/components/index.d.cts +21 -1
- package/dist/components/index.d.ts +21 -1
- package/dist/components/index.js +302 -3
- package/dist/components/index.js.map +1 -1
- package/dist/hooks/index.cjs.map +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/index.cjs +299 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +301 -3
- package/dist/index.js.map +1 -1
- package/dist/providers/index.cjs +6 -0
- package/dist/providers/index.cjs.map +1 -1
- package/dist/providers/index.js +6 -0
- package/dist/providers/index.js.map +1 -1
- package/dist/utils/index.cjs.map +1 -1
- package/dist/utils/index.d.cts +1 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js.map +1 -1
- package/package.json +3 -1
|
@@ -11,6 +11,7 @@ var clickSoundUrl = require('../click_sound-PNCRRTM4.mp3');
|
|
|
11
11
|
var hoverSoundUrl = require('../hover_sound-NBUA222C.mp3');
|
|
12
12
|
var notifications = require('@mantine/notifications');
|
|
13
13
|
var reactQuery = require('@tanstack/react-query');
|
|
14
|
+
var colorsGenerator = require('@mantine/colors-generator');
|
|
14
15
|
|
|
15
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
|
|
@@ -3713,6 +3714,13 @@ function useForm() {
|
|
|
3713
3714
|
}, [state.values, state.initialValues]);
|
|
3714
3715
|
return { ...state, changedFields, changedCount: changedFields.length };
|
|
3715
3716
|
}
|
|
3717
|
+
function useFormField(path) {
|
|
3718
|
+
const store = react.useContext(FormContext);
|
|
3719
|
+
if (!store) {
|
|
3720
|
+
throw new Error("useFormField must be used inside <FormProvider>");
|
|
3721
|
+
}
|
|
3722
|
+
return zustand.useStore(store, (s) => getNested(s.values, path));
|
|
3723
|
+
}
|
|
3716
3724
|
function useFormActions() {
|
|
3717
3725
|
const store = react.useContext(FormContext);
|
|
3718
3726
|
if (!store) {
|
|
@@ -4099,7 +4107,22 @@ function ConfigPanelInner({
|
|
|
4099
4107
|
if (result?.success) {
|
|
4100
4108
|
const { store } = getScriptConfigInstance();
|
|
4101
4109
|
form.reinitialize(cloneConfig(store.getState()));
|
|
4110
|
+
notifications.notifications.show({
|
|
4111
|
+
color: "green",
|
|
4112
|
+
title: locale("ConfigResetSuccessTitle"),
|
|
4113
|
+
message: locale("ConfigResetSuccessBody"),
|
|
4114
|
+
autoClose: 3e3
|
|
4115
|
+
});
|
|
4116
|
+
return;
|
|
4102
4117
|
}
|
|
4118
|
+
const err = result?._error || "Unknown";
|
|
4119
|
+
console.warn(`[ConfigPanel] config reset failed: ${err}`);
|
|
4120
|
+
notifications.notifications.show({
|
|
4121
|
+
color: "red",
|
|
4122
|
+
title: locale("ConfigResetFailedTitle"),
|
|
4123
|
+
message: locale("ConfigResetFailedBody", err),
|
|
4124
|
+
autoClose: 6e3
|
|
4125
|
+
});
|
|
4103
4126
|
},
|
|
4104
4127
|
onClose: () => setResetOpen(false),
|
|
4105
4128
|
zIndex: 300
|
|
@@ -5274,6 +5297,282 @@ function TestBed({
|
|
|
5274
5297
|
}
|
|
5275
5298
|
);
|
|
5276
5299
|
}
|
|
5300
|
+
var MANTINE_COLOR_OPTIONS = [
|
|
5301
|
+
"dirk",
|
|
5302
|
+
"red",
|
|
5303
|
+
"pink",
|
|
5304
|
+
"grape",
|
|
5305
|
+
"violet",
|
|
5306
|
+
"indigo",
|
|
5307
|
+
"blue",
|
|
5308
|
+
"cyan",
|
|
5309
|
+
"teal",
|
|
5310
|
+
"green",
|
|
5311
|
+
"lime",
|
|
5312
|
+
"yellow",
|
|
5313
|
+
"orange"
|
|
5314
|
+
].map((value) => ({ value, label: value }));
|
|
5315
|
+
var DEFAULT_PALETTE = [
|
|
5316
|
+
"#f0f4ff",
|
|
5317
|
+
"#d9e3ff",
|
|
5318
|
+
"#bfcfff",
|
|
5319
|
+
"#a6bbff",
|
|
5320
|
+
"#8ca7ff",
|
|
5321
|
+
"#7393ff",
|
|
5322
|
+
"#5a7fff",
|
|
5323
|
+
"#406bff",
|
|
5324
|
+
"#2547ff",
|
|
5325
|
+
"#0b33ff"
|
|
5326
|
+
];
|
|
5327
|
+
var DEFAULT_VALUE = {
|
|
5328
|
+
useOverride: false,
|
|
5329
|
+
primaryColor: "dirk",
|
|
5330
|
+
primaryShade: 5,
|
|
5331
|
+
customTheme: DEFAULT_PALETTE
|
|
5332
|
+
};
|
|
5333
|
+
function GroupLabel({ label }) {
|
|
5334
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", gap: "xs", mt: "xxs", children: [
|
|
5335
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", tt: "uppercase", lts: "0.07em", c: "rgba(255,255,255,0.2)", children: label }),
|
|
5336
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { style: { flex: 1, height: "0.05vh", background: "rgba(255,255,255,0.06)" } })
|
|
5337
|
+
] });
|
|
5338
|
+
}
|
|
5339
|
+
function ThemeOverrideSection({
|
|
5340
|
+
schemaKey = "theme",
|
|
5341
|
+
title
|
|
5342
|
+
}) {
|
|
5343
|
+
const mantineTheme = core.useMantineTheme();
|
|
5344
|
+
const color = mantineTheme.colors[mantineTheme.primaryColor][5];
|
|
5345
|
+
const raw = useFormField(schemaKey);
|
|
5346
|
+
const value = {
|
|
5347
|
+
useOverride: raw?.useOverride ?? DEFAULT_VALUE.useOverride,
|
|
5348
|
+
primaryColor: raw?.primaryColor ?? DEFAULT_VALUE.primaryColor,
|
|
5349
|
+
primaryShade: raw?.primaryShade ?? DEFAULT_VALUE.primaryShade,
|
|
5350
|
+
customTheme: Array.isArray(raw?.customTheme) && raw.customTheme.length === 10 ? raw.customTheme : DEFAULT_VALUE.customTheme
|
|
5351
|
+
};
|
|
5352
|
+
const { setValue } = useFormActions();
|
|
5353
|
+
const set = (key, val) => setValue(schemaKey, { ...value, [key]: val });
|
|
5354
|
+
const useCustom = value.primaryColor === "custom";
|
|
5355
|
+
const editable = value.useOverride;
|
|
5356
|
+
const setSwatch = (index, hex) => {
|
|
5357
|
+
const next = [...value.customTheme];
|
|
5358
|
+
next[index] = hex;
|
|
5359
|
+
set("customTheme", next);
|
|
5360
|
+
};
|
|
5361
|
+
const generateFromBase = (hex) => {
|
|
5362
|
+
try {
|
|
5363
|
+
const generated = colorsGenerator.generateColors(hex);
|
|
5364
|
+
set("customTheme", generated);
|
|
5365
|
+
} catch {
|
|
5366
|
+
}
|
|
5367
|
+
};
|
|
5368
|
+
const resetPalette = () => set("customTheme", DEFAULT_PALETTE);
|
|
5369
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
5370
|
+
core.Flex,
|
|
5371
|
+
{
|
|
5372
|
+
direction: "column",
|
|
5373
|
+
gap: "xs",
|
|
5374
|
+
p: "sm",
|
|
5375
|
+
style: { flex: 1, minHeight: 0, overflowY: "auto" },
|
|
5376
|
+
children: [
|
|
5377
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5378
|
+
AdminPageTitle,
|
|
5379
|
+
{
|
|
5380
|
+
icon: lucideReact.Palette,
|
|
5381
|
+
title: title || locale("Theme") || "Theme",
|
|
5382
|
+
color
|
|
5383
|
+
}
|
|
5384
|
+
),
|
|
5385
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5386
|
+
core.Flex,
|
|
5387
|
+
{
|
|
5388
|
+
align: "center",
|
|
5389
|
+
justify: "space-between",
|
|
5390
|
+
p: "xs",
|
|
5391
|
+
style: {
|
|
5392
|
+
background: `rgba(255,255,255,${editable ? 0.04 : 0.02})`,
|
|
5393
|
+
border: `0.1vh solid ${editable ? color : "rgba(255,255,255,0.08)"}`,
|
|
5394
|
+
borderRadius: mantineTheme.radius.xs,
|
|
5395
|
+
transition: "background 0.15s, border-color 0.15s"
|
|
5396
|
+
},
|
|
5397
|
+
children: [
|
|
5398
|
+
/* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { direction: "column", gap: "xxs", style: { flex: 1, minWidth: 0 }, children: [
|
|
5399
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xs", c: "rgba(255,255,255,0.9)", children: locale("OverrideGlobalTheme") || "Override global theme" }),
|
|
5400
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Text, { ff: "Akrobat Bold", size: "xxs", c: "rgba(255,255,255,0.4)", children: locale("OverrideGlobalThemeDesc") || "When on, this resource uses its own primary colour and palette instead of dirk_lib's. Turn off to fall back to the global theme \u2014 your custom palette is kept." })
|
|
5401
|
+
] }),
|
|
5402
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5403
|
+
core.Switch,
|
|
5404
|
+
{
|
|
5405
|
+
size: "md",
|
|
5406
|
+
checked: value.useOverride,
|
|
5407
|
+
onChange: (e) => set("useOverride", e.currentTarget.checked)
|
|
5408
|
+
}
|
|
5409
|
+
)
|
|
5410
|
+
]
|
|
5411
|
+
}
|
|
5412
|
+
),
|
|
5413
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
5414
|
+
"div",
|
|
5415
|
+
{
|
|
5416
|
+
style: {
|
|
5417
|
+
opacity: editable ? 1 : 0.4,
|
|
5418
|
+
pointerEvents: editable ? "auto" : "none",
|
|
5419
|
+
transition: "opacity 0.15s"
|
|
5420
|
+
},
|
|
5421
|
+
children: [
|
|
5422
|
+
/* @__PURE__ */ jsxRuntime.jsx(GroupLabel, { label: locale("PrimaryColor") || "Primary Colour" }),
|
|
5423
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5424
|
+
core.Switch,
|
|
5425
|
+
{
|
|
5426
|
+
label: locale("UseCustomPalette") || "Use custom palette",
|
|
5427
|
+
size: "md",
|
|
5428
|
+
mt: "xs",
|
|
5429
|
+
checked: useCustom,
|
|
5430
|
+
onChange: (e) => set("primaryColor", e.currentTarget.checked ? "custom" : "dirk"),
|
|
5431
|
+
styles: {
|
|
5432
|
+
label: {
|
|
5433
|
+
fontFamily: "Akrobat Bold",
|
|
5434
|
+
fontSize: "0.65em",
|
|
5435
|
+
letterSpacing: "0.06em",
|
|
5436
|
+
textTransform: "uppercase",
|
|
5437
|
+
color: "rgba(255,255,255,0.35)"
|
|
5438
|
+
}
|
|
5439
|
+
}
|
|
5440
|
+
}
|
|
5441
|
+
),
|
|
5442
|
+
/* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { gap: "xs", mt: "xs", children: [
|
|
5443
|
+
!useCustom && /* @__PURE__ */ jsxRuntime.jsx(
|
|
5444
|
+
core.Select,
|
|
5445
|
+
{
|
|
5446
|
+
label: locale("MantinePalette") || "Mantine palette",
|
|
5447
|
+
size: "xs",
|
|
5448
|
+
style: { flex: 1 },
|
|
5449
|
+
value: value.primaryColor,
|
|
5450
|
+
data: MANTINE_COLOR_OPTIONS,
|
|
5451
|
+
allowDeselect: false,
|
|
5452
|
+
onChange: (v) => v && set("primaryColor", v)
|
|
5453
|
+
}
|
|
5454
|
+
),
|
|
5455
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5456
|
+
core.NumberInput,
|
|
5457
|
+
{
|
|
5458
|
+
label: locale("Shade") || "Shade",
|
|
5459
|
+
size: "xs",
|
|
5460
|
+
style: { flex: 1 },
|
|
5461
|
+
min: 0,
|
|
5462
|
+
max: 9,
|
|
5463
|
+
value: value.primaryShade,
|
|
5464
|
+
onChange: (v) => set("primaryShade", Number(v))
|
|
5465
|
+
}
|
|
5466
|
+
)
|
|
5467
|
+
] }),
|
|
5468
|
+
useCustom && /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
5469
|
+
/* @__PURE__ */ jsxRuntime.jsxs(core.Flex, { align: "center", justify: "space-between", mt: "sm", children: [
|
|
5470
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5471
|
+
core.Text,
|
|
5472
|
+
{
|
|
5473
|
+
ff: "Akrobat Bold",
|
|
5474
|
+
size: "xxs",
|
|
5475
|
+
tt: "uppercase",
|
|
5476
|
+
lts: "0.07em",
|
|
5477
|
+
c: "rgba(255,255,255,0.2)",
|
|
5478
|
+
children: locale("CustomPalette") || "Custom palette"
|
|
5479
|
+
}
|
|
5480
|
+
),
|
|
5481
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5482
|
+
core.ActionIcon,
|
|
5483
|
+
{
|
|
5484
|
+
size: "sm",
|
|
5485
|
+
variant: "subtle",
|
|
5486
|
+
onClick: resetPalette,
|
|
5487
|
+
title: locale("ResetPalette") || "Reset palette",
|
|
5488
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(lucideReact.RotateCcw, { size: "1.4vh" })
|
|
5489
|
+
}
|
|
5490
|
+
)
|
|
5491
|
+
] }),
|
|
5492
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
5493
|
+
core.ColorInput,
|
|
5494
|
+
{
|
|
5495
|
+
label: locale("BaseColor") || "Base colour",
|
|
5496
|
+
size: "xs",
|
|
5497
|
+
value: value.customTheme[value.primaryShade] ?? value.customTheme[5] ?? "#000000",
|
|
5498
|
+
onChange: generateFromBase,
|
|
5499
|
+
eyeDropperIcon: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
|
|
5500
|
+
}
|
|
5501
|
+
),
|
|
5502
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Flex, { gap: "xxs", mt: "xxs", children: value.customTheme.map((swatch, i) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
5503
|
+
SwatchTile,
|
|
5504
|
+
{
|
|
5505
|
+
index: i,
|
|
5506
|
+
value: swatch,
|
|
5507
|
+
isPrimary: i === value.primaryShade,
|
|
5508
|
+
onChange: (v) => setSwatch(i, v)
|
|
5509
|
+
},
|
|
5510
|
+
i
|
|
5511
|
+
)) })
|
|
5512
|
+
] })
|
|
5513
|
+
]
|
|
5514
|
+
}
|
|
5515
|
+
)
|
|
5516
|
+
]
|
|
5517
|
+
}
|
|
5518
|
+
);
|
|
5519
|
+
}
|
|
5520
|
+
function SwatchTile({
|
|
5521
|
+
index,
|
|
5522
|
+
value,
|
|
5523
|
+
isPrimary,
|
|
5524
|
+
onChange
|
|
5525
|
+
}) {
|
|
5526
|
+
const [opened, setOpened] = react.useState(false);
|
|
5527
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(core.Popover, { opened, onChange: setOpened, position: "bottom", withArrow: true, zIndex: 1e4, children: [
|
|
5528
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Popover.Target, { children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5529
|
+
"button",
|
|
5530
|
+
{
|
|
5531
|
+
onClick: () => setOpened((o) => !o),
|
|
5532
|
+
title: `${index} \xB7 ${value}`,
|
|
5533
|
+
style: {
|
|
5534
|
+
flex: 1,
|
|
5535
|
+
aspectRatio: "1 / 1",
|
|
5536
|
+
background: value,
|
|
5537
|
+
border: isPrimary ? "0.2vh solid rgba(255,255,255,0.85)" : "0.1vh solid rgba(255,255,255,0.15)",
|
|
5538
|
+
borderRadius: "0.4vh",
|
|
5539
|
+
cursor: "pointer",
|
|
5540
|
+
padding: 0,
|
|
5541
|
+
display: "flex",
|
|
5542
|
+
alignItems: "flex-end",
|
|
5543
|
+
justifyContent: "flex-end",
|
|
5544
|
+
position: "relative"
|
|
5545
|
+
},
|
|
5546
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5547
|
+
"span",
|
|
5548
|
+
{
|
|
5549
|
+
style: {
|
|
5550
|
+
fontFamily: "Akrobat Bold",
|
|
5551
|
+
fontSize: "0.9vh",
|
|
5552
|
+
lineHeight: 1,
|
|
5553
|
+
padding: "0.2vh 0.3vh",
|
|
5554
|
+
color: "rgba(0,0,0,0.55)",
|
|
5555
|
+
background: "rgba(255,255,255,0.55)",
|
|
5556
|
+
borderRadius: "0.25vh",
|
|
5557
|
+
margin: "0.2vh"
|
|
5558
|
+
},
|
|
5559
|
+
children: index
|
|
5560
|
+
}
|
|
5561
|
+
)
|
|
5562
|
+
}
|
|
5563
|
+
) }),
|
|
5564
|
+
/* @__PURE__ */ jsxRuntime.jsx(core.Popover.Dropdown, { p: "xs", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
5565
|
+
core.ColorInput,
|
|
5566
|
+
{
|
|
5567
|
+
size: "xs",
|
|
5568
|
+
value,
|
|
5569
|
+
onChange,
|
|
5570
|
+
format: "hex",
|
|
5571
|
+
eyeDropperIcon: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, {})
|
|
5572
|
+
}
|
|
5573
|
+
) })
|
|
5574
|
+
] });
|
|
5575
|
+
}
|
|
5277
5576
|
|
|
5278
5577
|
exports.AdminPageTitle = AdminPageTitle;
|
|
5279
5578
|
exports.AsyncSaveButton = AsyncSaveButton;
|
|
@@ -5312,6 +5611,7 @@ exports.SegmentedControl = SegmentedControl;
|
|
|
5312
5611
|
exports.SegmentedProgress = SegmentedProgress;
|
|
5313
5612
|
exports.SelectItem = SelectItem;
|
|
5314
5613
|
exports.TestBed = TestBed;
|
|
5614
|
+
exports.ThemeOverrideSection = ThemeOverrideSection;
|
|
5315
5615
|
exports.Title = Title;
|
|
5316
5616
|
exports.Vector4DeleteButton = Vector4DeleteButton;
|
|
5317
5617
|
exports.Vector4Display = Vector4Display;
|