@leaflink/stash 44.0.0-beta.7 → 44.0.0-beta.9
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/README.md +107 -39
- package/dist/ActionsDropdown.js +2 -2
- package/dist/ActionsDropdown.js.map +1 -1
- package/dist/AddressSelect.js +2 -2
- package/dist/AppNavigationItem.js +1 -1
- package/dist/AppSidebar.js +13 -13
- package/dist/AppSidebar.js.map +1 -1
- package/dist/Badge.vue.d.ts +1 -1
- package/dist/Button.js +1 -1
- package/dist/Button.js.map +1 -1
- package/dist/Button.vue_used_vue_type_style_index_0_lang.module-63d31dc0.js +17 -0
- package/dist/Button.vue_used_vue_type_style_index_0_lang.module-63d31dc0.js.map +1 -0
- package/dist/ButtonGroup.js +19 -19
- package/dist/ButtonGroup.js.map +1 -1
- package/dist/Checkbox.js +57 -46
- package/dist/Checkbox.js.map +1 -1
- package/dist/Checkbox.vue.d.ts +2 -0
- package/dist/Checkbox.vue_used_vue_type_style_index_0_lang.module-fa8d9c06.js +9 -0
- package/dist/Checkbox.vue_used_vue_type_style_index_0_lang.module-fa8d9c06.js.map +1 -0
- package/dist/ChevronToggle.js +1 -1
- package/dist/Copy.js +1 -1
- package/dist/CurrencyInput.js +2 -2
- package/dist/DataView.js +1 -1
- package/dist/DataViewFilters.js +4 -4
- package/dist/DataViewSortButton.js +47 -38
- package/dist/DataViewSortButton.js.map +1 -1
- package/dist/DataViewToolbar.js +2 -2
- package/dist/DatePicker.js +8 -8
- package/dist/DatePicker.js.map +1 -1
- package/dist/DescriptionListTerm.js +1 -1
- package/dist/DescriptionListTerm.js.map +1 -1
- package/dist/Dialog.js +33 -33
- package/dist/Dialog.js.map +1 -1
- package/dist/Divider.js +4 -4
- package/dist/Divider.js.map +1 -1
- package/dist/Expand.js +1 -1
- package/dist/{Expand.vue_vue_type_script_setup_true_lang-b6a57ae9.js → Expand.vue_vue_type_script_setup_true_lang-1751f4a6.js} +12 -13
- package/dist/Expand.vue_vue_type_script_setup_true_lang-1751f4a6.js.map +1 -0
- package/dist/Field.js +2 -2
- package/dist/Field.vue.d.ts +1 -1
- package/dist/{Field.vue_vue_type_script_setup_true_lang-4483019d.js → Field.vue_vue_type_script_setup_true_lang-42ba3c5a.js} +2 -2
- package/dist/Field.vue_vue_type_script_setup_true_lang-42ba3c5a.js.map +1 -0
- package/dist/FileUpload.js +7 -7
- package/dist/FileUpload.js.map +1 -1
- package/dist/FilterChip.js +30 -30
- package/dist/FilterChip.js.map +1 -1
- package/dist/FilterDropdown.js +2 -2
- package/dist/FilterSelect.js +2 -2
- package/dist/Filters.js +39 -39
- package/dist/Filters.js.map +1 -1
- package/dist/HttpError.js +6 -6
- package/dist/IconLabel.js +6 -6
- package/dist/IconLabel.js.map +1 -1
- package/dist/IconLabel.vue.d.ts +1 -1
- package/dist/Illustration.js +10 -60
- package/dist/Illustration.js.map +1 -1
- package/dist/Illustration.vue_vue_type_script_setup_true_lang-d6a94e17.js +56 -0
- package/dist/Illustration.vue_vue_type_script_setup_true_lang-d6a94e17.js.map +1 -0
- package/dist/Image.js +67 -72
- package/dist/Image.js.map +1 -1
- package/dist/InlineEdit.js +2 -2
- package/dist/Input.js +53 -53
- package/dist/Input.js.map +1 -1
- package/dist/InputOptions.js +2 -2
- package/dist/Label.js +1 -1
- package/dist/Label.vue.d.ts +13 -2
- package/dist/{Label.vue_vue_type_script_setup_true_lang-2de35913.js → Label.vue_vue_type_script_setup_true_lang-4b02087f.js} +12 -11
- package/dist/Label.vue_vue_type_script_setup_true_lang-4b02087f.js.map +1 -0
- package/dist/ListItem.js +11 -11
- package/dist/ListItem.js.map +1 -1
- package/dist/ListItemCell.js +9 -9
- package/dist/ListItemCell.js.map +1 -1
- package/dist/ListView.js +83 -80
- package/dist/ListView.js.map +1 -1
- package/dist/Loading.js +17 -10
- package/dist/Loading.js.map +1 -1
- package/dist/Loading.vue_used_vue_type_style_index_0_lang.module-ef5a3bc6.js +8 -0
- package/dist/Loading.vue_used_vue_type_style_index_0_lang.module-ef5a3bc6.js.map +1 -0
- package/dist/MenuItem.js +20 -14
- package/dist/MenuItem.js.map +1 -1
- package/dist/Modal.js +2 -2
- package/dist/Modal.js.map +1 -1
- package/dist/ObfuscateText.js +30 -32
- package/dist/ObfuscateText.js.map +1 -1
- package/dist/ObfuscateText.vue.d.ts +1 -1
- package/dist/PageContent.js +9 -9
- package/dist/PageContent.js.map +1 -1
- package/dist/PageHeader.js +22 -22
- package/dist/PageHeader.js.map +1 -1
- package/dist/Paginate.js +1 -1
- package/dist/Paginate.js.map +1 -1
- package/dist/Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js +11 -0
- package/dist/Paginate.vue_used_vue_type_style_index_0_lang.module-18343da7.js.map +1 -0
- package/dist/Radio.js +24 -19
- package/dist/Radio.js.map +1 -1
- package/dist/RadioGroup.js +43 -43
- package/dist/RadioGroup.js.map +1 -1
- package/dist/SearchBar.js +32 -32
- package/dist/SearchBar.js.map +1 -1
- package/dist/Select.js +5 -5
- package/dist/Select.js.map +1 -1
- package/dist/SelectStatus.js +2 -2
- package/dist/Switch.js +41 -34
- package/dist/Switch.js.map +1 -1
- package/dist/Table.js +6 -6
- package/dist/Table.keys-cf93df19.js +27 -0
- package/dist/{Table.keys-75e99266.js.map → Table.keys-cf93df19.js.map} +1 -1
- package/dist/TableCell.js +5 -5
- package/dist/TableCell.js.map +1 -1
- package/dist/TableHeaderCell.js +32 -32
- package/dist/TableHeaderCell.js.map +1 -1
- package/dist/TableHeaderRow.js +10 -10
- package/dist/TableHeaderRow.js.map +1 -1
- package/dist/TableRow.js +6 -6
- package/dist/TableRow.js.map +1 -1
- package/dist/Textarea.js +49 -41
- package/dist/Textarea.js.map +1 -1
- package/dist/Toast.js +23 -23
- package/dist/Toast.js.map +1 -1
- package/dist/components.css +1 -1
- package/dist/constants.d.ts +26 -19
- package/dist/constants.js +41 -26
- package/dist/constants.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/tailwind-base.d.ts +16 -16
- package/dist/tailwind-base.js +7 -4
- package/dist/tailwind-base.js.map +1 -1
- package/package.json +1 -1
- package/styles/backwards-compat.css +41 -104
- package/styles/base.css +258 -112
- package/tailwind-base.ts +3 -0
- package/dist/Button.vue_used_vue_type_style_index_0_lang.module-b2ee90e6.js +0 -17
- package/dist/Button.vue_used_vue_type_style_index_0_lang.module-b2ee90e6.js.map +0 -1
- package/dist/Checkbox.vue_vue_type_style_index_0_scoped_dbd26d7f_lang-4ed993c7.js +0 -2
- package/dist/Checkbox.vue_vue_type_style_index_0_scoped_dbd26d7f_lang-4ed993c7.js.map +0 -1
- package/dist/Expand.vue_vue_type_script_setup_true_lang-b6a57ae9.js.map +0 -1
- package/dist/Field.vue_vue_type_script_setup_true_lang-4483019d.js.map +0 -1
- package/dist/Label.vue_vue_type_script_setup_true_lang-2de35913.js.map +0 -1
- package/dist/Loading.vue_vue_type_style_index_0_scoped_bb8d5f15_lang-4ed993c7.js +0 -2
- package/dist/Loading.vue_vue_type_style_index_0_scoped_bb8d5f15_lang-4ed993c7.js.map +0 -1
- package/dist/Paginate.vue_used_vue_type_style_index_0_lang.module-1a2084f9.js +0 -11
- package/dist/Paginate.vue_used_vue_type_style_index_0_lang.module-1a2084f9.js.map +0 -1
- package/dist/Table.keys-75e99266.js +0 -27
- package/styles/_base.scss +0 -493
- package/styles/elements/_links.scss +0 -32
- package/styles/elements/_lists.scss +0 -31
- package/styles/elements/_misc.scss +0 -16
- package/styles/main.scss +0 -38
package/dist/Illustration.js
CHANGED
|
@@ -1,64 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
const P = Object.values(l);
|
|
7
|
-
var o = /* @__PURE__ */ ((i) => (i.Bank = "bank", i.SearchStorefront = "search-storefront", i.Todo = "todo", i.Warehouse = "warehouse", i))(o || {});
|
|
8
|
-
const _ = Object.values(o);
|
|
9
|
-
var r = /* @__PURE__ */ ((i) => (i.Spot = "spot", i.Vignette = "vignette", i.Scene = "scene", i))(r || {});
|
|
10
|
-
const D = /* @__PURE__ */ h({
|
|
11
|
-
__name: "Illustration",
|
|
12
|
-
props: {
|
|
13
|
-
id: { default: C("ll-illustration-") },
|
|
14
|
-
name: {},
|
|
15
|
-
title: { default: "" },
|
|
16
|
-
size: { default: 48 },
|
|
17
|
-
type: { default: r.Spot },
|
|
18
|
-
fillColor: { default: "blue" },
|
|
19
|
-
strokeColor: { default: "purple-500" },
|
|
20
|
-
staticPath: { default: "" }
|
|
21
|
-
},
|
|
22
|
-
setup(i) {
|
|
23
|
-
const e = i;
|
|
24
|
-
if (e.type === r.Scene)
|
|
25
|
-
throw new Error(
|
|
26
|
-
"Scene illustration types are not supported. Illustrations will need to be uploaded under ./assets/illustrations/scene. Illustrations to be provided by design."
|
|
27
|
-
);
|
|
28
|
-
if (e.type === r.Spot && !P.includes(e.name) || e.type === r.Vignette && !_.includes(e.name))
|
|
29
|
-
throw new Error(
|
|
30
|
-
`${e.type} illustration name ${e.name} not found. Did you check that you are using the correct type for your illustration?`
|
|
31
|
-
);
|
|
32
|
-
const u = y(), n = f("stashOptions", {
|
|
33
|
-
staticPath: "/static"
|
|
34
|
-
}), t = s(() => e.type === r.Spot), a = s(() => t.value ? "0" : !1), d = s(() => e.staticPath || (n == null ? void 0 : n.staticPath));
|
|
35
|
-
return (B, L) => (g(), k(c(b), {
|
|
36
|
-
id: e.id,
|
|
37
|
-
class: v([
|
|
38
|
-
c(u).illustration,
|
|
39
|
-
{
|
|
40
|
-
[`tw-text-${e.fillColor}-400 tw-stroke-${e.strokeColor}`]: t.value
|
|
41
|
-
}
|
|
42
|
-
]),
|
|
43
|
-
title: e.title,
|
|
44
|
-
height: e.size,
|
|
45
|
-
width: e.size,
|
|
46
|
-
"stroke-width": a.value,
|
|
47
|
-
fill: "none",
|
|
48
|
-
src: `${d.value}/illustrations/${e.type}/${e.name}.svg`
|
|
49
|
-
}, null, 8, ["id", "class", "title", "height", "width", "stroke-width", "src"]));
|
|
50
|
-
}
|
|
51
|
-
}), I = "_illustration_b0xut_2", x = {
|
|
52
|
-
illustration: I
|
|
53
|
-
}, z = {
|
|
54
|
-
$style: x
|
|
55
|
-
}, R = /* @__PURE__ */ w(D, [["__cssModules", z]]);
|
|
1
|
+
import { _ as a } from "./Illustration.vue_vue_type_script_setup_true_lang-d6a94e17.js";
|
|
2
|
+
import { I as r, S as i, V as f, s as n, v as N } from "./Illustration.vue_vue_type_script_setup_true_lang-d6a94e17.js";
|
|
3
|
+
import "vue";
|
|
4
|
+
import "lodash-es/uniqueId";
|
|
5
|
+
import "./index-79ce320f.js";
|
|
56
6
|
export {
|
|
57
7
|
r as IllustrationType,
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
8
|
+
i as SpotName,
|
|
9
|
+
f as VignetteName,
|
|
10
|
+
a as default,
|
|
11
|
+
n as spotNames,
|
|
12
|
+
N as vignetteNames
|
|
63
13
|
};
|
|
64
14
|
//# sourceMappingURL=Illustration.js.map
|
package/dist/Illustration.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Illustration.js","sources":[
|
|
1
|
+
{"version":3,"file":"Illustration.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defineComponent as u, inject as d, computed as t, openBlock as h, createBlock as g, unref as y, normalizeClass as k } from "vue";
|
|
2
|
+
import f from "lodash-es/uniqueId";
|
|
3
|
+
import { I as v } from "./index-79ce320f.js";
|
|
4
|
+
var c = /* @__PURE__ */ ((i) => (i.Approved = "approved", i.Avatar = "avatar", i.Barcode = "barcode", i.Calendar = "calendar", i.Cartridge = "cartridge", i.Celebrate = "celebrate", i.ChatBubble = "chat-bubble", i.CheckBox = "check-box", i.CheckCircle = "check-circle", i.Click = "click", i.Cocktail = "cocktail", i.Confirmation = "confirmation", i.Connnect = "connnect", i.Cookie = "cookie", i.CreditCard = "credit-card", i.Crm = "crm", i.Cultivation = "cultivation", i.Data = "data", i.DeliveryCompleted = "delivery-completed", i.Delivery = "delivery", i.DigitalPayments = "digital-payments", i.Discover = "discover", i.Diversity = "diversity", i.Drink = "drink", i.Dolly = "dolly", i.EasyReconciliations = "easy-reconciliations", i.Efficiency = "efficiency", i.Error = "error", i.FinancialGrowth = "financial-growth", i.FinancialInstitution = "financial-institution", i.Focus = "focus", i.FulfillmentIssues = "fulfillment-issues", i.Growth = "growth", i.Handshake = "handshake", i.Hierarchy = "hierarchy", i.Home = "home", i.Laptop = "laptop", i.Licenses = "licenses", i.LightBulb = "light-bulb", i.LightbulbError = "lightbulb-error", i.LineChart = "line-chart", i.Link = "link", i.LocationPin = "location-pin", i.Lock = "lock", i.Messaging = "messaging", i.Microchip = "microchip", i.MissingData = "missing-data", i.MoneyTransfer = "money-transfer", i.Money = "money", i.NoInventoryAccess = "no-inventory-access", i.NoInventory = "no-inventory", i.NoPromote = "no-promote", i.PackageReceived = "package-received", i.Package = "package", i.PaymentProcessing = "payment-processing", i.Phone = "phone", i.PieChart = "pie-chart", i.ProductCycle = "product-cycle", i.Puzzle = "puzzle", i.Receipt = "receipt", i.Retail = "retail", i.SearchingDocument = "searching-document", i.ShoppingBasket = "shopping-basket", i.Shopping = "shopping", i.Sign = "sign", i.Smile = "smile", i.Speed = "speed", i.Time = "time", i.Tools = "tools", i.Truck = "truck", i.User = "user", i.Warehouse = "warehouse", i.Warning = "warning", i.XCircle = "x-circle", i))(c || {});
|
|
5
|
+
const C = Object.values(c);
|
|
6
|
+
var l = /* @__PURE__ */ ((i) => (i.Bank = "bank", i.SearchStorefront = "search-storefront", i.Todo = "todo", i.Warehouse = "warehouse", i))(l || {});
|
|
7
|
+
const b = Object.values(l);
|
|
8
|
+
var r = /* @__PURE__ */ ((i) => (i.Spot = "spot", i.Vignette = "vignette", i.Scene = "scene", i))(r || {});
|
|
9
|
+
const B = /* @__PURE__ */ u({
|
|
10
|
+
__name: "Illustration",
|
|
11
|
+
props: {
|
|
12
|
+
id: { default: f("ll-illustration-") },
|
|
13
|
+
name: {},
|
|
14
|
+
title: { default: "" },
|
|
15
|
+
size: { default: 48 },
|
|
16
|
+
type: { default: r.Spot },
|
|
17
|
+
fillColor: { default: "blue" },
|
|
18
|
+
strokeColor: { default: "purple-500" },
|
|
19
|
+
staticPath: { default: "" }
|
|
20
|
+
},
|
|
21
|
+
setup(i) {
|
|
22
|
+
const e = i;
|
|
23
|
+
if (e.type === r.Scene)
|
|
24
|
+
throw new Error(
|
|
25
|
+
"Scene illustration types are not supported. Illustrations will need to be uploaded under ./assets/illustrations/scene. Illustrations to be provided by design."
|
|
26
|
+
);
|
|
27
|
+
if (e.type === r.Spot && !C.includes(e.name) || e.type === r.Vignette && !b.includes(e.name))
|
|
28
|
+
throw new Error(
|
|
29
|
+
`${e.type} illustration name ${e.name} not found. Did you check that you are using the correct type for your illustration?`
|
|
30
|
+
);
|
|
31
|
+
const n = d("stashOptions", {
|
|
32
|
+
staticPath: "/static"
|
|
33
|
+
}), s = t(() => e.type === r.Spot), o = t(() => s.value ? "0" : !1), a = t(() => e.staticPath || (n == null ? void 0 : n.staticPath));
|
|
34
|
+
return (w, P) => (h(), g(y(v), {
|
|
35
|
+
id: e.id,
|
|
36
|
+
class: k(["tw-inline-block tw-align-middle", {
|
|
37
|
+
[`tw-text-${e.fillColor}-400 tw-stroke-${e.strokeColor}`]: s.value
|
|
38
|
+
}]),
|
|
39
|
+
title: e.title,
|
|
40
|
+
height: e.size,
|
|
41
|
+
width: e.size,
|
|
42
|
+
"stroke-width": o.value,
|
|
43
|
+
fill: "none",
|
|
44
|
+
src: `${a.value}/illustrations/${e.type}/${e.name}.svg`
|
|
45
|
+
}, null, 8, ["id", "class", "title", "height", "width", "stroke-width", "src"]));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
export {
|
|
49
|
+
r as I,
|
|
50
|
+
c as S,
|
|
51
|
+
l as V,
|
|
52
|
+
B as _,
|
|
53
|
+
C as s,
|
|
54
|
+
b as v
|
|
55
|
+
};
|
|
56
|
+
//# sourceMappingURL=Illustration.vue_vue_type_script_setup_true_lang-d6a94e17.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Illustration.vue_vue_type_script_setup_true_lang-d6a94e17.js","sources":["../src/components/Illustration/Illustration.models.ts","../src/components/Illustration/Illustration.vue"],"sourcesContent":["/**\n * Enum to strongly map between a friendly name and file name of the illustration\n */\nexport enum SpotName {\n Approved = 'approved',\n Avatar = 'avatar',\n Barcode = 'barcode',\n Calendar = 'calendar',\n Cartridge = 'cartridge',\n Celebrate = 'celebrate',\n ChatBubble = 'chat-bubble',\n CheckBox = 'check-box',\n CheckCircle = 'check-circle',\n Click = 'click',\n Cocktail = 'cocktail',\n Confirmation = 'confirmation',\n Connnect = 'connnect',\n Cookie = 'cookie',\n CreditCard = 'credit-card',\n Crm = 'crm',\n Cultivation = 'cultivation',\n Data = 'data',\n DeliveryCompleted = 'delivery-completed',\n Delivery = 'delivery',\n DigitalPayments = 'digital-payments',\n Discover = 'discover',\n Diversity = 'diversity',\n Drink = 'drink',\n Dolly = 'dolly',\n EasyReconciliations = 'easy-reconciliations',\n Efficiency = 'efficiency',\n Error = 'error',\n FinancialGrowth = 'financial-growth',\n FinancialInstitution = 'financial-institution',\n Focus = 'focus',\n FulfillmentIssues = 'fulfillment-issues',\n Growth = 'growth',\n Handshake = 'handshake',\n Hierarchy = 'hierarchy',\n Home = 'home',\n Laptop = 'laptop',\n Licenses = 'licenses',\n LightBulb = 'light-bulb',\n LightbulbError = 'lightbulb-error',\n LineChart = 'line-chart',\n Link = 'link',\n LocationPin = 'location-pin',\n Lock = 'lock',\n Messaging = 'messaging',\n Microchip = 'microchip',\n MissingData = 'missing-data',\n MoneyTransfer = 'money-transfer',\n Money = 'money',\n NoInventoryAccess = 'no-inventory-access',\n NoInventory = 'no-inventory',\n NoPromote = 'no-promote',\n PackageReceived = 'package-received',\n Package = 'package',\n PaymentProcessing = 'payment-processing',\n Phone = 'phone',\n PieChart = 'pie-chart',\n ProductCycle = 'product-cycle',\n Puzzle = 'puzzle',\n Receipt = 'receipt',\n Retail = 'retail',\n SearchingDocument = 'searching-document',\n ShoppingBasket = 'shopping-basket',\n Shopping = 'shopping',\n Sign = 'sign',\n Smile = 'smile',\n Speed = 'speed',\n Time = 'time',\n Tools = 'tools',\n Truck = 'truck',\n User = 'user',\n Warehouse = 'warehouse',\n Warning = 'warning',\n XCircle = 'x-circle',\n}\n\nexport type SpotNames = `${SpotName}`;\n\n/**\n * String array of all illustration names\n */\nexport const spotNames = Object.values(SpotName);\n\nexport enum VignetteName {\n Bank = 'bank',\n SearchStorefront = 'search-storefront',\n Todo = 'todo',\n Warehouse = 'warehouse',\n}\n\nexport type VignetteNames = `${VignetteName}`;\n\n/**\n * String array of all vignette names\n */\nexport const vignetteNames = Object.values(VignetteName);\n\n/**\n * Types of illustrations that map to the subfolder under ./assets/illustrations/<type>\n */\nexport enum IllustrationType {\n Spot = 'spot',\n Vignette = 'vignette',\n // Scene is not implemented, but adding it for future work mentioned in STASH-61.\n Scene = 'scene',\n}\n\nexport type IllustrationTypes = `${IllustrationType}`;\n","<script lang=\"ts\">\n export * from './Illustration.models';\n</script>\n\n<script lang=\"ts\" setup>\n import uniqueId from 'lodash-es/uniqueId';\n import { computed, inject } from 'vue';\n import InlineSvg from 'vue-inline-svg';\n\n import { StashPrimaryColor, StashPrimaryColorGroup } from '../../../types/colors';\n import { StashProvideState } from '../../../types/misc';\n import {\n IllustrationType,\n IllustrationTypes,\n SpotName,\n SpotNames,\n spotNames,\n VignetteName,\n VignetteNames,\n vignetteNames,\n } from './Illustration.models';\n\n export interface IllustrationProps {\n id?: string;\n\n /**\n * The filename of the icon that should be displayed\n */\n name: SpotNames | VignetteNames;\n\n /**\n * Accessible, short-text description for the icon. Not rendered as part of the graphic, but\n * browsers usually display it as a tooltip and screen readers use this.\n */\n title?: string;\n\n /**\n * The size in pixels of the illustration. This number will be used for width and height\n */\n size?: number;\n\n /**\n * Type of the illustration\n */\n type?: IllustrationTypes;\n\n /**\n * The fill color for the illustration. This component will use the 400 shade of the color\n * per design's request. Defaults to teal.\n */\n fillColor?: StashPrimaryColorGroup;\n\n /**\n * The color theme for the illustration. This component will use the standard 500 shade of the color.\n * Defaults to purple\n */\n strokeColor?: StashPrimaryColor;\n\n /**\n * Illustration's custom static path. It'll default to either the staticPath defined on the library installation or '/static' if none are provided.\n */\n staticPath?: string;\n }\n\n const props = withDefaults(defineProps<IllustrationProps>(), {\n id: uniqueId('ll-illustration-'),\n title: '',\n size: 48,\n type: IllustrationType.Spot,\n fillColor: 'blue',\n strokeColor: 'purple-500',\n staticPath: '',\n });\n\n if (props.type === IllustrationType.Scene) {\n throw new Error(\n 'Scene illustration types are not supported. Illustrations will need to be uploaded under ./assets/illustrations/scene. Illustrations to be provided by design.',\n );\n }\n\n if (\n (props.type === IllustrationType.Spot && !spotNames.includes(props.name as SpotName)) ||\n (props.type === IllustrationType.Vignette && !vignetteNames.includes(props.name as VignetteName))\n ) {\n throw new Error(\n `${props.type} illustration name ${props.name} not found. Did you check that you are using the correct type for your illustration?`,\n );\n }\n\n const stashOptions = inject<Partial<StashProvideState>>('stashOptions', {\n staticPath: '/static',\n });\n\n const isSpotIllustration = computed(() => props.type === IllustrationType.Spot);\n\n /**\n * Browsers won't add the `stroke-width` attribute if it is set to false.\n * However, setting it to specific number value affects vignettes\n */\n const strokeWidth = computed<boolean | string>(() => {\n return isSpotIllustration.value ? '0' : false;\n });\n\n const computedStaticPath = computed(() => {\n return props.staticPath || stashOptions?.staticPath;\n });\n</script>\n\n<template>\n <!-- InlineSvg package (https://github.com/shrpne/vue-inline-svg) swaps external svgs and puts\n them inline so we can style them with CSS -->\n <!-- Having to override fill to be none and stroke to be zero so the exported svgs from Figma\n that do not have those attributes specified do not get a default one applied -->\n <InlineSvg\n :id=\"props.id\"\n class=\"tw-inline-block tw-align-middle\"\n :class=\"{\n [`tw-text-${props.fillColor}-400 tw-stroke-${props.strokeColor}`]: isSpotIllustration,\n }\"\n :title=\"props.title\"\n :height=\"props.size\"\n :width=\"props.size\"\n :stroke-width=\"strokeWidth\"\n fill=\"none\"\n :src=\"`${computedStaticPath}/illustrations/${props.type}/${props.name}.svg`\"\n />\n</template>\n"],"names":["SpotName","spotNames","VignetteName","vignetteNames","IllustrationType","props","stashOptions","inject","isSpotIllustration","computed","strokeWidth","computedStaticPath"],"mappings":";;;AAGY,IAAAA,sBAAAA,OACVA,EAAA,WAAW,YACXA,EAAA,SAAS,UACTA,EAAA,UAAU,WACVA,EAAA,WAAW,YACXA,EAAA,YAAY,aACZA,EAAA,YAAY,aACZA,EAAA,aAAa,eACbA,EAAA,WAAW,aACXA,EAAA,cAAc,gBACdA,EAAA,QAAQ,SACRA,EAAA,WAAW,YACXA,EAAA,eAAe,gBACfA,EAAA,WAAW,YACXA,EAAA,SAAS,UACTA,EAAA,aAAa,eACbA,EAAA,MAAM,OACNA,EAAA,cAAc,eACdA,EAAA,OAAO,QACPA,EAAA,oBAAoB,sBACpBA,EAAA,WAAW,YACXA,EAAA,kBAAkB,oBAClBA,EAAA,WAAW,YACXA,EAAA,YAAY,aACZA,EAAA,QAAQ,SACRA,EAAA,QAAQ,SACRA,EAAA,sBAAsB,wBACtBA,EAAA,aAAa,cACbA,EAAA,QAAQ,SACRA,EAAA,kBAAkB,oBAClBA,EAAA,uBAAuB,yBACvBA,EAAA,QAAQ,SACRA,EAAA,oBAAoB,sBACpBA,EAAA,SAAS,UACTA,EAAA,YAAY,aACZA,EAAA,YAAY,aACZA,EAAA,OAAO,QACPA,EAAA,SAAS,UACTA,EAAA,WAAW,YACXA,EAAA,YAAY,cACZA,EAAA,iBAAiB,mBACjBA,EAAA,YAAY,cACZA,EAAA,OAAO,QACPA,EAAA,cAAc,gBACdA,EAAA,OAAO,QACPA,EAAA,YAAY,aACZA,EAAA,YAAY,aACZA,EAAA,cAAc,gBACdA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MACtE,YAAY;AAAA,IAAA,CACb,GAEKC,IAAqBC,EAAS,MAAMJ,EAAM,SAASD,EAAiB,IAAI,GAMxEM,IAAcD,EAA2B,MACtCD,EAAmB,QAAQ,MAAM,EACzC,GAEKG,IAAqBF,EAAS,MAC3BJ,EAAM,eAAcC,KAAA,gBAAAA,EAAc,WAC1C;;;;;;;;;;;;;;;"}
|
package/dist/Image.js
CHANGED
|
@@ -1,34 +1,29 @@
|
|
|
1
|
-
import { defineComponent as x, inject as
|
|
2
|
-
import { IMAGE_PROVIDER_URLS as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import "lodash-es/get";
|
|
7
|
-
import "lodash-es/isFinite";
|
|
8
|
-
import "lodash-es/isPlainObject";
|
|
9
|
-
function P(e) {
|
|
10
|
-
return (t) => e[t] || t;
|
|
1
|
+
import { defineComponent as x, inject as C, computed as d, useAttrs as W, openBlock as D, createElementBlock as L, mergeProps as M } from "vue";
|
|
2
|
+
import { IMAGE_PROVIDER_URLS as B, SCREEN_SIZES as P } from "./constants.js";
|
|
3
|
+
import N from "lodash-es/merge";
|
|
4
|
+
function j(t) {
|
|
5
|
+
return (e) => t[e] || e;
|
|
11
6
|
}
|
|
12
|
-
function
|
|
13
|
-
formatter:
|
|
14
|
-
keyMap:
|
|
7
|
+
function V({
|
|
8
|
+
formatter: t = (n, c) => `${n}=${c}`,
|
|
9
|
+
keyMap: e,
|
|
15
10
|
joinWith: f = "/",
|
|
16
11
|
valueMap: i = {}
|
|
17
12
|
} = {}) {
|
|
18
|
-
const n = typeof
|
|
13
|
+
const n = typeof e == "function" ? e : j(e);
|
|
19
14
|
return Object.keys(i).forEach((c) => {
|
|
20
|
-
typeof i[c] != "function" && (i[c] =
|
|
15
|
+
typeof i[c] != "function" && (i[c] = j(i[c]));
|
|
21
16
|
}), (c = {}) => Object.entries(c).map(([g, v]) => {
|
|
22
17
|
const m = i[g], S = n(g);
|
|
23
18
|
let h = v;
|
|
24
|
-
return typeof m == "function" && (h = m(c[g])),
|
|
19
|
+
return typeof m == "function" && (h = m(c[g])), t(S, h);
|
|
25
20
|
}).join(f);
|
|
26
21
|
}
|
|
27
|
-
function k(
|
|
28
|
-
const i = new URL(
|
|
29
|
-
return
|
|
22
|
+
function k(t = "", e = []) {
|
|
23
|
+
const i = new URL(t).host;
|
|
24
|
+
return e.some((n) => n === i ? !0 : n.endsWith(`.${i}`));
|
|
30
25
|
}
|
|
31
|
-
const q =
|
|
26
|
+
const q = B.CLOUDINARY, G = (t) => t.startsWith("#") ? t.replace("#", "rgb_") : t, E = V({
|
|
32
27
|
keyMap: {
|
|
33
28
|
fit: "c",
|
|
34
29
|
width: "w",
|
|
@@ -49,36 +44,36 @@ const q = N.CLOUDINARY, F = (e) => e.startsWith("#") ? e.replace("#", "rgb_") :
|
|
|
49
44
|
format: {
|
|
50
45
|
jpeg: "jpg"
|
|
51
46
|
},
|
|
52
|
-
background(
|
|
53
|
-
return
|
|
47
|
+
background(t) {
|
|
48
|
+
return G(t);
|
|
54
49
|
}
|
|
55
50
|
},
|
|
56
51
|
joinWith: ",",
|
|
57
|
-
formatter: (
|
|
58
|
-
}),
|
|
52
|
+
formatter: (t, e) => `${t}_${e}`
|
|
53
|
+
}), F = {
|
|
59
54
|
// defaulting to maintain original image format to reduce transformations
|
|
60
55
|
// format: 'auto',
|
|
61
56
|
quality: "auto"
|
|
62
57
|
};
|
|
63
|
-
function
|
|
64
|
-
const f =
|
|
65
|
-
return `${q}/${i}/${
|
|
58
|
+
function Y(t, e = {}) {
|
|
59
|
+
const f = N(F, e), i = E(f);
|
|
60
|
+
return `${q}/${i}/${t}`;
|
|
66
61
|
}
|
|
67
|
-
const
|
|
62
|
+
const Z = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
68
63
|
__proto__: null,
|
|
69
|
-
getImageUrl:
|
|
70
|
-
operationsGenerator:
|
|
64
|
+
getImageUrl: Y,
|
|
65
|
+
operationsGenerator: E
|
|
71
66
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
72
|
-
function
|
|
73
|
-
return
|
|
67
|
+
function H(t = "") {
|
|
68
|
+
return t;
|
|
74
69
|
}
|
|
75
|
-
const
|
|
70
|
+
const K = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
76
71
|
__proto__: null,
|
|
77
|
-
getImageUrl:
|
|
78
|
-
}, Symbol.toStringTag, { value: "Module" })),
|
|
79
|
-
cloudinary:
|
|
80
|
-
static:
|
|
81
|
-
},
|
|
72
|
+
getImageUrl: H
|
|
73
|
+
}, Symbol.toStringTag, { value: "Module" })), J = {
|
|
74
|
+
cloudinary: Z,
|
|
75
|
+
static: K
|
|
76
|
+
}, Q = ["src"], w = {
|
|
82
77
|
xsmall: {
|
|
83
78
|
alwaysIncluded: !1,
|
|
84
79
|
width: 160
|
|
@@ -100,8 +95,8 @@ const J = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
|
100
95
|
width: 2704
|
|
101
96
|
}
|
|
102
97
|
};
|
|
103
|
-
var
|
|
104
|
-
const
|
|
98
|
+
var X = /* @__PURE__ */ ((t) => (t.None = "none", t.Rounded = "rounded", t))(X || {});
|
|
99
|
+
const ne = /* @__PURE__ */ x({
|
|
105
100
|
__name: "Image",
|
|
106
101
|
props: {
|
|
107
102
|
src: { default: "" },
|
|
@@ -110,43 +105,43 @@ const ut = /* @__PURE__ */ x({
|
|
|
110
105
|
provider: { default: null },
|
|
111
106
|
radius: { default: "none" }
|
|
112
107
|
},
|
|
113
|
-
setup(
|
|
114
|
-
const
|
|
108
|
+
setup(t) {
|
|
109
|
+
const e = t, f = {
|
|
115
110
|
CLOUDINARY: "cloudinary",
|
|
116
111
|
STATIC: "static"
|
|
117
112
|
}, i = {
|
|
118
|
-
md:
|
|
119
|
-
lg:
|
|
120
|
-
}, n =
|
|
113
|
+
md: P.md,
|
|
114
|
+
lg: P.lg
|
|
115
|
+
}, n = C("stashOptions"), c = d(() => {
|
|
121
116
|
const { src: r, ...s } = W();
|
|
122
|
-
return s.sizes =
|
|
123
|
-
}),
|
|
117
|
+
return s.sizes = R.value, s.srcset = T.value, s;
|
|
118
|
+
}), _ = d(() => {
|
|
124
119
|
var r;
|
|
125
120
|
return ((r = n == null ? void 0 : n.images) == null ? void 0 : r.staticDomains) || [];
|
|
126
121
|
}), g = d(() => {
|
|
127
122
|
try {
|
|
128
|
-
new URL(
|
|
123
|
+
new URL(e.src);
|
|
129
124
|
} catch {
|
|
130
125
|
return !0;
|
|
131
126
|
}
|
|
132
|
-
return k(
|
|
127
|
+
return k(e.src, _.value);
|
|
133
128
|
}), v = d(() => {
|
|
134
129
|
var r;
|
|
135
|
-
return
|
|
136
|
-
}), m = d(() => v.value === f.STATIC), S = d(() =>
|
|
137
|
-
() => m.value ?
|
|
138
|
-
),
|
|
139
|
-
function
|
|
140
|
-
return S.value.getImageUrl(
|
|
130
|
+
return e.provider ? e.provider : (r = n == null ? void 0 : n.images) != null && r.provider && n.images.provider !== f.STATIC && !g.value ? n.images.provider : f.STATIC;
|
|
131
|
+
}), m = d(() => v.value === f.STATIC), S = d(() => J[v.value]), h = d(
|
|
132
|
+
() => m.value ? I() : I({ width: w.medium.width })
|
|
133
|
+
), R = d(() => e.sizes || !m.value ? O() : void 0), T = d(() => e.sizes && !e.srcset && !m.value ? U() : e.srcset), y = d(() => e.sizes ? z(e.sizes) : m.value ? [] : z("lg:large"));
|
|
134
|
+
function I(r = {}) {
|
|
135
|
+
return S.value.getImageUrl(e.src, r);
|
|
141
136
|
}
|
|
142
|
-
function
|
|
137
|
+
function U() {
|
|
143
138
|
const r = Object.entries(w).reduce((s, [l, a]) => ((!!y.value.find((o) => o.preset === l) || a.alwaysIncluded) && (s[l] = a), s), {});
|
|
144
139
|
return Object.values(r).map((s) => {
|
|
145
140
|
const l = s.width;
|
|
146
|
-
return `${
|
|
141
|
+
return `${I({ width: l })} ${s.width}w`;
|
|
147
142
|
}).join(", ");
|
|
148
143
|
}
|
|
149
|
-
function
|
|
144
|
+
function O() {
|
|
150
145
|
return y.value.map((r) => `${r.media ? r.media + " " : ""}${r.size}`).join(", ");
|
|
151
146
|
}
|
|
152
147
|
function z(r) {
|
|
@@ -166,36 +161,36 @@ const ut = /* @__PURE__ */ x({
|
|
|
166
161
|
} else
|
|
167
162
|
throw new Error("`sizes` needs to be a string");
|
|
168
163
|
for (const a in l) {
|
|
169
|
-
const u = parseInt(i[a] || 0), o = l[a],
|
|
170
|
-
let p = String(
|
|
171
|
-
const
|
|
172
|
-
if (
|
|
164
|
+
const u = parseInt(i[a] || 0), o = l[a], $ = w[o] ? o : void 0;
|
|
165
|
+
let p = String($ ? w[o].width : o);
|
|
166
|
+
const b = p.endsWith("vw");
|
|
167
|
+
if (!b && /^\d+$/.test(p) && (p = `${p}px`), !b && !p.endsWith("px"))
|
|
173
168
|
continue;
|
|
174
|
-
const
|
|
169
|
+
const A = {
|
|
175
170
|
media: u ? `(min-width: ${u}px)` : "",
|
|
176
|
-
preset:
|
|
171
|
+
preset: $,
|
|
177
172
|
screenMinWidth: u,
|
|
178
173
|
size: p
|
|
179
174
|
};
|
|
180
|
-
s.push(
|
|
175
|
+
s.push(A);
|
|
181
176
|
}
|
|
182
177
|
return s.sort((a, u) => a.screenMinWidth > u.screenMinWidth ? -1 : 1), s;
|
|
183
178
|
}
|
|
184
|
-
return (r, s) => (
|
|
179
|
+
return (r, s) => (D(), L("img", M({
|
|
185
180
|
ref: "img",
|
|
186
181
|
key: h.value,
|
|
187
182
|
"data-test": "stash-image",
|
|
188
|
-
class: {
|
|
189
|
-
"tw-rounded":
|
|
183
|
+
class: ["stash-image", {
|
|
184
|
+
"tw-rounded": e.radius === "rounded"
|
|
190
185
|
/* Rounded */
|
|
191
|
-
},
|
|
186
|
+
}],
|
|
192
187
|
src: h.value
|
|
193
|
-
}, c.value), null, 16,
|
|
188
|
+
}, c.value), null, 16, Q));
|
|
194
189
|
}
|
|
195
190
|
});
|
|
196
191
|
export {
|
|
197
|
-
|
|
192
|
+
X as ImageRadiuses,
|
|
198
193
|
w as PRESET_SIZES,
|
|
199
|
-
|
|
194
|
+
ne as default
|
|
200
195
|
};
|
|
201
196
|
//# sourceMappingURL=Image.js.map
|
package/dist/Image.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Image.js","sources":["../src/components/Image/providers/utils.ts","../src/components/Image/providers/cloudinary.ts","../src/components/Image/providers/static.ts","../src/components/Image/providers/index.ts","../src/components/Image/Image.vue"],"sourcesContent":["export interface ImageModifiers {\n format?: string;\n height?: number;\n width?: number;\n [key: string]: any /* eslint-disable-line @typescript-eslint/no-explicit-any */;\n}\n\nexport type ParamFormatter = (key: string, value: string) => string;\n\nexport type ParamMapper = { [key: string]: string } | ((key: string) => string);\n\nexport interface ProviderUrlBuilder {\n keyMap?: ParamMapper;\n formatter?: ParamFormatter;\n joinWith?: string;\n valueMap?: {\n [key: string]: ParamMapper;\n };\n}\n\nfunction createMapper(map: any) {\n /* eslint-disable-line @typescript-eslint/no-explicit-any */\n return (key: string) => {\n return map[key] || key;\n };\n}\n\n/**\n * Builds the parameterized Cloudinary url\n */\nexport function buildProviderUrl({\n formatter = (key, value) => `${key}=${value}`,\n keyMap,\n joinWith = '/',\n valueMap = {},\n}: ProviderUrlBuilder = {}) {\n const keyMapper = typeof keyMap === 'function' ? keyMap : createMapper(keyMap);\n\n Object.keys(valueMap).forEach((valueKey) => {\n if (typeof valueMap[valueKey] !== 'function') {\n valueMap[valueKey] = createMapper(valueMap[valueKey]);\n }\n });\n\n return (modifiers: { [key: string]: string } = {}) => {\n const operations = Object.entries(modifiers).map(([key, value]) => {\n const mapper = valueMap[key];\n const newKey = keyMapper(key);\n let newVal = value;\n\n if (typeof mapper === 'function') {\n newVal = mapper(modifiers[key]);\n }\n\n return formatter(newKey, newVal);\n });\n\n return operations.join(joinWith);\n };\n}\n\n/**\n * Checks if a (sub)domain is included in a list of acceptable domains\n * @param str the (sub)domain to check\n * @param domains an array of valid domains\n */\nexport function isDomainValid(str = '', domains: string[] = []): boolean {\n const url = new URL(str);\n const host = url.host;\n\n return domains.some((domain) => {\n if (domain === host) {\n return true;\n }\n\n return domain.endsWith(`.${host}`);\n });\n}\n","import merge from 'lodash-es/merge';\n\nimport { IMAGE_PROVIDER_URLS } from '../../../constants';\nimport { buildProviderUrl, ImageModifiers } from './utils';\n\nconst BASE_URL = IMAGE_PROVIDER_URLS.CLOUDINARY;\n\nconst convertHextoRGBFormat = (value: string) => (value.startsWith('#') ? value.replace('#', 'rgb_') : value);\n\n/**\n * Parameters (option and value pairs) that can be used in the <transformations> segment of the Cloudinary transformation URL.\n * Options and their respective values are connected by an underscore (eg `w_250` for width of 250px.).\n * Multiple parameters are comma separated (eg. `w_250,h_250`).\n *\n * `keyMap` maps the option to its option prefix.\n * `valueMap` is used for grouping options using the same `keyMap` value under a 'category', allowing for easier usage and custom labelling in the component context.\n *\n * Transformation URL structure:\n * https://cloudinary.com/documentation/transformation_reference\n *\n * Transformation URL parameters (options and values):\n * https://cloudinary.com/documentation/image_transformations#transformation_url_syntax\n *\n */\nexport const operationsGenerator = buildProviderUrl({\n keyMap: {\n fit: 'c',\n width: 'w',\n height: 'h',\n format: 'f',\n quality: 'q',\n background: 'b',\n dpr: 'dpr',\n },\n valueMap: {\n fit: {\n fill: 'fill',\n inside: 'pad',\n outside: 'lpad',\n cover: 'fit',\n contain: 'scale',\n },\n format: {\n jpeg: 'jpg',\n },\n background(value: string) {\n return convertHextoRGBFormat(value);\n },\n },\n joinWith: ',',\n formatter: (key, value) => `${key}_${value}`,\n});\n\n// Note: Not configurable via Image props (for now).\nconst defaultModifiers = {\n // defaulting to maintain original image format to reduce transformations\n // format: 'auto',\n quality: 'auto',\n};\n\nexport function getImageUrl(src: string, modifiers: Partial<ImageModifiers> = {}): string {\n const mergeModifiers = merge(defaultModifiers, modifiers);\n const operations = operationsGenerator(mergeModifiers);\n\n return `${BASE_URL}/${operations}/${src}`;\n}\n","export function getImageUrl(src = ''): string {\n return src;\n}\n","import * as cloudinary from './cloudinary';\nimport * as staticProvider from './static';\n\nexport default {\n cloudinary,\n static: staticProvider,\n};\n","<script lang=\"ts\">\n export const PRESET_SIZES = {\n xsmall: {\n alwaysIncluded: false,\n width: 160,\n },\n small: {\n alwaysIncluded: true,\n width: 338,\n },\n medium: {\n alwaysIncluded: true,\n width: 676,\n },\n large: {\n alwaysIncluded: true,\n width: 1352,\n },\n xlarge: {\n alwaysIncluded: false,\n width: 2704,\n },\n } as const;\n\n export enum ImageRadiuses {\n None = 'none',\n Rounded = 'rounded',\n }\n</script>\n\n<script setup lang=\"ts\">\n import { computed, inject, useAttrs } from 'vue';\n\n import { StashImageProviders, StashProvideState } from '../../../types/misc';\n import { CSS_VARS } from '../../constants';\n import { getCssVar } from '../../utils/helpers';\n import providers from './providers';\n import { ImageModifiers, isDomainValid } from './providers/utils';\n\n // interface ImagePresetSizes {\n // [size: string]: {\n // alwaysIncluded: boolean;\n // width: number;\n // }\n // }\n\n export interface ImageSizeVariant {\n media: string;\n preset?: keyof typeof PRESET_SIZES;\n screenMinWidth: number;\n size: string;\n }\n\n export type ImageRadius = `${ImageRadiuses}`;\n\n export interface ImageProps {\n /**\n * The path to the image you want to embed.\n */\n src: string;\n\n /**\n * Native srcset attribute.\n * One or more strings separated by commas, indicating possible image sources\n * Can only be used with provider=static, otherwise it's ignored and auto-generated with `sizes` usage\n */\n srcset?: string;\n\n /**\n * For specifying responsive sizes\n */\n sizes?: string;\n\n /**\n * Where the image is served from.\n * Optional, and when provided it forces the provider used.\n *\n * The provider is otherwise inherited from the Stash config `stashOptions.images.provider`, which defaults to `cloudinary`.\n *\n * When not provided, the provider is also inferred by `isStatic`:\n * - `static` for relative/absolute paths (`img/foo.jpg` or `/static/img/bar.jpg`), or when whitelisted absolute URLs are used (included in `staticOptions.images.staticDomains`).\n */\n provider?: StashImageProviders | null;\n\n /**\n * For applying border radius\n */\n radius?: ImageRadius;\n\n /**\n * TODO - https://leaflink.atlassian.net/browse/GRO-204\n * A custom function used to resolve a URL string for the image\n */\n // loader?: () => string;\n }\n\n const PROVIDERS = {\n CLOUDINARY: 'cloudinary',\n STATIC: 'static',\n };\n const BREAKPOINTS = {\n md: getCssVar(CSS_VARS.SCREEN_MD),\n lg: getCssVar(CSS_VARS.SCREEN_LG),\n };\n const stashOptions = inject<StashProvideState>('stashOptions');\n const props = withDefaults(defineProps<ImageProps>(), {\n src: '',\n srcset: '',\n sizes: '',\n provider: null,\n radius: 'none',\n // loader: undefined, // TODO - https://leaflink.atlassian.net/browse/GRO-204\n });\n\n const attrs = computed(() => {\n const { src, ...attrs } = useAttrs();\n\n attrs.sizes = imgSizes.value;\n attrs.srcset = imgSrcset.value;\n\n return attrs;\n });\n\n const staticDomains = computed(() => stashOptions?.images?.staticDomains || []);\n\n const isStaticUrl = computed(() => {\n // return true if not an absolute url\n try {\n new URL(props.src);\n } catch (e) {\n return true;\n }\n\n // true if domain is whitelisted for static usage\n return isDomainValid(props.src, staticDomains.value);\n });\n\n const computedProvider = computed(() => {\n if (props.provider) {\n return props.provider;\n }\n\n if (stashOptions?.images?.provider && stashOptions.images.provider !== PROVIDERS.STATIC && !isStaticUrl.value) {\n return stashOptions.images.provider;\n }\n\n return PROVIDERS.STATIC;\n });\n\n const isStatic = computed(() => computedProvider.value === PROVIDERS.STATIC);\n\n const imgProvider = computed(() => providers[computedProvider.value]);\n\n const imgSrc = computed(() =>\n isStatic.value ? getProviderImage() : getProviderImage({ width: PRESET_SIZES.medium.width }),\n );\n\n const imgSizes = computed(() => (props.sizes || !isStatic.value ? getSizes() : undefined));\n\n const imgSrcset = computed(() => (props.sizes && !props.srcset && !isStatic.value ? getSources() : props.srcset));\n\n const parsedSizes = computed(() => {\n if (props.sizes) {\n return parseSizes(props.sizes);\n }\n\n if (!isStatic.value) {\n return parseSizes('lg:large');\n }\n\n return [];\n });\n\n function getProviderImage(modifiers: ImageModifiers = {}) {\n return imgProvider.value.getImageUrl(props.src, modifiers);\n }\n\n function getSources() {\n const appliedPresets = Object.entries(PRESET_SIZES).reduce((obj, [key, entry]) => {\n const isPreset = !!parsedSizes.value.find((size) => size.preset === key);\n\n if (isPreset || entry.alwaysIncluded) {\n obj[key] = entry;\n }\n\n return obj;\n }, {} as typeof PRESET_SIZES);\n\n return Object.values(appliedPresets)\n .map((size) => {\n const width = size.width;\n const src = getProviderImage({ width });\n\n return `${src} ${size.width}w`;\n })\n .join(', ');\n }\n\n function getSizes() {\n return parsedSizes.value.map((v) => `${v.media ? v.media + ' ' : ''}${v.size}`).join(', ');\n }\n\n function parseSizes(providedSizes: string) {\n const variants: ImageSizeVariant[] = [];\n const sizes = {\n default: '100vw',\n };\n\n // parse sizes and convert to object\n if (typeof providedSizes === 'string') {\n const definitions = providedSizes.split(/[\\s]+/).filter((size) => size);\n\n for (const entry of definitions) {\n const size = entry.split(':');\n\n if (size.length !== 2) {\n sizes['default'] = size[0].trim();\n continue;\n }\n\n sizes[size[0].trim()] = size[1].trim();\n }\n } else {\n throw new Error('`sizes` needs to be a string');\n }\n\n for (const key in sizes) {\n const screenMinWidth = parseInt(BREAKPOINTS[key] || 0);\n const sizeValue = sizes[key];\n const presetKey = PRESET_SIZES[sizeValue] ? sizeValue : undefined;\n let size = String(presetKey ? PRESET_SIZES[sizeValue].width : sizeValue);\n const isFluid = size.endsWith('vw');\n\n // default integers to pixels\n if (!isFluid && /^\\d+$/.test(size)) {\n size = `${size}px`;\n }\n\n // ignore invalid size\n if (!isFluid && !size.endsWith('px')) {\n continue;\n }\n\n const variant = {\n media: screenMinWidth ? `(min-width: ${screenMinWidth}px)` : '',\n preset: presetKey,\n screenMinWidth,\n size,\n };\n\n variants.push(variant);\n }\n\n variants.sort((v1, v2) => (v1.screenMinWidth > v2.screenMinWidth ? -1 : 1));\n\n return variants;\n }\n</script>\n\n<template>\n <img\n ref=\"img\"\n :key=\"imgSrc\"\n data-test=\"stash-image\"\n :class=\"{\n 'tw-rounded': props.radius === ImageRadiuses.Rounded,\n }\"\n :src=\"imgSrc\"\n v-bind=\"attrs\"\n />\n</template>\n"],"names":["createMapper","map","key","buildProviderUrl","formatter","value","keyMap","joinWith","valueMap","keyMapper","valueKey","modifiers","mapper","newKey","newVal","isDomainValid","str","domains","host","domain","BASE_URL","IMAGE_PROVIDER_URLS","convertHextoRGBFormat","operationsGenerator","defaultModifiers","getImageUrl","src","mergeModifiers","merge","operations","providers","cloudinary","staticProvider","PRESET_SIZES","ImageRadiuses","PROVIDERS","BREAKPOINTS","getCssVar","CSS_VARS","stashOptions","inject","attrs","computed","useAttrs","imgSizes","imgSrcset","staticDomains","_a","isStaticUrl","props","computedProvider","isStatic","imgProvider","imgSrc","getProviderImage","getSizes","getSources","parsedSizes","parseSizes","appliedPresets","obj","entry","size","width","v","providedSizes","variants","sizes","definitions","screenMinWidth","sizeValue","presetKey","isFluid","variant","v1","v2"],"mappings":";;;;;;;;AAoBA,SAASA,EAAaC,GAAU;AAE9B,SAAO,CAACC,MACCD,EAAIC,CAAG,KAAKA;AAEvB;AAKO,SAASC,EAAiB;AAAA,EAC/B,WAAAC,IAAY,CAACF,GAAKG,MAAU,GAAGH,CAAG,IAAIG,CAAK;AAAA,EAC3C,QAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW,CAAC;AACd,IAAwB,IAAI;AAC1B,QAAMC,IAAY,OAAOH,KAAW,aAAaA,IAASN,EAAaM,CAAM;AAE7E,gBAAO,KAAKE,CAAQ,EAAE,QAAQ,CAACE,MAAa;AAC1C,IAAI,OAAOF,EAASE,CAAQ,KAAM,eAChCF,EAASE,CAAQ,IAAIV,EAAaQ,EAASE,CAAQ,CAAC;AAAA,EACtD,CACD,GAEM,CAACC,IAAuC,OAC1B,OAAO,QAAQA,CAAS,EAAE,IAAI,CAAC,CAACT,GAAKG,CAAK,MAAM;AAC3D,UAAAO,IAASJ,EAASN,CAAG,GACrBW,IAASJ,EAAUP,CAAG;AAC5B,QAAIY,IAAST;AAET,WAAA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B;AAES,aAAAP,EAAA,KAAK,CAACQ,GAAIC,MAAQD,EAAG,iBAAiBC,EAAG,iBAAiB,KAAK,CAAE,GAEnET;AAAA,IACT;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"Image.js","sources":["../src/components/Image/providers/utils.ts","../src/components/Image/providers/cloudinary.ts","../src/components/Image/providers/static.ts","../src/components/Image/providers/index.ts","../src/components/Image/Image.vue"],"sourcesContent":["export interface ImageModifiers {\n format?: string;\n height?: number;\n width?: number;\n [key: string]: any /* eslint-disable-line @typescript-eslint/no-explicit-any */;\n}\n\nexport type ParamFormatter = (key: string, value: string) => string;\n\nexport type ParamMapper = { [key: string]: string } | ((key: string) => string);\n\nexport interface ProviderUrlBuilder {\n keyMap?: ParamMapper;\n formatter?: ParamFormatter;\n joinWith?: string;\n valueMap?: {\n [key: string]: ParamMapper;\n };\n}\n\nfunction createMapper(map: any) {\n /* eslint-disable-line @typescript-eslint/no-explicit-any */\n return (key: string) => {\n return map[key] || key;\n };\n}\n\n/**\n * Builds the parameterized Cloudinary url\n */\nexport function buildProviderUrl({\n formatter = (key, value) => `${key}=${value}`,\n keyMap,\n joinWith = '/',\n valueMap = {},\n}: ProviderUrlBuilder = {}) {\n const keyMapper = typeof keyMap === 'function' ? keyMap : createMapper(keyMap);\n\n Object.keys(valueMap).forEach((valueKey) => {\n if (typeof valueMap[valueKey] !== 'function') {\n valueMap[valueKey] = createMapper(valueMap[valueKey]);\n }\n });\n\n return (modifiers: { [key: string]: string } = {}) => {\n const operations = Object.entries(modifiers).map(([key, value]) => {\n const mapper = valueMap[key];\n const newKey = keyMapper(key);\n let newVal = value;\n\n if (typeof mapper === 'function') {\n newVal = mapper(modifiers[key]);\n }\n\n return formatter(newKey, newVal);\n });\n\n return operations.join(joinWith);\n };\n}\n\n/**\n * Checks if a (sub)domain is included in a list of acceptable domains\n * @param str the (sub)domain to check\n * @param domains an array of valid domains\n */\nexport function isDomainValid(str = '', domains: string[] = []): boolean {\n const url = new URL(str);\n const host = url.host;\n\n return domains.some((domain) => {\n if (domain === host) {\n return true;\n }\n\n return domain.endsWith(`.${host}`);\n });\n}\n","import merge from 'lodash-es/merge';\n\nimport { IMAGE_PROVIDER_URLS } from '../../../constants';\nimport { buildProviderUrl, ImageModifiers } from './utils';\n\nconst BASE_URL = IMAGE_PROVIDER_URLS.CLOUDINARY;\n\nconst convertHextoRGBFormat = (value: string) => (value.startsWith('#') ? value.replace('#', 'rgb_') : value);\n\n/**\n * Parameters (option and value pairs) that can be used in the <transformations> segment of the Cloudinary transformation URL.\n * Options and their respective values are connected by an underscore (eg `w_250` for width of 250px.).\n * Multiple parameters are comma separated (eg. `w_250,h_250`).\n *\n * `keyMap` maps the option to its option prefix.\n * `valueMap` is used for grouping options using the same `keyMap` value under a 'category', allowing for easier usage and custom labelling in the component context.\n *\n * Transformation URL structure:\n * https://cloudinary.com/documentation/transformation_reference\n *\n * Transformation URL parameters (options and values):\n * https://cloudinary.com/documentation/image_transformations#transformation_url_syntax\n *\n */\nexport const operationsGenerator = buildProviderUrl({\n keyMap: {\n fit: 'c',\n width: 'w',\n height: 'h',\n format: 'f',\n quality: 'q',\n background: 'b',\n dpr: 'dpr',\n },\n valueMap: {\n fit: {\n fill: 'fill',\n inside: 'pad',\n outside: 'lpad',\n cover: 'fit',\n contain: 'scale',\n },\n format: {\n jpeg: 'jpg',\n },\n background(value: string) {\n return convertHextoRGBFormat(value);\n },\n },\n joinWith: ',',\n formatter: (key, value) => `${key}_${value}`,\n});\n\n// Note: Not configurable via Image props (for now).\nconst defaultModifiers = {\n // defaulting to maintain original image format to reduce transformations\n // format: 'auto',\n quality: 'auto',\n};\n\nexport function getImageUrl(src: string, modifiers: Partial<ImageModifiers> = {}): string {\n const mergeModifiers = merge(defaultModifiers, modifiers);\n const operations = operationsGenerator(mergeModifiers);\n\n return `${BASE_URL}/${operations}/${src}`;\n}\n","export function getImageUrl(src = ''): string {\n return src;\n}\n","import * as cloudinary from './cloudinary';\nimport * as staticProvider from './static';\n\nexport default {\n cloudinary,\n static: staticProvider,\n};\n","<script lang=\"ts\">\n export const PRESET_SIZES = {\n xsmall: {\n alwaysIncluded: false,\n width: 160,\n },\n small: {\n alwaysIncluded: true,\n width: 338,\n },\n medium: {\n alwaysIncluded: true,\n width: 676,\n },\n large: {\n alwaysIncluded: true,\n width: 1352,\n },\n xlarge: {\n alwaysIncluded: false,\n width: 2704,\n },\n } as const;\n\n export enum ImageRadiuses {\n None = 'none',\n Rounded = 'rounded',\n }\n</script>\n\n<script setup lang=\"ts\">\n import { computed, inject, useAttrs } from 'vue';\n\n import { StashImageProviders, StashProvideState } from '../../../types/misc';\n import { SCREEN_SIZES } from '../../constants';\n import providers from './providers';\n import { ImageModifiers, isDomainValid } from './providers/utils';\n\n // interface ImagePresetSizes {\n // [size: string]: {\n // alwaysIncluded: boolean;\n // width: number;\n // }\n // }\n\n export interface ImageSizeVariant {\n media: string;\n preset?: keyof typeof PRESET_SIZES;\n screenMinWidth: number;\n size: string;\n }\n\n export type ImageRadius = `${ImageRadiuses}`;\n\n export interface ImageProps {\n /**\n * The path to the image you want to embed.\n */\n src: string;\n\n /**\n * Native srcset attribute.\n * One or more strings separated by commas, indicating possible image sources\n * Can only be used with provider=static, otherwise it's ignored and auto-generated with `sizes` usage\n */\n srcset?: string;\n\n /**\n * For specifying responsive sizes\n */\n sizes?: string;\n\n /**\n * Where the image is served from.\n * Optional, and when provided it forces the provider used.\n *\n * The provider is otherwise inherited from the Stash config `stashOptions.images.provider`, which defaults to `cloudinary`.\n *\n * When not provided, the provider is also inferred by `isStatic`:\n * - `static` for relative/absolute paths (`img/foo.jpg` or `/static/img/bar.jpg`), or when whitelisted absolute URLs are used (included in `staticOptions.images.staticDomains`).\n */\n provider?: StashImageProviders | null;\n\n /**\n * For applying border radius\n */\n radius?: ImageRadius;\n\n /**\n * TODO - https://leaflink.atlassian.net/browse/GRO-204\n * A custom function used to resolve a URL string for the image\n */\n // loader?: () => string;\n }\n\n const PROVIDERS = {\n CLOUDINARY: 'cloudinary',\n STATIC: 'static',\n };\n const BREAKPOINTS = {\n md: SCREEN_SIZES.md,\n lg: SCREEN_SIZES.lg,\n };\n const stashOptions = inject<StashProvideState>('stashOptions');\n const props = withDefaults(defineProps<ImageProps>(), {\n src: '',\n srcset: '',\n sizes: '',\n provider: null,\n radius: 'none',\n // loader: undefined, // TODO - https://leaflink.atlassian.net/browse/GRO-204\n });\n\n const attrs = computed(() => {\n const { src, ...attrs } = useAttrs();\n\n attrs.sizes = imgSizes.value;\n attrs.srcset = imgSrcset.value;\n\n return attrs;\n });\n\n const staticDomains = computed(() => stashOptions?.images?.staticDomains || []);\n\n const isStaticUrl = computed(() => {\n // return true if not an absolute url\n try {\n new URL(props.src);\n } catch (e) {\n return true;\n }\n\n // true if domain is whitelisted for static usage\n return isDomainValid(props.src, staticDomains.value);\n });\n\n const computedProvider = computed(() => {\n if (props.provider) {\n return props.provider;\n }\n\n if (stashOptions?.images?.provider && stashOptions.images.provider !== PROVIDERS.STATIC && !isStaticUrl.value) {\n return stashOptions.images.provider;\n }\n\n return PROVIDERS.STATIC;\n });\n\n const isStatic = computed(() => computedProvider.value === PROVIDERS.STATIC);\n\n const imgProvider = computed(() => providers[computedProvider.value]);\n\n const imgSrc = computed(() =>\n isStatic.value ? getProviderImage() : getProviderImage({ width: PRESET_SIZES.medium.width }),\n );\n\n const imgSizes = computed(() => (props.sizes || !isStatic.value ? getSizes() : undefined));\n\n const imgSrcset = computed(() => (props.sizes && !props.srcset && !isStatic.value ? getSources() : props.srcset));\n\n const parsedSizes = computed(() => {\n if (props.sizes) {\n return parseSizes(props.sizes);\n }\n\n if (!isStatic.value) {\n return parseSizes('lg:large');\n }\n\n return [];\n });\n\n function getProviderImage(modifiers: ImageModifiers = {}) {\n return imgProvider.value.getImageUrl(props.src, modifiers);\n }\n\n function getSources() {\n const appliedPresets = Object.entries(PRESET_SIZES).reduce((obj, [key, entry]) => {\n const isPreset = !!parsedSizes.value.find((size) => size.preset === key);\n\n if (isPreset || entry.alwaysIncluded) {\n obj[key] = entry;\n }\n\n return obj;\n }, {} as typeof PRESET_SIZES);\n\n return Object.values(appliedPresets)\n .map((size) => {\n const width = size.width;\n const src = getProviderImage({ width });\n\n return `${src} ${size.width}w`;\n })\n .join(', ');\n }\n\n function getSizes() {\n return parsedSizes.value.map((v) => `${v.media ? v.media + ' ' : ''}${v.size}`).join(', ');\n }\n\n function parseSizes(providedSizes: string) {\n const variants: ImageSizeVariant[] = [];\n const sizes = {\n default: '100vw',\n };\n\n // parse sizes and convert to object\n if (typeof providedSizes === 'string') {\n const definitions = providedSizes.split(/[\\s]+/).filter((size) => size);\n\n for (const entry of definitions) {\n const size = entry.split(':');\n\n if (size.length !== 2) {\n sizes['default'] = size[0].trim();\n continue;\n }\n\n sizes[size[0].trim()] = size[1].trim();\n }\n } else {\n throw new Error('`sizes` needs to be a string');\n }\n\n for (const key in sizes) {\n const screenMinWidth = parseInt(BREAKPOINTS[key] || 0);\n const sizeValue = sizes[key];\n const presetKey = PRESET_SIZES[sizeValue] ? sizeValue : undefined;\n let size = String(presetKey ? PRESET_SIZES[sizeValue].width : sizeValue);\n const isFluid = size.endsWith('vw');\n\n // default integers to pixels\n if (!isFluid && /^\\d+$/.test(size)) {\n size = `${size}px`;\n }\n\n // ignore invalid size\n if (!isFluid && !size.endsWith('px')) {\n continue;\n }\n\n const variant = {\n media: screenMinWidth ? `(min-width: ${screenMinWidth}px)` : '',\n preset: presetKey,\n screenMinWidth,\n size,\n };\n\n variants.push(variant);\n }\n\n variants.sort((v1, v2) => (v1.screenMinWidth > v2.screenMinWidth ? -1 : 1));\n\n return variants;\n }\n</script>\n\n<template>\n <img\n ref=\"img\"\n :key=\"imgSrc\"\n data-test=\"stash-image\"\n class=\"stash-image\"\n :class=\"{\n 'tw-rounded': props.radius === ImageRadiuses.Rounded,\n }\"\n :src=\"imgSrc\"\n v-bind=\"attrs\"\n />\n</template>\n"],"names":["createMapper","map","key","buildProviderUrl","formatter","value","keyMap","joinWith","valueMap","keyMapper","valueKey","modifiers","mapper","newKey","newVal","isDomainValid","str","domains","host","domain","BASE_URL","IMAGE_PROVIDER_URLS","convertHextoRGBFormat","operationsGenerator","defaultModifiers","getImageUrl","src","mergeModifiers","merge","operations","providers","cloudinary","staticProvider","PRESET_SIZES","ImageRadiuses","PROVIDERS","BREAKPOINTS","SCREEN_SIZES","stashOptions","inject","attrs","computed","useAttrs","imgSizes","imgSrcset","staticDomains","_a","isStaticUrl","props","computedProvider","isStatic","imgProvider","imgSrc","getProviderImage","getSizes","getSources","parsedSizes","parseSizes","appliedPresets","obj","entry","size","width","v","providedSizes","variants","sizes","definitions","screenMinWidth","sizeValue","presetKey","isFluid","variant","v1","v2"],"mappings":";;;AAoBA,SAASA,EAAaC,GAAU;AAE9B,SAAO,CAACC,MACCD,EAAIC,CAAG,KAAKA;AAEvB;AAKO,SAASC,EAAiB;AAAA,EAC/B,WAAAC,IAAY,CAACF,GAAKG,MAAU,GAAGH,CAAG,IAAIG,CAAK;AAAA,EAC3C,QAAAC;AAAA,EACA,UAAAC,IAAW;AAAA,EACX,UAAAC,IAAW,CAAC;AACd,IAAwB,IAAI;AAC1B,QAAMC,IAAY,OAAOH,KAAW,aAAaA,IAASN,EAAaM,CAAM;AAE7E,gBAAO,KAAKE,CAAQ,EAAE,QAAQ,CAACE,MAAa;AAC1C,IAAI,OAAOF,EAASE,CAAQ,KAAM,eAChCF,EAASE,CAAQ,IAAIV,EAAaQ,EAASE,CAAQ,CAAC;AAAA,EACtD,CACD,GAEM,CAACC,IAAuC,OAC1B,OAAO,QAAQA,CAAS,EAAE,IAAI,CAAC,CAACT,GAAKG,CAAK,MAAM;AAC3D,UAAAO,IAASJ,EAASN,CAAG,GACrBW,IAASJ,EAAUP,CAAG;AAC5B,QAAIY,IAAST;AAET,WAAA,OAAOO,KAAW,eACXE,IAAAF,EAAOD,EAAUT,CAAG,CAAC,IAGzBE,EAAUS,GAAQC,CAAM;AAAA,EAAA,CAChC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InlineEdit.js
CHANGED
|
@@ -5,9 +5,9 @@ import "./constants.js";
|
|
|
5
5
|
import "./locale.js";
|
|
6
6
|
import "lodash-es/get";
|
|
7
7
|
import "lodash-es/isNil";
|
|
8
|
-
import "./Field.vue_vue_type_script_setup_true_lang-
|
|
8
|
+
import "./Field.vue_vue_type_script_setup_true_lang-42ba3c5a.js";
|
|
9
9
|
import "lodash-es/uniqueId";
|
|
10
|
-
import "./Label.vue_vue_type_script_setup_true_lang-
|
|
10
|
+
import "./Label.vue_vue_type_script_setup_true_lang-4b02087f.js";
|
|
11
11
|
import "./Icon.js";
|
|
12
12
|
import "./index-79ce320f.js";
|
|
13
13
|
import "./Icon.vue_used_vue_type_style_index_0_lang.module-eb359559.js";
|