@trops/dash-core 0.1.180 → 0.1.181
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.esm.js +58 -51
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +58 -51
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -33223,8 +33223,21 @@ var ThemeQuickCreate = function ThemeQuickCreate(_ref8) {
|
|
|
33223
33223
|
_ref8$onExtract = _ref8.onExtract,
|
|
33224
33224
|
onExtract = _ref8$onExtract === void 0 ? null : _ref8$onExtract,
|
|
33225
33225
|
_ref8$onMapToTheme = _ref8.onMapToTheme,
|
|
33226
|
-
onMapToTheme = _ref8$onMapToTheme === void 0 ? null : _ref8$onMapToTheme
|
|
33226
|
+
onMapToTheme = _ref8$onMapToTheme === void 0 ? null : _ref8$onMapToTheme,
|
|
33227
|
+
_ref8$initialMethod = _ref8.initialMethod,
|
|
33228
|
+
initialMethod = _ref8$initialMethod === void 0 ? null : _ref8$initialMethod;
|
|
33227
33229
|
var canCreate = wizardName.trim().length > 0 && wizardTheme !== null;
|
|
33230
|
+
var showMethodPicker = initialMethod === null;
|
|
33231
|
+
useEffect(function () {
|
|
33232
|
+
if (initialMethod && wizardMethod !== initialMethod) {
|
|
33233
|
+
setWizardMethod(initialMethod);
|
|
33234
|
+
setWizardTheme(null);
|
|
33235
|
+
if (initialMethod === "random") {
|
|
33236
|
+
setWizardTheme(generateRandomTheme());
|
|
33237
|
+
}
|
|
33238
|
+
}
|
|
33239
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
33240
|
+
}, [initialMethod]);
|
|
33228
33241
|
function handleMethodSelect(method) {
|
|
33229
33242
|
setWizardMethod(method);
|
|
33230
33243
|
setWizardTheme(null);
|
|
@@ -33246,7 +33259,7 @@ var ThemeQuickCreate = function ThemeQuickCreate(_ref8) {
|
|
|
33246
33259
|
},
|
|
33247
33260
|
placeholder: "Theme name..."
|
|
33248
33261
|
})]
|
|
33249
|
-
}), /*#__PURE__*/jsxs("div", {
|
|
33262
|
+
}), showMethodPicker && /*#__PURE__*/jsxs("div", {
|
|
33250
33263
|
className: "flex flex-col gap-2",
|
|
33251
33264
|
children: [/*#__PURE__*/jsx("span", {
|
|
33252
33265
|
className: "text-sm font-semibold opacity-50",
|
|
@@ -33344,9 +33357,7 @@ var ChooserCard = function ChooserCard(_ref) {
|
|
|
33344
33357
|
};
|
|
33345
33358
|
var ThemeNewChooser = function ThemeNewChooser(_ref2) {
|
|
33346
33359
|
var onSearchThemes = _ref2.onSearchThemes,
|
|
33347
|
-
|
|
33348
|
-
_ref2$onCreateFromUrl = _ref2.onCreateFromUrl,
|
|
33349
|
-
onCreateFromUrl = _ref2$onCreateFromUrl === void 0 ? null : _ref2$onCreateFromUrl;
|
|
33360
|
+
onSelectMethod = _ref2.onSelectMethod;
|
|
33350
33361
|
return /*#__PURE__*/jsxs("div", {
|
|
33351
33362
|
className: "flex flex-col gap-6 p-6 overflow-y-auto flex-1 min-h-0",
|
|
33352
33363
|
children: [/*#__PURE__*/jsx("span", {
|
|
@@ -33356,19 +33367,37 @@ var ThemeNewChooser = function ThemeNewChooser(_ref2) {
|
|
|
33356
33367
|
className: "grid grid-cols-2 gap-3",
|
|
33357
33368
|
children: [/*#__PURE__*/jsx(ChooserCard, {
|
|
33358
33369
|
icon: "magnifying-glass",
|
|
33359
|
-
title: "Search
|
|
33360
|
-
subtitle: "Browse
|
|
33370
|
+
title: "Search Marketplace",
|
|
33371
|
+
subtitle: "Browse community themes",
|
|
33361
33372
|
onClick: onSearchThemes
|
|
33362
33373
|
}), /*#__PURE__*/jsx(ChooserCard, {
|
|
33363
|
-
icon: "
|
|
33364
|
-
title: "
|
|
33365
|
-
subtitle: "
|
|
33366
|
-
onClick:
|
|
33367
|
-
|
|
33374
|
+
icon: "swatchbook",
|
|
33375
|
+
title: "From Presets",
|
|
33376
|
+
subtitle: "Start from a curated preset",
|
|
33377
|
+
onClick: function onClick() {
|
|
33378
|
+
return onSelectMethod("presets");
|
|
33379
|
+
}
|
|
33380
|
+
}), /*#__PURE__*/jsx(ChooserCard, {
|
|
33381
|
+
icon: "droplet",
|
|
33382
|
+
title: "From Colors",
|
|
33383
|
+
subtitle: "Build from a color palette",
|
|
33384
|
+
onClick: function onClick() {
|
|
33385
|
+
return onSelectMethod("color");
|
|
33386
|
+
}
|
|
33387
|
+
}), /*#__PURE__*/jsx(ChooserCard, {
|
|
33388
|
+
icon: "shuffle",
|
|
33389
|
+
title: "From Random",
|
|
33390
|
+
subtitle: "Generate a random theme",
|
|
33391
|
+
onClick: function onClick() {
|
|
33392
|
+
return onSelectMethod("random");
|
|
33393
|
+
}
|
|
33394
|
+
}), /*#__PURE__*/jsx(ChooserCard, {
|
|
33368
33395
|
icon: "globe",
|
|
33369
33396
|
title: "From Website",
|
|
33370
|
-
subtitle: "Extract colors from any URL
|
|
33371
|
-
onClick:
|
|
33397
|
+
subtitle: "Extract colors from any URL",
|
|
33398
|
+
onClick: function onClick() {
|
|
33399
|
+
return onSelectMethod("from-url");
|
|
33400
|
+
}
|
|
33372
33401
|
})]
|
|
33373
33402
|
})]
|
|
33374
33403
|
});
|
|
@@ -34056,10 +34085,10 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34056
34085
|
_useState12 = _slicedToArray(_useState11, 2),
|
|
34057
34086
|
isSearching = _useState12[0],
|
|
34058
34087
|
setIsSearching = _useState12[1];
|
|
34059
|
-
var _useState13 = useState(
|
|
34088
|
+
var _useState13 = useState(null),
|
|
34060
34089
|
_useState14 = _slicedToArray(_useState13, 2),
|
|
34061
|
-
|
|
34062
|
-
|
|
34090
|
+
selectedMethod = _useState14[0],
|
|
34091
|
+
setSelectedMethod = _useState14[1];
|
|
34063
34092
|
var _useState15 = useState(""),
|
|
34064
34093
|
_useState16 = _slicedToArray(_useState15, 2),
|
|
34065
34094
|
wizardName = _useState16[0],
|
|
@@ -34087,7 +34116,7 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34087
34116
|
setIsCreating(false);
|
|
34088
34117
|
setIsChoosingMode(false);
|
|
34089
34118
|
setIsSearching(false);
|
|
34090
|
-
|
|
34119
|
+
setSelectedMethod(null);
|
|
34091
34120
|
} else {
|
|
34092
34121
|
if (themeKeySelected === null && themes) {
|
|
34093
34122
|
var themeKeyTemp = settings && "theme" in settings ? settings["theme"] in themes ? settings["theme"] : Object.keys(themes)[0] : Object.keys(themes)[0];
|
|
@@ -34130,10 +34159,12 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34130
34159
|
setIsCreating(false);
|
|
34131
34160
|
setIsSearching(false);
|
|
34132
34161
|
setIsEditing(false);
|
|
34162
|
+
setSelectedMethod(null);
|
|
34133
34163
|
}
|
|
34134
|
-
function
|
|
34164
|
+
function handleSelectMethod(method) {
|
|
34135
34165
|
setIsChoosingMode(false);
|
|
34136
34166
|
setIsCreating(true);
|
|
34167
|
+
setSelectedMethod(method);
|
|
34137
34168
|
setWizardName("");
|
|
34138
34169
|
setWizardMethod(null);
|
|
34139
34170
|
setWizardTheme(null);
|
|
@@ -34142,10 +34173,6 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34142
34173
|
setIsChoosingMode(false);
|
|
34143
34174
|
setIsSearching(true);
|
|
34144
34175
|
}
|
|
34145
|
-
function handleChooseFromUrl() {
|
|
34146
|
-
setIsChoosingMode(false);
|
|
34147
|
-
setIsFromUrl(true);
|
|
34148
|
-
}
|
|
34149
34176
|
function handleBackFromSearch() {
|
|
34150
34177
|
setIsSearching(false);
|
|
34151
34178
|
setIsChoosingMode(true);
|
|
@@ -34204,24 +34231,6 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34204
34231
|
}));
|
|
34205
34232
|
return _handleUrlMapToTheme.apply(this, arguments);
|
|
34206
34233
|
}
|
|
34207
|
-
function handleUrlThemeGenerated(theme) {
|
|
34208
|
-
var key = theme.id || "theme-".concat(Date.now());
|
|
34209
|
-
var finalTheme = _objectSpread$c(_objectSpread$c({}, theme), {}, {
|
|
34210
|
-
id: key
|
|
34211
|
-
});
|
|
34212
|
-
if (dashApi) {
|
|
34213
|
-
dashApi.saveTheme(credentials.appId, key, finalTheme, function (e, message) {
|
|
34214
|
-
changeThemesForApplication(message["themes"]);
|
|
34215
|
-
setIsFromUrl(false);
|
|
34216
|
-
var newThemes = message["themes"];
|
|
34217
|
-
if (newThemes && newThemes[key]) {
|
|
34218
|
-
setThemeKeySelected(key);
|
|
34219
|
-
setThemeSelected(newThemes[key]);
|
|
34220
|
-
setRawThemeSelected(finalTheme);
|
|
34221
|
-
}
|
|
34222
|
-
}, handleSaveThemeError);
|
|
34223
|
-
}
|
|
34224
|
-
}
|
|
34225
34234
|
function handleWizardComplete() {
|
|
34226
34235
|
if (!wizardTheme || !wizardName.trim()) return;
|
|
34227
34236
|
var key = wizardTheme.id || "theme-".concat(Date.now());
|
|
@@ -34234,6 +34243,7 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34234
34243
|
changeThemesForApplication(message["themes"]);
|
|
34235
34244
|
setIsCreating(false);
|
|
34236
34245
|
setIsEditing(false);
|
|
34246
|
+
setSelectedMethod(null);
|
|
34237
34247
|
var newThemes = message["themes"];
|
|
34238
34248
|
if (newThemes && newThemes[key]) {
|
|
34239
34249
|
setThemeKeySelected(key);
|
|
@@ -34247,7 +34257,7 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34247
34257
|
setIsCreating(false);
|
|
34248
34258
|
setIsChoosingMode(false);
|
|
34249
34259
|
setIsSearching(false);
|
|
34250
|
-
|
|
34260
|
+
setSelectedMethod(null);
|
|
34251
34261
|
}
|
|
34252
34262
|
function handleSaveTheme() {
|
|
34253
34263
|
if (themeKeySelected !== null && rawThemeSelected !== null) {
|
|
@@ -34302,6 +34312,7 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34302
34312
|
setThemeSelected(null);
|
|
34303
34313
|
setIsEditing(false);
|
|
34304
34314
|
}
|
|
34315
|
+
var isInWizardFlow = isCreating || isChoosingMode || isSearching;
|
|
34305
34316
|
return /*#__PURE__*/jsx(Modal, {
|
|
34306
34317
|
isOpen: open,
|
|
34307
34318
|
setIsOpen: setIsOpen,
|
|
@@ -34326,8 +34337,7 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34326
34337
|
rawTheme: rawThemeSelected,
|
|
34327
34338
|
wizardContent: isChoosingMode ? /*#__PURE__*/jsx(ThemeNewChooser, {
|
|
34328
34339
|
onSearchThemes: handleChooseSearch,
|
|
34329
|
-
|
|
34330
|
-
onCreateFromUrl: handleChooseFromUrl
|
|
34340
|
+
onSelectMethod: handleSelectMethod
|
|
34331
34341
|
}) : isSearching ? /*#__PURE__*/jsx(DiscoverThemesDetail, {
|
|
34332
34342
|
onBack: handleBackFromSearch,
|
|
34333
34343
|
appId: credentials === null || credentials === void 0 ? void 0 : credentials.appId,
|
|
@@ -34348,12 +34358,9 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34348
34358
|
wizardTheme: wizardTheme,
|
|
34349
34359
|
setWizardTheme: setWizardTheme,
|
|
34350
34360
|
onComplete: handleWizardComplete,
|
|
34351
|
-
onExtract: handleUrlExtract,
|
|
34352
|
-
onMapToTheme: handleUrlMapToTheme
|
|
34353
|
-
}) : isFromUrl ? /*#__PURE__*/jsx(ThemeFromUrlPane, {
|
|
34354
34361
|
onExtract: handleUrlExtract,
|
|
34355
34362
|
onMapToTheme: handleUrlMapToTheme,
|
|
34356
|
-
|
|
34363
|
+
initialMethod: selectedMethod
|
|
34357
34364
|
}) : null
|
|
34358
34365
|
}), !isCreating && themeSelected && isEditing === true && /*#__PURE__*/jsx(PanelTheme, {
|
|
34359
34366
|
theme: themeSelected,
|
|
@@ -34374,13 +34381,13 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34374
34381
|
children: themeKeySelected
|
|
34375
34382
|
})]
|
|
34376
34383
|
})
|
|
34377
|
-
}),
|
|
34384
|
+
}), isInWizardFlow && /*#__PURE__*/jsx("div", {
|
|
34378
34385
|
className: "flex flex-row space-x-2",
|
|
34379
34386
|
children: /*#__PURE__*/jsx(Button, {
|
|
34380
34387
|
onClick: handleCancelCreate,
|
|
34381
34388
|
title: "Cancel"
|
|
34382
34389
|
})
|
|
34383
|
-
}), !
|
|
34390
|
+
}), !isInWizardFlow && isEditing === false && /*#__PURE__*/jsxs("div", {
|
|
34384
34391
|
className: "flex flex-row space-x-2",
|
|
34385
34392
|
children: [/*#__PURE__*/jsx(Button, {
|
|
34386
34393
|
onClick: function onClick() {
|
|
@@ -34399,7 +34406,7 @@ var ThemeManagerModal = function ThemeManagerModal(_ref) {
|
|
|
34399
34406
|
onClick: handleActivateTheme,
|
|
34400
34407
|
title: "Activate"
|
|
34401
34408
|
})]
|
|
34402
|
-
}), !
|
|
34409
|
+
}), !isInWizardFlow && isEditing === true && /*#__PURE__*/jsxs("div", {
|
|
34403
34410
|
className: "flex flex-row space-x-2",
|
|
34404
34411
|
children: [/*#__PURE__*/jsx(Button, {
|
|
34405
34412
|
onClick: function onClick() {
|