labellife-design-tool 2.5.0 → 2.5.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/dist/cjs/canvas/workspace.js.map +1 -1
- package/dist/cjs/config.js +18 -0
- package/dist/cjs/config.js.map +1 -1
- package/dist/cjs/index.js +88 -10
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/side-panel/index.js +88 -10
- package/dist/cjs/side-panel/index.js.map +1 -1
- package/dist/cjs/side-panel/side-panel.js +88 -10
- package/dist/cjs/side-panel/side-panel.js.map +1 -1
- package/dist/cjs/toolbar/toolbar.js.map +1 -1
- package/dist/esm/canvas/workspace.js.map +1 -1
- package/dist/esm/config.js +17 -1
- package/dist/esm/config.js.map +1 -1
- package/dist/esm/index.js +88 -10
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/side-panel/index.js +88 -10
- package/dist/esm/side-panel/index.js.map +1 -1
- package/dist/esm/side-panel/side-panel.js +88 -10
- package/dist/esm/side-panel/side-panel.js.map +1 -1
- package/dist/esm/toolbar/toolbar.js.map +1 -1
- package/package.json +2 -2
|
@@ -417,6 +417,17 @@ function t(key, defaultValue) {
|
|
|
417
417
|
return defaultValue || key;
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
+
// ── Backend API base URL (used by background-panel.js's Unsplash proxy calls) ─
|
|
421
|
+
// Window-level singleton, same reasoning as translations/input-fields config above:
|
|
422
|
+
// each Rollup output bundle (index, side-panel, toolbar, canvas...) gets its own copy
|
|
423
|
+
// of this module, so a plain closure variable set from one bundle (e.g. via the host
|
|
424
|
+
// app's top-level `labellife-design-tool/config` import) would never be seen by another
|
|
425
|
+
// bundle (e.g. background-panel.js, built into the side-panel bundle).
|
|
426
|
+
var API_BASE_URL_KEY = '__labellife_api_base_url__';
|
|
427
|
+
function getApiBaseUrl() {
|
|
428
|
+
return typeof window !== 'undefined' && window[API_BASE_URL_KEY] || '';
|
|
429
|
+
}
|
|
430
|
+
|
|
420
431
|
// ── Input Fields Dialog Config ───────────────────────────────────────
|
|
421
432
|
var INPUT_FIELDS_CONFIG_KEY = '__labellife_input_fields_config__';
|
|
422
433
|
if (typeof window !== 'undefined' && !window[INPUT_FIELDS_CONFIG_KEY]) {
|
|
@@ -1001,6 +1012,33 @@ var TextSection = {
|
|
|
1001
1012
|
Panel: TextPanelContent
|
|
1002
1013
|
};
|
|
1003
1014
|
|
|
1015
|
+
// src/side-panel/unsplash-api.js
|
|
1016
|
+
//
|
|
1017
|
+
// Pure, framework-free URL helpers for the Unsplash background search, proxied through the
|
|
1018
|
+
// labellife backend (see labellifeBackendRepo's UnsplashBackgroundSearchView /
|
|
1019
|
+
// UnsplashTrackDownloadView). Deliberately has no internal imports so it can be unit-tested
|
|
1020
|
+
// with plain `node`, following the same convention as ./fonts.js.
|
|
1021
|
+
|
|
1022
|
+
var UNSPLASH_UTM_SOURCE = 'labellife';
|
|
1023
|
+
function buildUnsplashSearchUrl(apiBaseUrl, query) {
|
|
1024
|
+
var page = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
1025
|
+
var perPage = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 20;
|
|
1026
|
+
var trimmed = query && String(query).trim();
|
|
1027
|
+
var q = trimmed || 'gradient';
|
|
1028
|
+
return "".concat(apiBaseUrl, "/api/polotno/unsplash/search/?query=").concat(encodeURIComponent(q), "&per_page=").concat(perPage, "&page=").concat(page);
|
|
1029
|
+
}
|
|
1030
|
+
function buildUnsplashTrackDownloadUrl(apiBaseUrl) {
|
|
1031
|
+
return "".concat(apiBaseUrl, "/api/polotno/unsplash/track-download/");
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
// Unsplash API Guidelines require attribution links back to unsplash.com and to the
|
|
1035
|
+
// photographer's profile to carry UTM params identifying this app.
|
|
1036
|
+
function withUnsplashAttribution(url) {
|
|
1037
|
+
if (!url) return url;
|
|
1038
|
+
var separator = url.includes('?') ? '&' : '?';
|
|
1039
|
+
return "".concat(url).concat(separator, "utm_source=").concat(encodeURIComponent(UNSPLASH_UTM_SOURCE), "&utm_medium=referral");
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1004
1042
|
function hsvToRgb(h, s, v) {
|
|
1005
1043
|
var i = Math.floor(h / 60) % 6;
|
|
1006
1044
|
var f = h / 60 - Math.floor(h / 60);
|
|
@@ -1076,8 +1114,6 @@ function hueToColor(h) {
|
|
|
1076
1114
|
|
|
1077
1115
|
// ─── Constants ───────────────────────────────────────────────────────
|
|
1078
1116
|
|
|
1079
|
-
var UNSPLASH_KEY = 'zwiE802FyRjTmLhZjXqW';
|
|
1080
|
-
var UNSPLASH_BASE = 'https://api.polotno.com/api/get-unsplash';
|
|
1081
1117
|
var SWATCH_COLORS = ['#ffffff', '#1a237e', '#ff6d00', '#2e7d32', '#fdd835', '#9c27b0'];
|
|
1082
1118
|
var PICKER_PRESETS = ['#f44336', '#ff9800', '#ffeb3b', '#4caf50', '#2196f3', '#9c27b0', '#00bcd4', '#8bc34a', '#cddc39', '#000000', '#607d8b', '#ffffff'];
|
|
1083
1119
|
var CHECKER_SVG = "data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16'%3E%3Crect width='8' height='8' fill='%23ccc'/%3E%3Crect x='8' y='8' width='8' height='8' fill='%23ccc'/%3E%3Crect x='8' width='8' height='8' fill='%23fff'/%3E%3Crect y='8' width='8' height='8' fill='%23fff'/%3E%3C/svg%3E";
|
|
@@ -1675,7 +1711,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1675
1711
|
_context.p = 2;
|
|
1676
1712
|
q = query || 'gradient';
|
|
1677
1713
|
_context.n = 3;
|
|
1678
|
-
return fetch(
|
|
1714
|
+
return fetch(buildUnsplashSearchUrl(getApiBaseUrl(), q, pg, 20));
|
|
1679
1715
|
case 3:
|
|
1680
1716
|
res = _context.v;
|
|
1681
1717
|
_context.n = 4;
|
|
@@ -1907,7 +1943,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1907
1943
|
color: '#888'
|
|
1908
1944
|
},
|
|
1909
1945
|
children: ["Photos by", ' ', /*#__PURE__*/jsx("a", {
|
|
1910
|
-
href:
|
|
1946
|
+
href: withUnsplashAttribution('https://unsplash.com'),
|
|
1911
1947
|
target: "_blank",
|
|
1912
1948
|
rel: "noopener noreferrer",
|
|
1913
1949
|
style: {
|
|
@@ -1923,16 +1959,33 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1923
1959
|
gap: 1
|
|
1924
1960
|
},
|
|
1925
1961
|
children: photos.map(function (photo, idx) {
|
|
1926
|
-
var _photo$urls, _photo$urls2;
|
|
1962
|
+
var _photo$urls, _photo$urls2, _photo$user, _photo$user2;
|
|
1927
1963
|
var thumb = ((_photo$urls = photo.urls) === null || _photo$urls === void 0 ? void 0 : _photo$urls.small) || ((_photo$urls2 = photo.urls) === null || _photo$urls2 === void 0 ? void 0 : _photo$urls2.thumb) || photo.src;
|
|
1928
1964
|
if (!thumb) return null;
|
|
1929
|
-
|
|
1965
|
+
var photographerName = (_photo$user = photo.user) === null || _photo$user === void 0 ? void 0 : _photo$user.name;
|
|
1966
|
+
var photographerUrl = ((_photo$user2 = photo.user) === null || _photo$user2 === void 0 || (_photo$user2 = _photo$user2.links) === null || _photo$user2 === void 0 ? void 0 : _photo$user2.html) && withUnsplashAttribution(photo.user.links.html);
|
|
1967
|
+
return /*#__PURE__*/jsxs(Box, {
|
|
1930
1968
|
onClick: function onClick() {
|
|
1931
|
-
var _photo$urls3, _photo$urls4;
|
|
1969
|
+
var _photo$urls3, _photo$urls4, _photo$links;
|
|
1932
1970
|
var url = ((_photo$urls3 = photo.urls) === null || _photo$urls3 === void 0 ? void 0 : _photo$urls3.regular) || ((_photo$urls4 = photo.urls) === null || _photo$urls4 === void 0 ? void 0 : _photo$urls4.small) || photo.src;
|
|
1933
|
-
if (url)
|
|
1971
|
+
if (!url) return;
|
|
1972
|
+
setBackground(url);
|
|
1973
|
+
// Unsplash API Guidelines require registering a "download" whenever a photo is used.
|
|
1974
|
+
// Best-effort: don't block or fail background-setting if this ping fails.
|
|
1975
|
+
if ((_photo$links = photo.links) !== null && _photo$links !== void 0 && _photo$links.download_location) {
|
|
1976
|
+
fetch(buildUnsplashTrackDownloadUrl(getApiBaseUrl()), {
|
|
1977
|
+
method: 'POST',
|
|
1978
|
+
headers: {
|
|
1979
|
+
'Content-Type': 'application/json'
|
|
1980
|
+
},
|
|
1981
|
+
body: JSON.stringify({
|
|
1982
|
+
download_location: photo.links.download_location
|
|
1983
|
+
})
|
|
1984
|
+
})["catch"](function () {});
|
|
1985
|
+
}
|
|
1934
1986
|
},
|
|
1935
1987
|
sx: {
|
|
1988
|
+
position: 'relative',
|
|
1936
1989
|
cursor: 'pointer',
|
|
1937
1990
|
borderRadius: '8px',
|
|
1938
1991
|
overflow: 'hidden',
|
|
@@ -1942,7 +1995,7 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1942
1995
|
},
|
|
1943
1996
|
transition: 'opacity 0.15s'
|
|
1944
1997
|
},
|
|
1945
|
-
children: /*#__PURE__*/jsx("img", {
|
|
1998
|
+
children: [/*#__PURE__*/jsx("img", {
|
|
1946
1999
|
src: thumb,
|
|
1947
2000
|
alt: photo.alt_description || 'Background',
|
|
1948
2001
|
style: {
|
|
@@ -1952,7 +2005,32 @@ var BackgroundPanelContent = observer(function (_ref5) {
|
|
|
1952
2005
|
display: 'block'
|
|
1953
2006
|
},
|
|
1954
2007
|
loading: "lazy"
|
|
1955
|
-
})
|
|
2008
|
+
}), photographerName && /*#__PURE__*/jsx(Typography, {
|
|
2009
|
+
variant: "caption",
|
|
2010
|
+
component: "a",
|
|
2011
|
+
href: photographerUrl || undefined,
|
|
2012
|
+
target: "_blank",
|
|
2013
|
+
rel: "noopener noreferrer",
|
|
2014
|
+
onClick: function onClick(e) {
|
|
2015
|
+
return e.stopPropagation();
|
|
2016
|
+
},
|
|
2017
|
+
sx: {
|
|
2018
|
+
position: 'absolute',
|
|
2019
|
+
left: 0,
|
|
2020
|
+
right: 0,
|
|
2021
|
+
bottom: 0,
|
|
2022
|
+
px: 0.75,
|
|
2023
|
+
py: 0.25,
|
|
2024
|
+
fontSize: 10,
|
|
2025
|
+
color: '#fff',
|
|
2026
|
+
textDecoration: 'none',
|
|
2027
|
+
background: 'linear-gradient(to top, rgba(0,0,0,0.55), transparent)',
|
|
2028
|
+
whiteSpace: 'nowrap',
|
|
2029
|
+
overflow: 'hidden',
|
|
2030
|
+
textOverflow: 'ellipsis'
|
|
2031
|
+
},
|
|
2032
|
+
children: photographerName
|
|
2033
|
+
})]
|
|
1956
2034
|
}, photo.id || idx);
|
|
1957
2035
|
})
|
|
1958
2036
|
}), hasMore && /*#__PURE__*/jsx(Box, {
|