@studiolxd/brand 49.27.0 → 50.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +61 -0
- package/README.md +26 -4
- package/dist/_shared/assign-ref.js +6 -0
- package/dist/_shared/calendargrid.js +57 -57
- package/dist/_shared/datepicker.js +67 -65
- package/dist/_shared/default-render-link.js +7 -0
- package/dist/_shared/dialogsurface.js +1 -1
- package/dist/_shared/dropdownitems.js +14 -20
- package/dist/_shared/imagecropdialog.js +38 -441
- package/dist/_shared/overflow-focusable.js +15 -0
- package/dist/_shared/side-offset.js +13 -0
- package/dist/_shared/tokens.js +34 -132
- package/dist/_shared/useasyncoptions.js +30 -0
- package/dist/_types/atoms/Accordion/Accordion.d.ts +7 -1
- package/dist/_types/atoms/AsyncMultiSelect/AsyncMultiSelect.d.ts +8 -4
- package/dist/_types/atoms/AsyncSelect/AsyncSelect.d.ts +8 -4
- package/dist/_types/atoms/Autocomplete/Autocomplete.d.ts +10 -6
- package/dist/_types/atoms/CloseButton/CloseButton.d.ts +13 -3
- package/dist/_types/atoms/Fieldset/Fieldset.d.ts +1 -1
- package/dist/_types/atoms/InputPhone/InputPhone.d.ts +2 -0
- package/dist/_types/atoms/MultiSelect/MultiSelect.d.ts +11 -10
- package/dist/_types/atoms/Select/Select.d.ts +6 -0
- package/dist/_types/atoms/Skeleton/Skeleton.d.ts +1 -1
- package/dist/_types/atoms/Spinner/Spinner.d.ts +3 -1
- package/dist/_types/atoms/TypingIndicator/TypingIndicator.d.ts +3 -1
- package/dist/_types/atoms/_shared/useAsyncOptions.d.ts +36 -0
- package/dist/_types/constants/assign-ref.d.ts +12 -0
- package/dist/_types/constants/default-render-link.d.ts +13 -0
- package/dist/_types/constants/overflow-focusable.d.ts +15 -0
- package/dist/_types/constants/side-offset.d.ts +18 -0
- package/dist/_types/email/EmailLayout.d.ts +38 -21
- package/dist/_types/messages/BrandMessages.d.ts +8 -2
- package/dist/_types/messages/index.d.ts +1 -1
- package/dist/_types/molecules/AppLauncher/AppLauncher.d.ts +9 -3
- package/dist/_types/molecules/Calendar/Calendar.d.ts +10 -1
- package/dist/_types/molecules/CalendarPlanner/CalendarPlanner.d.ts +43 -13
- package/dist/_types/molecules/CalendarRoster/CalendarRoster.d.ts +10 -2
- package/dist/_types/molecules/ContextMenu/ContextMenu.d.ts +8 -1
- package/dist/_types/molecules/DatePicker/DatePicker.d.ts +6 -0
- package/dist/_types/molecules/DateTimeField/DateTimeField.d.ts +2 -0
- package/dist/_types/molecules/DocsSearch/DocsSearch.d.ts +2 -2
- package/dist/_types/molecules/FloatingToolbar/FloatingToolbar.d.ts +83 -0
- package/dist/_types/molecules/FormField/FormField.d.ts +5 -6
- package/dist/_types/molecules/LanguageSwitcher/LanguageSwitcher.d.ts +7 -3
- package/dist/_types/molecules/LoadingRegion/LoadingRegion.d.ts +12 -4
- package/dist/_types/molecules/Modal/Modal.d.ts +10 -4
- package/dist/_types/molecules/OrgSwitcher/OrgSwitcher.d.ts +7 -1
- package/dist/_types/molecules/PasswordField/PasswordField.d.ts +9 -2
- package/dist/_types/molecules/PrevNextNav/PrevNextNav.d.ts +3 -1
- package/dist/_types/molecules/RecurrenceField/RecurrenceField.d.ts +6 -1
- package/dist/_types/molecules/SidebarNav/SidebarNav.d.ts +18 -2
- package/dist/_types/molecules/SiteNav/SiteNav.d.ts +4 -1
- package/dist/_types/molecules/StatTile/StatTile.d.ts +15 -1
- package/dist/_types/molecules/Table/Table.d.ts +1 -1
- package/dist/_types/molecules/ThemeSwitcher/ThemeSwitcher.d.ts +38 -3
- package/dist/_types/molecules/Toast/Toaster.d.ts +8 -0
- package/dist/_types/molecules/UserMenu/UserMenu.d.ts +7 -1
- package/dist/_types/molecules/_shared/calendarGrid.d.ts +15 -2
- package/dist/_types/molecules/_shared/dialogSurface.d.ts +6 -1
- package/dist/_types/molecules/_shared/dropdownItems.d.ts +0 -2
- package/dist/_types/sections/AppHeader/AppHeader.d.ts +3 -1
- package/dist/_types/sections/AppShell/AppShell.d.ts +6 -1
- package/dist/_types/sections/LegalFooter/LegalFooter.d.ts +7 -1
- package/dist/_types/sections/Sidebar/Sidebar.d.ts +3 -1
- package/dist/_types/sections/SiteFooter/SiteFooter.d.ts +6 -2
- package/dist/_types/sections/SiteHeader/SiteHeader.d.ts +2 -2
- package/dist/_types/templates/ConnectorAuth/ConnectorAuthShell.d.ts +5 -2
- package/dist/_types/templates/ConnectorAuth/ConnectorConsentPage.d.ts +1 -1
- package/dist/_types/templates/ConnectorAuth/ConnectorExternalSignInPage.d.ts +1 -1
- package/dist/_types/templates/ConnectorAuth/ConnectorRejectionPage.d.ts +1 -1
- package/dist/_types/templates/ConnectorAuth/ConnectorSignInPage.d.ts +1 -1
- package/dist/_types/templates/ErrorPage/ErrorPage.d.ts +7 -1
- package/dist/_types/templates/NotFoundPage/NotFoundPage.d.ts +7 -1
- package/dist/_types/templates/PublicPageShell/PublicPageShell.d.ts +6 -0
- package/dist/accordion.css +1 -1
- package/dist/accordion.js +6 -5
- package/dist/alert.css +1 -1
- package/dist/app-header.js +16 -21
- package/dist/app-launcher.css +1 -1
- package/dist/app-launcher.js +29 -21
- package/dist/app-shell.js +43 -43
- package/dist/async-multi-select.css +1 -1
- package/dist/async-multi-select.js +104 -173
- package/dist/async-select.css +1 -1
- package/dist/async-select.js +81 -137
- package/dist/autocomplete.css +1 -1
- package/dist/autocomplete.js +76 -115
- package/dist/brand.css +80 -990
- package/dist/breadcrumb.js +11 -16
- package/dist/button.css +1 -1
- package/dist/calendar-planner.css +1 -1
- package/dist/calendar-planner.js +100 -95
- package/dist/calendar-roster.css +1 -1
- package/dist/calendar-roster.js +69 -61
- package/dist/calendar.css +1 -1
- package/dist/calendar.js +86 -85
- package/dist/card.css +1 -1
- package/dist/card.js +42 -41
- package/dist/chart.css +1 -1
- package/dist/chat-shell.js +48 -47
- package/dist/checkbox.css +1 -1
- package/dist/close-button.js +14 -12
- package/dist/command-palette.css +1 -1
- package/dist/connector-consent-page.js +19 -18
- package/dist/connector-external-sign-in-page.js +6 -5
- package/dist/connector-rejection-page.js +5 -4
- package/dist/connector-sign-in-page.js +10 -9
- package/dist/consent.css +1 -1
- package/dist/context-menu.js +3 -2
- package/dist/conversation-list.css +1 -1
- package/dist/conversation-thread.css +1 -1
- package/dist/conversation-thread.js +1 -0
- package/dist/data-table.js +74 -1625
- package/dist/date-time-field.js +7 -6
- package/dist/docs-search.js +36 -38
- package/dist/email.js +10 -7
- package/dist/error-page.js +2 -2
- package/dist/fieldset.css +1 -1
- package/dist/figure.js +1 -0
- package/dist/file-upload.css +1 -1
- package/dist/file-upload.js +48 -50
- package/dist/floating-toolbar.css +1 -0
- package/dist/floating-toolbar.js +64 -0
- package/dist/form-field.js +55 -53
- package/dist/imagecropdialog.css +1 -1
- package/dist/input-phone.css +1 -1
- package/dist/input-phone.js +30 -31
- package/dist/input.css +1 -1
- package/dist/label.css +1 -1
- package/dist/language-switcher.js +37 -44
- package/dist/legal-footer.js +12 -17
- package/dist/loading-region.css +1 -1
- package/dist/loading-region.js +8 -8
- package/dist/menu.css +1 -1
- package/dist/menu.js +4 -3
- package/dist/message-bubble.css +1 -1
- package/dist/message-composer.css +1 -1
- package/dist/modal.css +1 -1
- package/dist/modal.js +9 -9
- package/dist/multi-select.css +1 -1
- package/dist/multi-select.js +104 -172
- package/dist/not-found-page.js +8 -5
- package/dist/notification-list.js +16 -21
- package/dist/notification-panel.js +34 -46
- package/dist/number-badge.css +1 -1
- package/dist/number-input.css +1 -1
- package/dist/org-switcher.css +1 -1
- package/dist/org-switcher.js +13 -11
- package/dist/password-field.js +40 -39
- package/dist/popover.css +1 -1
- package/dist/popover.js +9 -15
- package/dist/prev-next-nav.js +8 -7
- package/dist/public-page-shell.js +7 -6
- package/dist/radio.css +1 -1
- package/dist/recurrence-field.css +1 -1
- package/dist/recurrence-field.js +38 -37
- package/dist/select.css +1 -1
- package/dist/select.js +3 -2
- package/dist/sheet.css +1 -1
- package/dist/sidebar-nav.css +1 -1
- package/dist/sidebar-nav.js +75 -70
- package/dist/sidebar.css +1 -1
- package/dist/sidebar.js +46 -42
- package/dist/site-footer.js +28 -28
- package/dist/site-header.js +39 -44
- package/dist/site-nav.js +10 -19
- package/dist/site-search.js +34 -36
- package/dist/site-shell.js +17 -16
- package/dist/skeleton.js +8 -6
- package/dist/sortable.js +20 -19
- package/dist/spinner.css +1 -1
- package/dist/spinner.js +12 -9
- package/dist/stat-tile.js +24 -26
- package/dist/switcher.css +1 -1
- package/dist/table.css +1 -1
- package/dist/table.js +57 -45
- package/dist/textarea.css +1 -1
- package/dist/theme-switcher.js +57 -56
- package/dist/toaster.css +1 -1
- package/dist/toggle.css +1 -1
- package/dist/tokens.css +78 -989
- package/dist/tooltip.css +1 -1
- package/dist/tooltip.js +20 -27
- package/dist/typing-indicator.css +1 -1
- package/dist/typing-indicator.js +4 -4
- package/dist/user-menu.css +1 -1
- package/dist/user-menu.js +38 -45
- package/dist/visuallyhidden.css +1 -1
- package/package.json +26 -14
- package/src/tokens/components/async-multi-select.css +4 -0
- package/src/tokens/components/async-select.css +3 -0
- package/src/tokens/components/autocomplete.css +1 -0
- package/src/tokens/components/breadcrumb.css +0 -2
- package/src/tokens/components/button.css +0 -23
- package/src/tokens/components/control.css +0 -4
- package/src/tokens/components/file-upload.css +0 -4
- package/src/tokens/components/radio.css +2 -0
- package/src/tokens/components/site-header.css +0 -1
- package/src/tokens/components/spinner.css +3 -3
- package/src/tokens/index.css +5 -7
- package/src/tokens/molecules/async-multi-select-field.css +0 -6
- package/src/tokens/molecules/async-select-field.css +0 -6
- package/src/tokens/molecules/autocomplete-field.css +0 -5
- package/src/tokens/molecules/avatar-upload.css +0 -6
- package/src/tokens/molecules/calendar-roster.css +5 -0
- package/src/tokens/molecules/chart.css +0 -3
- package/src/tokens/molecules/checkbox-field.css +0 -6
- package/src/tokens/molecules/consent.css +1 -0
- package/src/tokens/molecules/conversation-thread.css +10 -0
- package/src/tokens/molecules/date-picker-field.css +0 -6
- package/src/tokens/molecules/date-time-field.css +0 -6
- package/src/tokens/molecules/dropdown-field.css +0 -6
- package/src/tokens/molecules/file-upload-field.css +0 -6
- package/src/tokens/molecules/floating-toolbar.css +18 -0
- package/src/tokens/molecules/floating-toolbar.ts +4 -0
- package/src/tokens/molecules/input-field.css +0 -1
- package/src/tokens/molecules/input-phone-field.css +0 -6
- package/src/tokens/molecules/modal.css +1 -0
- package/src/tokens/molecules/multi-select-field.css +0 -6
- package/src/tokens/molecules/number-input-field.css +0 -6
- package/src/tokens/molecules/otp-field.css +0 -6
- package/src/tokens/molecules/radio-field.css +0 -6
- package/src/tokens/molecules/recurrence-field.css +1 -0
- package/src/tokens/molecules/select-field.css +0 -6
- package/src/tokens/molecules/sidebar-nav.css +0 -6
- package/src/tokens/molecules/site-search.css +0 -2
- package/src/tokens/molecules/switcher-field.css +0 -1
- package/src/tokens/molecules/table.css +1 -0
- package/src/tokens/molecules/textarea-field.css +0 -6
- package/src/tokens/molecules/time-field.css +0 -6
- package/src/tokens/scss/_index.legacy.scss +1 -0
- package/src/tokens/scss/_index.scss +1 -0
- package/src/tokens/scss/components/_async-multi-select.scss +4 -0
- package/src/tokens/scss/components/_async-select.scss +3 -0
- package/src/tokens/scss/components/_autocomplete.scss +1 -0
- package/src/tokens/scss/components/_breadcrumb.scss +0 -2
- package/src/tokens/scss/components/_button.scss +0 -23
- package/src/tokens/scss/components/_control.scss +0 -4
- package/src/tokens/scss/components/_file-upload.scss +0 -4
- package/src/tokens/scss/components/_site-header.scss +0 -1
- package/src/tokens/scss/components/_spinner.scss +3 -3
- package/src/tokens/scss/molecules/_async-multi-select-field.scss +0 -5
- package/src/tokens/scss/molecules/_async-select-field.scss +0 -5
- package/src/tokens/scss/molecules/_autocomplete-field.scss +0 -5
- package/src/tokens/scss/molecules/_avatar-upload.scss +0 -5
- package/src/tokens/scss/molecules/_calendar-roster.scss +4 -0
- package/src/tokens/scss/molecules/_chart.scss +0 -2
- package/src/tokens/scss/molecules/_checkbox-field.scss +0 -5
- package/src/tokens/scss/molecules/_consent.scss +1 -0
- package/src/tokens/scss/molecules/_conversation-thread.scss +3 -0
- package/src/tokens/scss/molecules/_date-picker-field.scss +0 -5
- package/src/tokens/scss/molecules/_date-time-field.scss +0 -5
- package/src/tokens/scss/molecules/_dropdown-field.scss +0 -5
- package/src/tokens/scss/molecules/_file-upload-field.scss +0 -5
- package/src/tokens/scss/molecules/_floating-toolbar.scss +15 -0
- package/src/tokens/scss/molecules/_input-field.scss +0 -1
- package/src/tokens/scss/molecules/_input-phone-field.scss +0 -5
- package/src/tokens/scss/molecules/_modal.scss +1 -0
- package/src/tokens/scss/molecules/_multi-select-field.scss +0 -5
- package/src/tokens/scss/molecules/_number-input-field.scss +0 -5
- package/src/tokens/scss/molecules/_otp-field.scss +0 -5
- package/src/tokens/scss/molecules/_radio-field.scss +0 -5
- package/src/tokens/scss/molecules/_recurrence-field.scss +1 -0
- package/src/tokens/scss/molecules/_select-field.scss +0 -5
- package/src/tokens/scss/molecules/_sidebar-nav.scss +0 -4
- package/src/tokens/scss/molecules/_site-search.scss +0 -2
- package/src/tokens/scss/molecules/_switcher-field.scss +0 -1
- package/src/tokens/scss/molecules/_table.scss +1 -0
- package/src/tokens/scss/molecules/_textarea-field.scss +0 -5
- package/src/tokens/scss/molecules/_time-field.scss +0 -5
- package/src/tokens/surface-dark-derived.css +2 -1
- package/src/tokens/surface-invert.css +15 -21
- package/src/tokens/surface-public.css +0 -19
- package/src/tokens/tokens.json +34 -132
- package/CHANGELOG.md +0 -8140
- package/dist/_types/data/home.d.ts +0 -83
- package/dist/_types/pages/Auth/AuthPage.d.ts +0 -24
- package/dist/_types/pages/Onboarding/OnboardingPage.d.ts +0 -37
- package/dist/_types/pages/Status/StatusPage.d.ts +0 -37
- package/dist/_types/pages/Status/_datos.d.ts +0 -47
- package/src/tokens/surface-light.css +0 -782
- package/src/tokens/utils.test.ts +0 -86
|
@@ -4,414 +4,11 @@ import { Spinner as t } from "../spinner.js";
|
|
|
4
4
|
import { Button as n } from "../button.js";
|
|
5
5
|
import { Alert as r } from "../alert.js";
|
|
6
6
|
import { Modal as i } from "../modal.js";
|
|
7
|
-
import
|
|
8
|
-
import { Fragment as
|
|
9
|
-
|
|
10
|
-
var p = {
|
|
11
|
-
x: 0,
|
|
12
|
-
y: 0,
|
|
13
|
-
width: 0,
|
|
14
|
-
height: 0,
|
|
15
|
-
unit: "px"
|
|
16
|
-
}, m = (e, t, n) => Math.min(Math.max(e, t), n), h = (...e) => e.filter((e) => e && typeof e == "string").join(" "), g = (e, t) => e === t || e.width === t.width && e.height === t.height && e.x === t.x && e.y === t.y && e.unit === t.unit;
|
|
17
|
-
function _(e, t, n, r) {
|
|
18
|
-
let i = b(e, n, r);
|
|
19
|
-
return e.width && (i.height = i.width / t), e.height && (i.width = i.height * t), i.y + i.height > r && (i.height = r - i.y, i.width = i.height * t), i.x + i.width > n && (i.width = n - i.x, i.height = i.width / t), e.unit === "%" ? y(i, n, r) : i;
|
|
20
|
-
}
|
|
21
|
-
function v(e, t, n) {
|
|
22
|
-
let r = b(e, t, n);
|
|
23
|
-
return r.x = (t - r.width) / 2, r.y = (n - r.height) / 2, e.unit === "%" ? y(r, t, n) : r;
|
|
24
|
-
}
|
|
25
|
-
function y(e, t, n) {
|
|
26
|
-
return e.unit === "%" ? {
|
|
27
|
-
...p,
|
|
28
|
-
...e,
|
|
29
|
-
unit: "%"
|
|
30
|
-
} : {
|
|
31
|
-
unit: "%",
|
|
32
|
-
x: e.x ? e.x / t * 100 : 0,
|
|
33
|
-
y: e.y ? e.y / n * 100 : 0,
|
|
34
|
-
width: e.width ? e.width / t * 100 : 0,
|
|
35
|
-
height: e.height ? e.height / n * 100 : 0
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
function b(e, t, n) {
|
|
39
|
-
return !e.unit || e.unit === "px" ? {
|
|
40
|
-
...p,
|
|
41
|
-
...e,
|
|
42
|
-
unit: "px"
|
|
43
|
-
} : {
|
|
44
|
-
unit: "px",
|
|
45
|
-
x: e.x ? e.x * t / 100 : 0,
|
|
46
|
-
y: e.y ? e.y * n / 100 : 0,
|
|
47
|
-
width: e.width ? e.width * t / 100 : 0,
|
|
48
|
-
height: e.height ? e.height * n / 100 : 0
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
function x(e, t, n, r, i, a = 0, o = 0, s = r, c = i) {
|
|
52
|
-
let l = { ...e }, u = Math.min(a, r), d = Math.min(o, i), f = Math.min(s, r), p = Math.min(c, i);
|
|
53
|
-
t && (t > 1 ? (u = o ? o * t : u, d = u / t, f = s * t) : (d = a ? a / t : d, u = d * t, p = c / t)), l.y < 0 && (l.height = Math.max(l.height + l.y, d), l.y = 0), l.x < 0 && (l.width = Math.max(l.width + l.x, u), l.x = 0);
|
|
54
|
-
let m = r - (l.x + l.width);
|
|
55
|
-
m < 0 && (l.x = Math.min(l.x, r - u), l.width += m);
|
|
56
|
-
let h = i - (l.y + l.height);
|
|
57
|
-
if (h < 0 && (l.y = Math.min(l.y, i - d), l.height += h), l.width < u && ((n === "sw" || n == "nw") && (l.x -= u - l.width), l.width = u), l.height < d && ((n === "nw" || n == "ne") && (l.y -= d - l.height), l.height = d), l.width > f && ((n === "sw" || n == "nw") && (l.x -= f - l.width), l.width = f), l.height > p && ((n === "nw" || n == "ne") && (l.y -= p - l.height), l.height = p), t) {
|
|
58
|
-
let e = l.width / l.height;
|
|
59
|
-
if (e < t) {
|
|
60
|
-
let e = Math.max(l.width / t, d);
|
|
61
|
-
(n === "nw" || n == "ne") && (l.y -= e - l.height), l.height = e;
|
|
62
|
-
} else if (e > t) {
|
|
63
|
-
let e = Math.max(l.height * t, u);
|
|
64
|
-
(n === "sw" || n == "nw") && (l.x -= e - l.width), l.width = e;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
return l;
|
|
68
|
-
}
|
|
69
|
-
function S(e, t, n, r) {
|
|
70
|
-
let i = { ...e };
|
|
71
|
-
return t === "ArrowLeft" ? r === "nw" ? (i.x -= n, i.y -= n, i.width += n, i.height += n) : r === "w" ? (i.x -= n, i.width += n) : r === "sw" ? (i.x -= n, i.width += n, i.height += n) : r === "ne" ? (i.y += n, i.width -= n, i.height -= n) : r === "e" ? i.width -= n : r === "se" && (i.width -= n, i.height -= n) : t === "ArrowRight" && (r === "nw" ? (i.x += n, i.y += n, i.width -= n, i.height -= n) : r === "w" ? (i.x += n, i.width -= n) : r === "sw" ? (i.x += n, i.width -= n, i.height -= n) : r === "ne" ? (i.y -= n, i.width += n, i.height += n) : r === "e" ? i.width += n : r === "se" && (i.width += n, i.height += n)), t === "ArrowUp" ? r === "nw" ? (i.x -= n, i.y -= n, i.width += n, i.height += n) : r === "n" ? (i.y -= n, i.height += n) : r === "ne" ? (i.y -= n, i.width += n, i.height += n) : r === "sw" ? (i.x += n, i.width -= n, i.height -= n) : r === "s" ? i.height -= n : r === "se" && (i.width -= n, i.height -= n) : t === "ArrowDown" && (r === "nw" ? (i.x += n, i.y += n, i.width -= n, i.height -= n) : r === "n" ? (i.y += n, i.height -= n) : r === "ne" ? (i.y += n, i.width -= n, i.height -= n) : r === "sw" ? (i.x -= n, i.width += n, i.height += n) : r === "s" ? i.height += n : r === "se" && (i.width += n, i.height += n)), i;
|
|
72
|
-
}
|
|
73
|
-
var C = {
|
|
74
|
-
capture: !0,
|
|
75
|
-
passive: !1
|
|
76
|
-
}, w = 0, T = class e extends o {
|
|
77
|
-
static xOrds = ["e", "w"];
|
|
78
|
-
static yOrds = ["n", "s"];
|
|
79
|
-
static xyOrds = [
|
|
80
|
-
"nw",
|
|
81
|
-
"ne",
|
|
82
|
-
"se",
|
|
83
|
-
"sw"
|
|
84
|
-
];
|
|
85
|
-
static nudgeStep = 1;
|
|
86
|
-
static nudgeStepMedium = 10;
|
|
87
|
-
static nudgeStepLarge = 100;
|
|
88
|
-
static defaultProps = { ariaLabels: {
|
|
89
|
-
cropArea: "Use the arrow keys to move the crop selection area",
|
|
90
|
-
nwDragHandle: "Use the arrow keys to move the north west drag handle to change the crop selection area",
|
|
91
|
-
nDragHandle: "Use the up and down arrow keys to move the north drag handle to change the crop selection area",
|
|
92
|
-
neDragHandle: "Use the arrow keys to move the north east drag handle to change the crop selection area",
|
|
93
|
-
eDragHandle: "Use the up and down arrow keys to move the east drag handle to change the crop selection area",
|
|
94
|
-
seDragHandle: "Use the arrow keys to move the south east drag handle to change the crop selection area",
|
|
95
|
-
sDragHandle: "Use the up and down arrow keys to move the south drag handle to change the crop selection area",
|
|
96
|
-
swDragHandle: "Use the arrow keys to move the south west drag handle to change the crop selection area",
|
|
97
|
-
wDragHandle: "Use the up and down arrow keys to move the west drag handle to change the crop selection area"
|
|
98
|
-
} };
|
|
99
|
-
get document() {
|
|
100
|
-
return document;
|
|
101
|
-
}
|
|
102
|
-
docMoveBound = !1;
|
|
103
|
-
mouseDownOnCrop = !1;
|
|
104
|
-
dragStarted = !1;
|
|
105
|
-
evData = {
|
|
106
|
-
startClientX: 0,
|
|
107
|
-
startClientY: 0,
|
|
108
|
-
startCropX: 0,
|
|
109
|
-
startCropY: 0,
|
|
110
|
-
clientX: 0,
|
|
111
|
-
clientY: 0,
|
|
112
|
-
isResize: !0
|
|
113
|
-
};
|
|
114
|
-
componentRef = s();
|
|
115
|
-
mediaRef = s();
|
|
116
|
-
resizeObserver;
|
|
117
|
-
initChangeCalled = !1;
|
|
118
|
-
instanceId = `rc-${w++}`;
|
|
119
|
-
state = {
|
|
120
|
-
cropIsActive: !1,
|
|
121
|
-
newCropIsBeingDrawn: !1
|
|
122
|
-
};
|
|
123
|
-
getBox() {
|
|
124
|
-
let e = this.mediaRef.current;
|
|
125
|
-
if (!e) return {
|
|
126
|
-
x: 0,
|
|
127
|
-
y: 0,
|
|
128
|
-
width: 0,
|
|
129
|
-
height: 0
|
|
130
|
-
};
|
|
131
|
-
let { x: t, y: n, width: r, height: i } = e.getBoundingClientRect();
|
|
132
|
-
return {
|
|
133
|
-
x: t,
|
|
134
|
-
y: n,
|
|
135
|
-
width: r,
|
|
136
|
-
height: i
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
componentDidUpdate(e) {
|
|
140
|
-
let { crop: t, onComplete: n } = this.props;
|
|
141
|
-
if (n && !e.crop && t) {
|
|
142
|
-
let { width: e, height: r } = this.getBox();
|
|
143
|
-
e && r && n(b(t, e, r), y(t, e, r));
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
componentWillUnmount() {
|
|
147
|
-
this.resizeObserver && this.resizeObserver.disconnect(), this.unbindDocMove();
|
|
148
|
-
}
|
|
149
|
-
bindDocMove() {
|
|
150
|
-
this.docMoveBound ||= (this.document.addEventListener("pointermove", this.onDocPointerMove, C), this.document.addEventListener("pointerup", this.onDocPointerDone, C), this.document.addEventListener("pointercancel", this.onDocPointerDone, C), !0);
|
|
151
|
-
}
|
|
152
|
-
unbindDocMove() {
|
|
153
|
-
this.docMoveBound &&= (this.document.removeEventListener("pointermove", this.onDocPointerMove, C), this.document.removeEventListener("pointerup", this.onDocPointerDone, C), this.document.removeEventListener("pointercancel", this.onDocPointerDone, C), !1);
|
|
154
|
-
}
|
|
155
|
-
onCropPointerDown = (e) => {
|
|
156
|
-
let { crop: t, disabled: n } = this.props, r = this.getBox();
|
|
157
|
-
if (!t) return;
|
|
158
|
-
let i = b(t, r.width, r.height);
|
|
159
|
-
if (n) return;
|
|
160
|
-
e.cancelable && e.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
|
|
161
|
-
let a = e.target.dataset.ord, o = !!a, s = e.clientX, c = e.clientY, l = i.x, u = i.y;
|
|
162
|
-
if (a) {
|
|
163
|
-
let t = e.clientX - r.x, n = e.clientY - r.y, o = 0, d = 0;
|
|
164
|
-
a === "ne" || a == "e" ? (o = t - (i.x + i.width), d = n - i.y, l = i.x, u = i.y + i.height) : a === "se" || a === "s" ? (o = t - (i.x + i.width), d = n - (i.y + i.height), l = i.x, u = i.y) : a === "sw" || a == "w" ? (o = t - i.x, d = n - (i.y + i.height), l = i.x + i.width, u = i.y) : (a === "nw" || a == "n") && (o = t - i.x, d = n - i.y, l = i.x + i.width, u = i.y + i.height), s = l + r.x + o, c = u + r.y + d;
|
|
165
|
-
}
|
|
166
|
-
this.evData = {
|
|
167
|
-
startClientX: s,
|
|
168
|
-
startClientY: c,
|
|
169
|
-
startCropX: l,
|
|
170
|
-
startCropY: u,
|
|
171
|
-
clientX: e.clientX,
|
|
172
|
-
clientY: e.clientY,
|
|
173
|
-
isResize: o,
|
|
174
|
-
ord: a
|
|
175
|
-
}, this.mouseDownOnCrop = !0, this.setState({ cropIsActive: !0 });
|
|
176
|
-
};
|
|
177
|
-
onComponentPointerDown = (e) => {
|
|
178
|
-
let { crop: t, disabled: n, locked: r, keepSelection: i, onChange: a } = this.props, o = this.getBox();
|
|
179
|
-
if (n || r || i && t) return;
|
|
180
|
-
e.cancelable && e.preventDefault(), this.bindDocMove(), this.componentRef.current.focus({ preventScroll: !0 });
|
|
181
|
-
let s = e.clientX - o.x, c = e.clientY - o.y, l = {
|
|
182
|
-
unit: "px",
|
|
183
|
-
x: s,
|
|
184
|
-
y: c,
|
|
185
|
-
width: 0,
|
|
186
|
-
height: 0
|
|
187
|
-
};
|
|
188
|
-
this.evData = {
|
|
189
|
-
startClientX: e.clientX,
|
|
190
|
-
startClientY: e.clientY,
|
|
191
|
-
startCropX: s,
|
|
192
|
-
startCropY: c,
|
|
193
|
-
clientX: e.clientX,
|
|
194
|
-
clientY: e.clientY,
|
|
195
|
-
isResize: !0
|
|
196
|
-
}, this.mouseDownOnCrop = !0, a(b(l, o.width, o.height), y(l, o.width, o.height)), this.setState({
|
|
197
|
-
cropIsActive: !0,
|
|
198
|
-
newCropIsBeingDrawn: !0
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
onDocPointerMove = (e) => {
|
|
202
|
-
let { crop: t, disabled: n, onChange: r, onDragStart: i } = this.props, a = this.getBox();
|
|
203
|
-
if (n || !t || !this.mouseDownOnCrop) return;
|
|
204
|
-
e.cancelable && e.preventDefault(), this.dragStarted || (this.dragStarted = !0, i && i(e));
|
|
205
|
-
let { evData: o } = this;
|
|
206
|
-
o.clientX = e.clientX, o.clientY = e.clientY;
|
|
207
|
-
let s;
|
|
208
|
-
s = o.isResize ? this.resizeCrop() : this.dragCrop(), g(t, s) || r(b(s, a.width, a.height), y(s, a.width, a.height));
|
|
209
|
-
};
|
|
210
|
-
onComponentKeyDown = (t) => {
|
|
211
|
-
let { crop: n, disabled: r, onChange: i, onComplete: a } = this.props;
|
|
212
|
-
if (r) return;
|
|
213
|
-
let o = t.key, s = !1;
|
|
214
|
-
if (!n) return;
|
|
215
|
-
let c = this.getBox(), l = this.makePixelCrop(c), u = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? e.nudgeStepLarge : t.shiftKey ? e.nudgeStepMedium : e.nudgeStep;
|
|
216
|
-
if (o === "ArrowLeft" ? (l.x -= u, s = !0) : o === "ArrowRight" ? (l.x += u, s = !0) : o === "ArrowUp" ? (l.y -= u, s = !0) : o === "ArrowDown" && (l.y += u, s = !0), s) {
|
|
217
|
-
t.cancelable && t.preventDefault(), l.x = m(l.x, 0, c.width - l.width), l.y = m(l.y, 0, c.height - l.height);
|
|
218
|
-
let e = b(l, c.width, c.height), n = y(l, c.width, c.height);
|
|
219
|
-
i(e, n), a && a(e, n);
|
|
220
|
-
}
|
|
221
|
-
};
|
|
222
|
-
onHandlerKeyDown = (t, n) => {
|
|
223
|
-
let { aspect: r = 0, crop: i, disabled: a, minWidth: o = 0, minHeight: s = 0, maxWidth: c, maxHeight: l, onChange: u, onComplete: d } = this.props, f = this.getBox();
|
|
224
|
-
if (a || !i) return;
|
|
225
|
-
if (t.key === "ArrowUp" || t.key === "ArrowDown" || t.key === "ArrowLeft" || t.key === "ArrowRight") t.stopPropagation(), t.preventDefault();
|
|
226
|
-
else return;
|
|
227
|
-
let p = (navigator.platform.match("Mac") ? t.metaKey : t.ctrlKey) ? e.nudgeStepLarge : t.shiftKey ? e.nudgeStepMedium : e.nudgeStep, m = x(S(b(i, f.width, f.height), t.key, p, n), r, n, f.width, f.height, o, s, c, l);
|
|
228
|
-
if (!g(i, m)) {
|
|
229
|
-
let e = y(m, f.width, f.height);
|
|
230
|
-
u(m, e), d && d(m, e);
|
|
231
|
-
}
|
|
232
|
-
};
|
|
233
|
-
onDocPointerDone = (e) => {
|
|
234
|
-
let { crop: t, disabled: n, onComplete: r, onDragEnd: i } = this.props, a = this.getBox();
|
|
235
|
-
this.unbindDocMove(), !(n || !t) && this.mouseDownOnCrop && (this.mouseDownOnCrop = !1, this.dragStarted = !1, i && i(e), r && r(b(t, a.width, a.height), y(t, a.width, a.height)), this.setState({
|
|
236
|
-
cropIsActive: !1,
|
|
237
|
-
newCropIsBeingDrawn: !1
|
|
238
|
-
}));
|
|
239
|
-
};
|
|
240
|
-
onDragFocus = () => {
|
|
241
|
-
this.componentRef.current?.scrollTo(0, 0);
|
|
242
|
-
};
|
|
243
|
-
getCropStyle() {
|
|
244
|
-
let { crop: e } = this.props;
|
|
245
|
-
if (e) return {
|
|
246
|
-
top: `${e.y}${e.unit}`,
|
|
247
|
-
left: `${e.x}${e.unit}`,
|
|
248
|
-
width: `${e.width}${e.unit}`,
|
|
249
|
-
height: `${e.height}${e.unit}`
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
dragCrop() {
|
|
253
|
-
let { evData: e } = this, t = this.getBox(), n = this.makePixelCrop(t), r = e.clientX - e.startClientX, i = e.clientY - e.startClientY;
|
|
254
|
-
return n.x = m(e.startCropX + r, 0, t.width - n.width), n.y = m(e.startCropY + i, 0, t.height - n.height), n;
|
|
255
|
-
}
|
|
256
|
-
getPointRegion(e, t, n, r) {
|
|
257
|
-
let { evData: i } = this, a = i.clientX - e.x, o = i.clientY - e.y, s;
|
|
258
|
-
s = r && t ? t === "nw" || t === "n" || t === "ne" : o < i.startCropY;
|
|
259
|
-
let c;
|
|
260
|
-
return c = n && t ? t === "nw" || t === "w" || t === "sw" : a < i.startCropX, c ? s ? "nw" : "sw" : s ? "ne" : "se";
|
|
261
|
-
}
|
|
262
|
-
resolveMinDimensions(e, t, n = 0, r = 0) {
|
|
263
|
-
let i = Math.min(n, e.width), a = Math.min(r, e.height);
|
|
264
|
-
return !t || !i && !a ? [i, a] : t > 1 ? i ? [i, i / t] : [a * t, a] : a ? [a * t, a] : [i, i / t];
|
|
265
|
-
}
|
|
266
|
-
resizeCrop() {
|
|
267
|
-
let { evData: t } = this, { aspect: n = 0, maxWidth: r, maxHeight: i } = this.props, a = this.getBox(), [o, s] = this.resolveMinDimensions(a, n, this.props.minWidth, this.props.minHeight), c = this.makePixelCrop(a), l = this.getPointRegion(a, t.ord, o, s), u = t.ord || l, d = t.clientX - t.startClientX, f = t.clientY - t.startClientY;
|
|
268
|
-
(o && u === "nw" || u === "w" || u === "sw") && (d = Math.min(d, -o)), (s && u === "nw" || u === "n" || u === "ne") && (f = Math.min(f, -s));
|
|
269
|
-
let p = {
|
|
270
|
-
unit: "px",
|
|
271
|
-
x: 0,
|
|
272
|
-
y: 0,
|
|
273
|
-
width: 0,
|
|
274
|
-
height: 0
|
|
275
|
-
};
|
|
276
|
-
l === "ne" ? (p.x = t.startCropX, p.width = d, n ? (p.height = p.width / n, p.y = t.startCropY - p.height) : (p.height = Math.abs(f), p.y = t.startCropY - p.height)) : l === "se" ? (p.x = t.startCropX, p.y = t.startCropY, p.width = d, n ? p.height = p.width / n : p.height = f) : l === "sw" ? (p.x = t.startCropX + d, p.y = t.startCropY, p.width = Math.abs(d), n ? p.height = p.width / n : p.height = f) : l === "nw" && (p.x = t.startCropX + d, p.width = Math.abs(d), n ? (p.height = p.width / n, p.y = t.startCropY - p.height) : (p.height = Math.abs(f), p.y = t.startCropY + f));
|
|
277
|
-
let h = x(p, n, l, a.width, a.height, o, s, r, i);
|
|
278
|
-
return n || e.xyOrds.indexOf(u) > -1 ? c = h : e.xOrds.indexOf(u) > -1 ? (c.x = h.x, c.width = h.width) : e.yOrds.indexOf(u) > -1 && (c.y = h.y, c.height = h.height), c.x = m(c.x, 0, a.width - c.width), c.y = m(c.y, 0, a.height - c.height), c;
|
|
279
|
-
}
|
|
280
|
-
renderCropSelection() {
|
|
281
|
-
let { ariaLabels: t = e.defaultProps.ariaLabels, disabled: n, locked: r, renderSelectionAddon: i, ruleOfThirds: o, crop: s } = this.props, c = this.getCropStyle();
|
|
282
|
-
if (s) return /* @__PURE__ */ a.createElement("div", {
|
|
283
|
-
style: c,
|
|
284
|
-
className: "ReactCrop__crop-selection",
|
|
285
|
-
onPointerDown: this.onCropPointerDown,
|
|
286
|
-
"aria-label": t.cropArea,
|
|
287
|
-
tabIndex: 0,
|
|
288
|
-
onKeyDown: this.onComponentKeyDown,
|
|
289
|
-
role: "group"
|
|
290
|
-
}, !n && !r && /* @__PURE__ */ a.createElement("div", {
|
|
291
|
-
className: "ReactCrop__drag-elements",
|
|
292
|
-
onFocus: this.onDragFocus
|
|
293
|
-
}, /* @__PURE__ */ a.createElement("div", {
|
|
294
|
-
className: "ReactCrop__drag-bar ord-n",
|
|
295
|
-
"data-ord": "n"
|
|
296
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
297
|
-
className: "ReactCrop__drag-bar ord-e",
|
|
298
|
-
"data-ord": "e"
|
|
299
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
300
|
-
className: "ReactCrop__drag-bar ord-s",
|
|
301
|
-
"data-ord": "s"
|
|
302
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
303
|
-
className: "ReactCrop__drag-bar ord-w",
|
|
304
|
-
"data-ord": "w"
|
|
305
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
306
|
-
className: "ReactCrop__drag-handle ord-nw",
|
|
307
|
-
"data-ord": "nw",
|
|
308
|
-
tabIndex: 0,
|
|
309
|
-
"aria-label": t.nwDragHandle,
|
|
310
|
-
onKeyDown: (e) => this.onHandlerKeyDown(e, "nw"),
|
|
311
|
-
role: "button"
|
|
312
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
313
|
-
className: "ReactCrop__drag-handle ord-n",
|
|
314
|
-
"data-ord": "n",
|
|
315
|
-
tabIndex: 0,
|
|
316
|
-
"aria-label": t.nDragHandle,
|
|
317
|
-
onKeyDown: (e) => this.onHandlerKeyDown(e, "n"),
|
|
318
|
-
role: "button"
|
|
319
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
320
|
-
className: "ReactCrop__drag-handle ord-ne",
|
|
321
|
-
"data-ord": "ne",
|
|
322
|
-
tabIndex: 0,
|
|
323
|
-
"aria-label": t.neDragHandle,
|
|
324
|
-
onKeyDown: (e) => this.onHandlerKeyDown(e, "ne"),
|
|
325
|
-
role: "button"
|
|
326
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
327
|
-
className: "ReactCrop__drag-handle ord-e",
|
|
328
|
-
"data-ord": "e",
|
|
329
|
-
tabIndex: 0,
|
|
330
|
-
"aria-label": t.eDragHandle,
|
|
331
|
-
onKeyDown: (e) => this.onHandlerKeyDown(e, "e"),
|
|
332
|
-
role: "button"
|
|
333
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
334
|
-
className: "ReactCrop__drag-handle ord-se",
|
|
335
|
-
"data-ord": "se",
|
|
336
|
-
tabIndex: 0,
|
|
337
|
-
"aria-label": t.seDragHandle,
|
|
338
|
-
onKeyDown: (e) => this.onHandlerKeyDown(e, "se"),
|
|
339
|
-
role: "button"
|
|
340
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
341
|
-
className: "ReactCrop__drag-handle ord-s",
|
|
342
|
-
"data-ord": "s",
|
|
343
|
-
tabIndex: 0,
|
|
344
|
-
"aria-label": t.sDragHandle,
|
|
345
|
-
onKeyDown: (e) => this.onHandlerKeyDown(e, "s"),
|
|
346
|
-
role: "button"
|
|
347
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
348
|
-
className: "ReactCrop__drag-handle ord-sw",
|
|
349
|
-
"data-ord": "sw",
|
|
350
|
-
tabIndex: 0,
|
|
351
|
-
"aria-label": t.swDragHandle,
|
|
352
|
-
onKeyDown: (e) => this.onHandlerKeyDown(e, "sw"),
|
|
353
|
-
role: "button"
|
|
354
|
-
}), /* @__PURE__ */ a.createElement("div", {
|
|
355
|
-
className: "ReactCrop__drag-handle ord-w",
|
|
356
|
-
"data-ord": "w",
|
|
357
|
-
tabIndex: 0,
|
|
358
|
-
"aria-label": t.wDragHandle,
|
|
359
|
-
onKeyDown: (e) => this.onHandlerKeyDown(e, "w"),
|
|
360
|
-
role: "button"
|
|
361
|
-
})), i && /* @__PURE__ */ a.createElement("div", {
|
|
362
|
-
className: "ReactCrop__selection-addon",
|
|
363
|
-
onPointerDown: (e) => e.stopPropagation()
|
|
364
|
-
}, i(this.state)), o && /* @__PURE__ */ a.createElement(a.Fragment, null, /* @__PURE__ */ a.createElement("div", { className: "ReactCrop__rule-of-thirds-hz" }), /* @__PURE__ */ a.createElement("div", { className: "ReactCrop__rule-of-thirds-vt" })));
|
|
365
|
-
}
|
|
366
|
-
makePixelCrop(e) {
|
|
367
|
-
return b({
|
|
368
|
-
...p,
|
|
369
|
-
...this.props.crop || {}
|
|
370
|
-
}, e.width, e.height);
|
|
371
|
-
}
|
|
372
|
-
render() {
|
|
373
|
-
let { aspect: e, children: t, circularCrop: n, className: r, crop: i, disabled: o, locked: s, style: c, ruleOfThirds: l } = this.props, { cropIsActive: u, newCropIsBeingDrawn: d } = this.state, f = i ? this.renderCropSelection() : null, p = h("ReactCrop", r, u && "ReactCrop--active", o && "ReactCrop--disabled", s && "ReactCrop--locked", d && "ReactCrop--new-crop", i && e && "ReactCrop--fixed-aspect", i && n && "ReactCrop--circular-crop", i && l && "ReactCrop--rule-of-thirds", !this.dragStarted && i && !i.width && !i.height && "ReactCrop--invisible-crop", n && "ReactCrop--no-animate");
|
|
374
|
-
return /* @__PURE__ */ a.createElement("div", {
|
|
375
|
-
ref: this.componentRef,
|
|
376
|
-
className: p,
|
|
377
|
-
style: c
|
|
378
|
-
}, /* @__PURE__ */ a.createElement("div", {
|
|
379
|
-
ref: this.mediaRef,
|
|
380
|
-
className: "ReactCrop__child-wrapper",
|
|
381
|
-
onPointerDown: this.onComponentPointerDown
|
|
382
|
-
}, t), i ? /* @__PURE__ */ a.createElement("svg", {
|
|
383
|
-
className: "ReactCrop__crop-mask",
|
|
384
|
-
width: "100%",
|
|
385
|
-
height: "100%"
|
|
386
|
-
}, /* @__PURE__ */ a.createElement("defs", null, /* @__PURE__ */ a.createElement("mask", { id: `hole-${this.instanceId}` }, /* @__PURE__ */ a.createElement("rect", {
|
|
387
|
-
width: "100%",
|
|
388
|
-
height: "100%",
|
|
389
|
-
fill: "white"
|
|
390
|
-
}), n ? /* @__PURE__ */ a.createElement("ellipse", {
|
|
391
|
-
cx: `${i.x + i.width / 2}${i.unit}`,
|
|
392
|
-
cy: `${i.y + i.height / 2}${i.unit}`,
|
|
393
|
-
rx: `${i.width / 2}${i.unit}`,
|
|
394
|
-
ry: `${i.height / 2}${i.unit}`,
|
|
395
|
-
fill: "black"
|
|
396
|
-
}) : /* @__PURE__ */ a.createElement("rect", {
|
|
397
|
-
x: `${i.x}${i.unit}`,
|
|
398
|
-
y: `${i.y}${i.unit}`,
|
|
399
|
-
width: `${i.width}${i.unit}`,
|
|
400
|
-
height: `${i.height}${i.unit}`,
|
|
401
|
-
fill: "black"
|
|
402
|
-
}))), /* @__PURE__ */ a.createElement("rect", {
|
|
403
|
-
fill: "black",
|
|
404
|
-
fillOpacity: .5,
|
|
405
|
-
width: "100%",
|
|
406
|
-
height: "100%",
|
|
407
|
-
mask: `url(#hole-${this.instanceId})`
|
|
408
|
-
})) : void 0, f);
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
Math.PI / 180;
|
|
412
|
-
//#endregion
|
|
7
|
+
import { useRef as a, useState as o } from "react";
|
|
8
|
+
import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
9
|
+
import u, { centerCrop as d, makeAspectCrop as f } from "react-image-crop";
|
|
413
10
|
//#region src/stories/molecules/ImageCropDialog/crop.ts
|
|
414
|
-
async function
|
|
11
|
+
async function p(e, t, n = {}) {
|
|
415
12
|
let r = n.outputSize ?? 512, i = n.mimeType ?? "image/jpeg", a = n.quality ?? .9, o = document.createElement("canvas");
|
|
416
13
|
o.width = r, o.height = r;
|
|
417
14
|
let s = o.getContext("2d");
|
|
@@ -421,8 +18,8 @@ async function E(e, t, n = {}) {
|
|
|
421
18
|
o.toBlob((n) => n ? e(n) : t(/* @__PURE__ */ Error("Canvas toBlob returned null")), i, a);
|
|
422
19
|
});
|
|
423
20
|
}
|
|
424
|
-
function
|
|
425
|
-
return
|
|
21
|
+
function m(e, t, n) {
|
|
22
|
+
return d(f(t / n >= e ? {
|
|
426
23
|
unit: "%",
|
|
427
24
|
height: 100
|
|
428
25
|
} : {
|
|
@@ -432,66 +29,66 @@ function D(e, t, n) {
|
|
|
432
29
|
}
|
|
433
30
|
//#endregion
|
|
434
31
|
//#region src/stories/molecules/ImageCropDialog/ImageCropDialog.tsx
|
|
435
|
-
function
|
|
436
|
-
let k = e("imageCropDialog"), A =
|
|
437
|
-
|
|
32
|
+
function h({ sourceUrl: d, title: f, description: h, circularCrop: g = !1, aspect: _ = 1, outputSize: v = 512, outputMimeType: y, busy: b = !1, cancelLabel: x, confirmLabel: S, closeLabel: C, loadingLabel: w, errorMessage: T, onConfirm: E, onClose: D, className: O }) {
|
|
33
|
+
let k = e("imageCropDialog"), A = a(null), [j, M] = o(), [N, P] = o(), [F, I] = o("loading"), [L, R] = o(d);
|
|
34
|
+
d !== L && (R(d), I("loading"), M(void 0), P(void 0));
|
|
438
35
|
let z = () => {
|
|
439
|
-
M(void 0), P(void 0),
|
|
36
|
+
M(void 0), P(void 0), D();
|
|
440
37
|
}, B = async () => {
|
|
441
38
|
let e = A.current;
|
|
442
|
-
!e || !N || N.width === 0 || (await
|
|
443
|
-
mimeType:
|
|
444
|
-
outputSize:
|
|
39
|
+
!e || !N || N.width === 0 || (await E(await p(e, N, {
|
|
40
|
+
mimeType: y,
|
|
41
|
+
outputSize: v
|
|
445
42
|
})), z());
|
|
446
43
|
};
|
|
447
|
-
return /* @__PURE__ */
|
|
448
|
-
open:
|
|
44
|
+
return /* @__PURE__ */ c(i, {
|
|
45
|
+
open: d !== null,
|
|
449
46
|
onClose: () => {
|
|
450
|
-
|
|
47
|
+
b || z();
|
|
451
48
|
},
|
|
452
|
-
title:
|
|
453
|
-
...
|
|
454
|
-
...
|
|
49
|
+
title: f,
|
|
50
|
+
...C ? { closeLabel: C } : {},
|
|
51
|
+
...h == null ? {} : { description: h },
|
|
455
52
|
footerClassName: "image-crop-dialog__actions",
|
|
456
|
-
footer: /* @__PURE__ */
|
|
53
|
+
footer: /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ c(n, {
|
|
457
54
|
variant: "outline",
|
|
458
|
-
disabled:
|
|
55
|
+
disabled: b,
|
|
459
56
|
onClick: z,
|
|
460
|
-
children:
|
|
461
|
-
}), /* @__PURE__ */
|
|
462
|
-
disabled:
|
|
57
|
+
children: x
|
|
58
|
+
}), /* @__PURE__ */ c(n, {
|
|
59
|
+
disabled: b || !N?.width,
|
|
463
60
|
onClick: B,
|
|
464
|
-
children:
|
|
61
|
+
children: S
|
|
465
62
|
})] }),
|
|
466
|
-
children: /* @__PURE__ */
|
|
63
|
+
children: /* @__PURE__ */ c("div", {
|
|
467
64
|
className: ["image-crop-dialog", O].filter(Boolean).join(" "),
|
|
468
|
-
children: /* @__PURE__ */
|
|
65
|
+
children: /* @__PURE__ */ l("div", {
|
|
469
66
|
className: "image-crop-dialog__area",
|
|
470
67
|
children: [
|
|
471
|
-
F === "loading" && /* @__PURE__ */
|
|
68
|
+
F === "loading" && /* @__PURE__ */ c(t, {
|
|
472
69
|
size: "lg",
|
|
473
|
-
label: k("loading",
|
|
70
|
+
label: k("loading", w)
|
|
474
71
|
}),
|
|
475
|
-
F === "error" && /* @__PURE__ */
|
|
72
|
+
F === "error" && /* @__PURE__ */ c(r, {
|
|
476
73
|
variant: "error",
|
|
477
|
-
description: k("error",
|
|
74
|
+
description: k("error", T),
|
|
478
75
|
className: "image-crop-dialog__error"
|
|
479
76
|
}),
|
|
480
|
-
|
|
77
|
+
d && F !== "error" && /* @__PURE__ */ c(u, {
|
|
481
78
|
crop: j,
|
|
482
79
|
onChange: (e, t) => M(t),
|
|
483
80
|
onComplete: (e) => P(e),
|
|
484
|
-
aspect:
|
|
485
|
-
circularCrop:
|
|
81
|
+
aspect: _,
|
|
82
|
+
circularCrop: g,
|
|
486
83
|
minWidth: 64,
|
|
487
84
|
keepSelection: !0,
|
|
488
|
-
children: /* @__PURE__ */
|
|
85
|
+
children: /* @__PURE__ */ c("img", {
|
|
489
86
|
ref: A,
|
|
490
|
-
src:
|
|
87
|
+
src: d,
|
|
491
88
|
alt: "",
|
|
492
89
|
onLoad: (e) => {
|
|
493
90
|
let { width: t, height: n } = e.currentTarget;
|
|
494
|
-
I("ready"), M(
|
|
91
|
+
I("ready"), M(m(_, t, n));
|
|
495
92
|
},
|
|
496
93
|
onError: () => I("error")
|
|
497
94
|
})
|
|
@@ -502,4 +99,4 @@ function O({ sourceUrl: a, title: o, description: s, circularCrop: p = !1, aspec
|
|
|
502
99
|
});
|
|
503
100
|
}
|
|
504
101
|
//#endregion
|
|
505
|
-
export {
|
|
102
|
+
export { h as t };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useEffect as e, useState as t } from "react";
|
|
2
|
+
//#region src/stories/constants/overflow-focusable.ts
|
|
3
|
+
function n(n) {
|
|
4
|
+
let [r, i] = t(!1);
|
|
5
|
+
return e(() => {
|
|
6
|
+
let e = n.current;
|
|
7
|
+
if (!e || typeof ResizeObserver > "u") return;
|
|
8
|
+
let t = () => i(e.scrollWidth > e.clientWidth || e.scrollHeight > e.clientHeight);
|
|
9
|
+
t();
|
|
10
|
+
let r = new ResizeObserver(t);
|
|
11
|
+
return r.observe(e), e.firstElementChild && r.observe(e.firstElementChild), () => r.disconnect();
|
|
12
|
+
}, [n]), r;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { n as t };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
//#region src/stories/constants/side-offset.ts
|
|
2
|
+
function e(e, t = document.documentElement) {
|
|
3
|
+
let n = parseFloat(e);
|
|
4
|
+
return Number.isNaN(n) ? 0 : e.endsWith("rem") ? n * parseFloat(getComputedStyle(document.documentElement).fontSize) : e.endsWith("em") ? n * parseFloat(getComputedStyle(t).fontSize) : n;
|
|
5
|
+
}
|
|
6
|
+
function t(t) {
|
|
7
|
+
return () => {
|
|
8
|
+
let n = document.documentElement;
|
|
9
|
+
return e(getComputedStyle(n).getPropertyValue(t).trim(), n);
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { t };
|