@aglyn/shared-ui-jsx 1.0.0-beta.143
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 +201 -0
- package/README.md +7 -0
- package/package.json +63 -0
- package/src/index.d.ts +48 -0
- package/src/index.js +179 -0
- package/src/index.js.map +1 -0
- package/src/lib/components/aglyn-text.d.ts +86 -0
- package/src/lib/components/aglyn-text.js +44 -0
- package/src/lib/components/aglyn-text.js.map +1 -0
- package/src/lib/components/app-link.d.ts +74 -0
- package/src/lib/components/app-link.js +139 -0
- package/src/lib/components/app-link.js.map +1 -0
- package/src/lib/components/aspect-ratio.d.ts +59 -0
- package/src/lib/components/aspect-ratio.js +153 -0
- package/src/lib/components/aspect-ratio.js.map +1 -0
- package/src/lib/components/background-image.component.d.ts +30 -0
- package/src/lib/components/background-image.component.js +42 -0
- package/src/lib/components/background-image.component.js.map +1 -0
- package/src/lib/components/card-columns.d.ts +86 -0
- package/src/lib/components/card-columns.js +148 -0
- package/src/lib/components/card-columns.js.map +1 -0
- package/src/lib/components/card-display.d.ts +36 -0
- package/src/lib/components/card-display.js +158 -0
- package/src/lib/components/card-display.js.map +1 -0
- package/src/lib/components/card-list-item.d.ts +35 -0
- package/src/lib/components/card-list-item.js +137 -0
- package/src/lib/components/card-list-item.js.map +1 -0
- package/src/lib/components/children-function-prop.d.ts +25 -0
- package/src/lib/components/children-function-prop.js +29 -0
- package/src/lib/components/children-function-prop.js.map +1 -0
- package/src/lib/components/confirmation-provider.component.d.ts +19 -0
- package/src/lib/components/confirmation-provider.component.js +83 -0
- package/src/lib/components/confirmation-provider.component.js.map +1 -0
- package/src/lib/components/container.d.ts +25 -0
- package/src/lib/components/container.js +62 -0
- package/src/lib/components/container.js.map +1 -0
- package/src/lib/components/data-table.component.d.ts +54 -0
- package/src/lib/components/data-table.component.js +211 -0
- package/src/lib/components/data-table.component.js.map +1 -0
- package/src/lib/components/dialog-confirm.d.ts +36 -0
- package/src/lib/components/dialog-confirm.js +74 -0
- package/src/lib/components/dialog-confirm.js.map +1 -0
- package/src/lib/components/ellipsis-pulse.component.d.ts +22 -0
- package/src/lib/components/ellipsis-pulse.component.js +51 -0
- package/src/lib/components/ellipsis-pulse.component.js.map +1 -0
- package/src/lib/components/emotion-cache-provider.d.ts +31 -0
- package/src/lib/components/emotion-cache-provider.js +40 -0
- package/src/lib/components/emotion-cache-provider.js.map +1 -0
- package/src/lib/components/empty-state.component.d.ts +63 -0
- package/src/lib/components/empty-state.component.js +214 -0
- package/src/lib/components/empty-state.component.js.map +1 -0
- package/src/lib/components/error-boundary.component.d.ts +28 -0
- package/src/lib/components/error-boundary.component.js +86 -0
- package/src/lib/components/error-boundary.component.js.map +1 -0
- package/src/lib/components/grid-buttons.d.ts +26 -0
- package/src/lib/components/grid-buttons.js +45 -0
- package/src/lib/components/grid-buttons.js.map +1 -0
- package/src/lib/components/grid-items.d.ts +103 -0
- package/src/lib/components/grid-items.js +336 -0
- package/src/lib/components/grid-items.js.map +1 -0
- package/src/lib/components/grid-list.d.ts +37 -0
- package/src/lib/components/grid-list.js +156 -0
- package/src/lib/components/grid-list.js.map +1 -0
- package/src/lib/components/help-tip.component.d.ts +30 -0
- package/src/lib/components/help-tip.component.js +139 -0
- package/src/lib/components/help-tip.component.js.map +1 -0
- package/src/lib/components/link-navigation-reporter.d.ts +24 -0
- package/src/lib/components/link-navigation-reporter.js +64 -0
- package/src/lib/components/link-navigation-reporter.js.map +1 -0
- package/src/lib/components/list-pagination.component.d.ts +57 -0
- package/src/lib/components/list-pagination.component.js +90 -0
- package/src/lib/components/list-pagination.component.js.map +1 -0
- package/src/lib/components/list-table.component.d.ts +155 -0
- package/src/lib/components/list-table.component.js +369 -0
- package/src/lib/components/list-table.component.js.map +1 -0
- package/src/lib/components/loading-layout-app.component.d.ts +35 -0
- package/src/lib/components/loading-layout-app.component.js +42 -0
- package/src/lib/components/loading-layout-app.component.js.map +1 -0
- package/src/lib/components/loading-modal-overlay.d.ts +30 -0
- package/src/lib/components/loading-modal-overlay.js +156 -0
- package/src/lib/components/loading-modal-overlay.js.map +1 -0
- package/src/lib/components/loading-modal.d.ts +19 -0
- package/src/lib/components/loading-modal.js +113 -0
- package/src/lib/components/loading-modal.js.map +1 -0
- package/src/lib/components/loading-text.component.d.ts +21 -0
- package/src/lib/components/loading-text.component.js +40 -0
- package/src/lib/components/loading-text.component.js.map +1 -0
- package/src/lib/components/mdi-icon/index.d.ts +2 -0
- package/src/lib/components/mdi-icon/index.js +4 -0
- package/src/lib/components/mdi-icon/index.js.map +1 -0
- package/src/lib/components/mdi-icon/md-icon-stack.d.ts +31 -0
- package/src/lib/components/mdi-icon/md-icon-stack.js +101 -0
- package/src/lib/components/mdi-icon/md-icon-stack.js.map +1 -0
- package/src/lib/components/mdi-icon/md-icon.d.ts +32 -0
- package/src/lib/components/mdi-icon/md-icon.js +147 -0
- package/src/lib/components/mdi-icon/md-icon.js.map +1 -0
- package/src/lib/components/mdi-icon/mdi-icon-from-id.d.ts +23 -0
- package/src/lib/components/mdi-icon/mdi-icon-from-id.js +35 -0
- package/src/lib/components/mdi-icon/mdi-icon-from-id.js.map +1 -0
- package/src/lib/components/mdi-icon/mdi-icon.d.ts +24 -0
- package/src/lib/components/mdi-icon/mdi-icon.js +46 -0
- package/src/lib/components/mdi-icon/mdi-icon.js.map +1 -0
- package/src/lib/components/measured-figures.component.d.ts +64 -0
- package/src/lib/components/measured-figures.component.js +161 -0
- package/src/lib/components/measured-figures.component.js.map +1 -0
- package/src/lib/components/menu.d.ts +45 -0
- package/src/lib/components/menu.js +229 -0
- package/src/lib/components/menu.js.map +1 -0
- package/src/lib/components/mui-shadow-dom.d.ts +38 -0
- package/src/lib/components/mui-shadow-dom.js +161 -0
- package/src/lib/components/mui-shadow-dom.js.map +1 -0
- package/src/lib/components/navigation-drawer.component.d.ts +31 -0
- package/src/lib/components/navigation-drawer.component.js +76 -0
- package/src/lib/components/navigation-drawer.component.js.map +1 -0
- package/src/lib/components/navigation-intent.d.ts +18 -0
- package/src/lib/components/navigation-intent.js +56 -0
- package/src/lib/components/navigation-intent.js.map +1 -0
- package/src/lib/components/navigation-view/index.d.ts +18 -0
- package/src/lib/components/navigation-view/index.js +19 -0
- package/src/lib/components/navigation-view/index.js.map +1 -0
- package/src/lib/components/navigation-view/navigation-view.d.ts +35 -0
- package/src/lib/components/navigation-view/navigation-view.js +175 -0
- package/src/lib/components/navigation-view/navigation-view.js.map +1 -0
- package/src/lib/components/next-link.d.ts +27 -0
- package/src/lib/components/next-link.js +88 -0
- package/src/lib/components/next-link.js.map +1 -0
- package/src/lib/components/popper-styled.component.d.ts +25 -0
- package/src/lib/components/popper-styled.component.js +129 -0
- package/src/lib/components/popper-styled.component.js.map +1 -0
- package/src/lib/components/quota-readout.component.d.ts +69 -0
- package/src/lib/components/quota-readout.component.js +52 -0
- package/src/lib/components/quota-readout.component.js.map +1 -0
- package/src/lib/components/resizeable-stack.d.ts +4 -0
- package/src/lib/components/resizeable-stack.js +23 -0
- package/src/lib/components/resizeable-stack.js.map +1 -0
- package/src/lib/components/row-actions-menu.component.d.ts +53 -0
- package/src/lib/components/row-actions-menu.component.js +132 -0
- package/src/lib/components/row-actions-menu.component.js.map +1 -0
- package/src/lib/components/ruler-guides.component.d.ts +35 -0
- package/src/lib/components/ruler-guides.component.js +166 -0
- package/src/lib/components/ruler-guides.component.js.map +1 -0
- package/src/lib/components/sandbox-frame.d.ts +42 -0
- package/src/lib/components/sandbox-frame.js +122 -0
- package/src/lib/components/sandbox-frame.js.map +1 -0
- package/src/lib/components/scroll-reaction.d.ts +59 -0
- package/src/lib/components/scroll-reaction.js +43 -0
- package/src/lib/components/scroll-reaction.js.map +1 -0
- package/src/lib/components/scroll-table.component.d.ts +124 -0
- package/src/lib/components/scroll-table.component.js +103 -0
- package/src/lib/components/scroll-table.component.js.map +1 -0
- package/src/lib/components/shadow-dom/index.d.ts +18 -0
- package/src/lib/components/shadow-dom/index.js +19 -0
- package/src/lib/components/shadow-dom/index.js.map +1 -0
- package/src/lib/components/shadow-dom/shadow-dom.d.ts +42 -0
- package/src/lib/components/shadow-dom/shadow-dom.js +123 -0
- package/src/lib/components/shadow-dom/shadow-dom.js.map +1 -0
- package/src/lib/components/splash-screen.d.ts +33 -0
- package/src/lib/components/splash-screen.js +105 -0
- package/src/lib/components/splash-screen.js.map +1 -0
- package/src/lib/components/sr-only.d.ts +20 -0
- package/src/lib/components/sr-only.js +25 -0
- package/src/lib/components/sr-only.js.map +1 -0
- package/src/lib/components/status-screen-plain.component.d.ts +27 -0
- package/src/lib/components/status-screen-plain.component.js +178 -0
- package/src/lib/components/status-screen-plain.component.js.map +1 -0
- package/src/lib/components/usage-meter.component.d.ts +30 -0
- package/src/lib/components/usage-meter.component.js +92 -0
- package/src/lib/components/usage-meter.component.js.map +1 -0
- package/src/lib/components/variable-text-field.component.d.ts +50 -0
- package/src/lib/components/variable-text-field.component.js +188 -0
- package/src/lib/components/variable-text-field.component.js.map +1 -0
- package/src/lib/components/zoomable-panning-component/index.d.ts +1 -0
- package/src/lib/components/zoomable-panning-component/index.js +3 -0
- package/src/lib/components/zoomable-panning-component/index.js.map +1 -0
- package/src/lib/components/zoomable-panning-component/util.d.ts +58 -0
- package/src/lib/components/zoomable-panning-component/util.js +114 -0
- package/src/lib/components/zoomable-panning-component/util.js.map +1 -0
- package/src/lib/components/zoomable-panning-component/zoomable-panning-component.d.ts +132 -0
- package/src/lib/components/zoomable-panning-component/zoomable-panning-component.js +728 -0
- package/src/lib/components/zoomable-panning-component/zoomable-panning-component.js.map +1 -0
- package/src/lib/const/aglyn-besigner-logo-full.d.ts +39 -0
- package/src/lib/const/aglyn-besigner-logo-full.js +146 -0
- package/src/lib/const/aglyn-besigner-logo-full.js.map +1 -0
- package/src/lib/const/aglyn-console-logo-full.d.ts +34 -0
- package/src/lib/const/aglyn-console-logo-full.js +142 -0
- package/src/lib/const/aglyn-console-logo-full.js.map +1 -0
- package/src/lib/const/aglyn-logo-class-keys.d.ts +30 -0
- package/src/lib/const/aglyn-logo-class-keys.js +32 -0
- package/src/lib/const/aglyn-logo-class-keys.js.map +1 -0
- package/src/lib/const/aglyn-logo-full.d.ts +29 -0
- package/src/lib/const/aglyn-logo-full.js +111 -0
- package/src/lib/const/aglyn-logo-full.js.map +1 -0
- package/src/lib/const/list-filter.d.ts +260 -0
- package/src/lib/const/list-filter.js +409 -0
- package/src/lib/const/list-filter.js.map +1 -0
- package/src/lib/const/prebuilt-components.d.ts +17 -0
- package/src/lib/const/prebuilt-components.js +22 -0
- package/src/lib/const/prebuilt-components.js.map +1 -0
- package/src/lib/const/svg-icons.d.ts +75 -0
- package/src/lib/const/svg-icons.js +313 -0
- package/src/lib/const/svg-icons.js.map +1 -0
- package/src/lib/const/table-pagination.d.ts +106 -0
- package/src/lib/const/table-pagination.js +106 -0
- package/src/lib/const/table-pagination.js.map +1 -0
- package/src/lib/contexts/confirmation.context.d.ts +996 -0
- package/src/lib/contexts/confirmation.context.js +49 -0
- package/src/lib/contexts/confirmation.context.js.map +1 -0
- package/src/lib/contexts/loading.context.d.ts +93 -0
- package/src/lib/contexts/loading.context.js +126 -0
- package/src/lib/contexts/loading.context.js.map +1 -0
- package/src/lib/hocs/create-hoc-with-context-consumer.d.ts +36 -0
- package/src/lib/hocs/create-hoc-with-context-consumer.js +44 -0
- package/src/lib/hocs/create-hoc-with-context-consumer.js.map +1 -0
- package/src/lib/hocs/with-hoc.d.ts +32 -0
- package/src/lib/hocs/with-hoc.js +37 -0
- package/src/lib/hocs/with-hoc.js.map +1 -0
- package/src/lib/hooks/mdi-icon/use-mdi-icon.d.ts +20 -0
- package/src/lib/hooks/mdi-icon/use-mdi-icon.js +48 -0
- package/src/lib/hooks/mdi-icon/use-mdi-icon.js.map +1 -0
- package/src/lib/hooks/mdi-icon/use-mdi-icons-fuzzy.d.ts +26 -0
- package/src/lib/hooks/mdi-icon/use-mdi-icons-fuzzy.js +73 -0
- package/src/lib/hooks/mdi-icon/use-mdi-icons-fuzzy.js.map +1 -0
- package/src/lib/hooks/mdi-icon/use-mdi-icons.d.ts +19 -0
- package/src/lib/hooks/mdi-icon/use-mdi-icons.js +49 -0
- package/src/lib/hooks/mdi-icon/use-mdi-icons.js.map +1 -0
- package/src/lib/hooks/router-events.d.ts +56 -0
- package/src/lib/hooks/router-events.js +88 -0
- package/src/lib/hooks/router-events.js.map +1 -0
- package/src/lib/hooks/use-async-effect.d.ts +24 -0
- package/src/lib/hooks/use-async-effect.js +44 -0
- package/src/lib/hooks/use-async-effect.js.map +1 -0
- package/src/lib/hooks/use-callback-param-ref.d.ts +19 -0
- package/src/lib/hooks/use-callback-param-ref.js +29 -0
- package/src/lib/hooks/use-callback-param-ref.js.map +1 -0
- package/src/lib/hooks/use-id.d.ts +21 -0
- package/src/lib/hooks/use-id.js +28 -0
- package/src/lib/hooks/use-id.js.map +1 -0
- package/src/lib/hooks/use-isomorphic-layout-effect.d.ts +19 -0
- package/src/lib/hooks/use-isomorphic-layout-effect.js +20 -0
- package/src/lib/hooks/use-isomorphic-layout-effect.js.map +1 -0
- package/src/lib/hooks/use-merge-refs.d.ts +38 -0
- package/src/lib/hooks/use-merge-refs.js +52 -0
- package/src/lib/hooks/use-merge-refs.js.map +1 -0
- package/src/lib/hooks/use-subscribable.d.ts +29 -0
- package/src/lib/hooks/use-subscribable.js +50 -0
- package/src/lib/hooks/use-subscribable.js.map +1 -0
- package/src/lib/types.d.ts +18 -0
- package/src/lib/types.js +18 -0
- package/src/lib/types.js.map +1 -0
- package/src/lib/utils/make-link-elements.d.ts +24 -0
- package/src/lib/utils/make-link-elements.js +32 -0
- package/src/lib/utils/make-link-elements.js.map +1 -0
- package/src/lib/utils/make-meta-elements.d.ts +24 -0
- package/src/lib/utils/make-meta-elements.js +32 -0
- package/src/lib/utils/make-meta-elements.js.map +1 -0
- package/src/lib/utils/scroll-overflow.d.ts +120 -0
- package/src/lib/utils/scroll-overflow.js +115 -0
- package/src/lib/utils/scroll-overflow.js.map +1 -0
- package/src/lib/utils/vendor.d.ts +17 -0
- package/src/lib/utils/vendor.js +18 -0
- package/src/lib/utils/vendor.js.map +1 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
+
import { AppLink } from "./app-link.js";
|
|
20
|
+
import { MdiIcon } from "./mdi-icon/mdi-icon.js";
|
|
21
|
+
import { mdiDotsVertical } from "@aglyn/shared-data-mdi";
|
|
22
|
+
import { IconButton, ListItemIcon, ListItemText, Menu, MenuItem, Tooltip } from "@mui/material";
|
|
23
|
+
import { forwardRef, useCallback, useState } from "react";
|
|
24
|
+
/**
|
|
25
|
+
* The anchor a linked menu item renders as.
|
|
26
|
+
*
|
|
27
|
+
* `naked` is the variant that adds no styling of its own — the MenuItem it is
|
|
28
|
+
* the root of already resets colour and text-decoration, so a linked item is
|
|
29
|
+
* pixel-identical to a handler-driven one.
|
|
30
|
+
*/ const MenuItemLinkComponent = /*#__PURE__*/ forwardRef((props, ref)=>/*#__PURE__*/ _jsx(AppLink, _extends({
|
|
31
|
+
ref: ref
|
|
32
|
+
}, props, {
|
|
33
|
+
componentVariant: 'naked'
|
|
34
|
+
})));
|
|
35
|
+
MenuItemLinkComponent.displayName = 'MenuItemLinkComponent';
|
|
36
|
+
/**
|
|
37
|
+
* Overflow menu for a table row's secondary actions (AGL-701).
|
|
38
|
+
*
|
|
39
|
+
* The DataGrid lists get this from `GridActionsCellItem showInMenu`, but the
|
|
40
|
+
* screens table is hand-rolled markup driven by a `renderRowActions`
|
|
41
|
+
* render-prop, so `showInMenu` is not available to it and it needs a real
|
|
42
|
+
* menu of its own.
|
|
43
|
+
*
|
|
44
|
+
* Every handler closes the menu first. Delete opens a confirmation, and a
|
|
45
|
+
* menu left standing over that dialog reads as though the click missed.
|
|
46
|
+
*
|
|
47
|
+
* An item that names an `href` is an ANCHOR, not a handler — a navigation
|
|
48
|
+
* action must be middle-clickable and copyable like any other link. It still
|
|
49
|
+
* renders as a menu item: the anchor is the MenuItem's own root element, so
|
|
50
|
+
* it inherits the item's colour, padding and focus ring rather than the
|
|
51
|
+
* browser's link styling.
|
|
52
|
+
*/ export function RowActionsMenu(props) {
|
|
53
|
+
const { items, label } = props;
|
|
54
|
+
const [anchorEl, setAnchorEl] = useState(null);
|
|
55
|
+
const handleOpen = useCallback((event)=>{
|
|
56
|
+
// The row itself opens the screen; without this the menu button would
|
|
57
|
+
// navigate out from under the menu it just opened.
|
|
58
|
+
event.stopPropagation();
|
|
59
|
+
setAnchorEl(event.currentTarget);
|
|
60
|
+
}, []);
|
|
61
|
+
const handleClose = useCallback(()=>setAnchorEl(null), []);
|
|
62
|
+
if (!items.length) return null;
|
|
63
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
64
|
+
children: [
|
|
65
|
+
/*#__PURE__*/ _jsx(IconButton, {
|
|
66
|
+
size: "small",
|
|
67
|
+
"aria-label": label ? `More actions for ${label}` : 'More actions',
|
|
68
|
+
"aria-haspopup": "true",
|
|
69
|
+
onClick: handleOpen,
|
|
70
|
+
children: /*#__PURE__*/ _jsx(MdiIcon, {
|
|
71
|
+
path: mdiDotsVertical.path,
|
|
72
|
+
size: 0.8
|
|
73
|
+
})
|
|
74
|
+
}),
|
|
75
|
+
/*#__PURE__*/ _jsx(Menu, {
|
|
76
|
+
anchorEl: anchorEl,
|
|
77
|
+
open: Boolean(anchorEl),
|
|
78
|
+
onClose: handleClose,
|
|
79
|
+
onClick: (event)=>event.stopPropagation(),
|
|
80
|
+
children: items.map((item)=>{
|
|
81
|
+
// A disabled item is never a link: an anchor whose destination is
|
|
82
|
+
// refused still navigates on a middle-click, which is the one route
|
|
83
|
+
// around the disabled state that `pointer-events: none` misses.
|
|
84
|
+
const linkProps = item.href && !item.disabled ? _extends({
|
|
85
|
+
component: MenuItemLinkComponent,
|
|
86
|
+
href: item.href
|
|
87
|
+
}, item.external ? {
|
|
88
|
+
target: '_blank',
|
|
89
|
+
rel: 'noreferrer'
|
|
90
|
+
} : {}) : {};
|
|
91
|
+
const menuItem = /*#__PURE__*/ _jsxs(MenuItem, _extends({}, linkProps, {
|
|
92
|
+
disabled: item.disabled,
|
|
93
|
+
onClick: ()=>{
|
|
94
|
+
handleClose();
|
|
95
|
+
item.onClick == null ? void 0 : item.onClick.call(item);
|
|
96
|
+
},
|
|
97
|
+
children: [
|
|
98
|
+
item.icon ? /*#__PURE__*/ _jsx(ListItemIcon, {
|
|
99
|
+
sx: item.destructive ? {
|
|
100
|
+
color: 'error.main'
|
|
101
|
+
} : undefined,
|
|
102
|
+
children: item.icon
|
|
103
|
+
}) : null,
|
|
104
|
+
/*#__PURE__*/ _jsx(ListItemText, {
|
|
105
|
+
slotProps: item.destructive ? {
|
|
106
|
+
primary: {
|
|
107
|
+
color: 'error.main'
|
|
108
|
+
}
|
|
109
|
+
} : undefined,
|
|
110
|
+
children: item.label
|
|
111
|
+
})
|
|
112
|
+
]
|
|
113
|
+
}), item.key);
|
|
114
|
+
// span: a disabled item takes no pointer events, so the tooltip
|
|
115
|
+
// needs a wrapper that does. `MenuList` reads its items from
|
|
116
|
+
// context rather than from its direct children, so the wrapper
|
|
117
|
+
// costs nothing in keyboard navigation.
|
|
118
|
+
return item.disabled && item.disabledReason ? /*#__PURE__*/ _jsx(Tooltip, {
|
|
119
|
+
title: item.disabledReason,
|
|
120
|
+
children: /*#__PURE__*/ _jsx("span", {
|
|
121
|
+
children: menuItem
|
|
122
|
+
})
|
|
123
|
+
}, item.key) : menuItem;
|
|
124
|
+
})
|
|
125
|
+
})
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
RowActionsMenu.displayName = 'RowActionsMenu';
|
|
130
|
+
export default RowActionsMenu;
|
|
131
|
+
|
|
132
|
+
//# sourceMappingURL=row-actions-menu.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/components/row-actions-menu.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n'use client'\n\nimport { AppLink, type AppLinkNakedLinkProps } from './app-link'\nimport { MdiIcon } from './mdi-icon/mdi-icon'\nimport { mdiDotsVertical } from '@aglyn/shared-data-mdi'\nimport {\n IconButton,\n ListItemIcon,\n ListItemText,\n Menu,\n MenuItem,\n Tooltip,\n} from '@mui/material'\nimport {\n forwardRef,\n useCallback,\n useState,\n type MouseEvent,\n type ReactNode,\n} from 'react'\n\nexport interface RowActionsMenuItem {\n key: string\n label: string\n icon?: ReactNode\n /**\n * Where the item navigates. An item that carries one renders as a real\n * anchor, so it can be middle-clicked into a new tab, copied, or opened\n * from the browser's own context menu — the affordances a click handler\n * cannot offer however faithfully it calls `router.push`.\n */\n href?: string\n /** `href` leaves the console, so it opens in a new tab. */\n external?: boolean\n /** For items that open a dialog rather than navigate. */\n onClick?: () => void\n /** Renders the row in the error colour, for destructive actions. */\n destructive?: boolean\n disabled?: boolean\n /**\n * Why the item cannot be used, shown as its tooltip. Mirrors the quick\n * action's `unavailableReason`: a control that is present but inert says\n * nothing on its own, and an absent one and an inapplicable one look alike.\n */\n disabledReason?: string\n}\n\n/**\n * The anchor a linked menu item renders as.\n *\n * `naked` is the variant that adds no styling of its own — the MenuItem it is\n * the root of already resets colour and text-decoration, so a linked item is\n * pixel-identical to a handler-driven one.\n */\nconst MenuItemLinkComponent = forwardRef<any, AppLinkNakedLinkProps>(\n (props, ref) => <AppLink ref={ref} {...props} componentVariant={'naked'} />,\n)\nMenuItemLinkComponent.displayName = 'MenuItemLinkComponent'\n\nexport interface RowActionsMenuProps {\n items: RowActionsMenuItem[]\n /** Distinguishes this row's menu for screen readers. */\n label?: string\n}\n\n/**\n * Overflow menu for a table row's secondary actions (AGL-701).\n *\n * The DataGrid lists get this from `GridActionsCellItem showInMenu`, but the\n * screens table is hand-rolled markup driven by a `renderRowActions`\n * render-prop, so `showInMenu` is not available to it and it needs a real\n * menu of its own.\n *\n * Every handler closes the menu first. Delete opens a confirmation, and a\n * menu left standing over that dialog reads as though the click missed.\n *\n * An item that names an `href` is an ANCHOR, not a handler — a navigation\n * action must be middle-clickable and copyable like any other link. It still\n * renders as a menu item: the anchor is the MenuItem's own root element, so\n * it inherits the item's colour, padding and focus ring rather than the\n * browser's link styling.\n */\nexport function RowActionsMenu(props: RowActionsMenuProps) {\n const { items, label } = props\n const [anchorEl, setAnchorEl] = useState<HTMLElement | null>(null)\n const handleOpen = useCallback((event: MouseEvent<HTMLElement>) => {\n // The row itself opens the screen; without this the menu button would\n // navigate out from under the menu it just opened.\n event.stopPropagation()\n setAnchorEl(event.currentTarget)\n }, [])\n const handleClose = useCallback(() => setAnchorEl(null), [])\n if (!items.length) return null\n return (\n <>\n <IconButton\n size=\"small\"\n aria-label={label ? `More actions for ${label}` : 'More actions'}\n aria-haspopup=\"true\"\n onClick={handleOpen}\n >\n <MdiIcon path={mdiDotsVertical.path} size={0.8} />\n </IconButton>\n <Menu\n anchorEl={anchorEl}\n open={Boolean(anchorEl)}\n onClose={handleClose}\n onClick={(event) => event.stopPropagation()}\n >\n {items.map((item) => {\n // A disabled item is never a link: an anchor whose destination is\n // refused still navigates on a middle-click, which is the one route\n // around the disabled state that `pointer-events: none` misses.\n const linkProps =\n item.href && !item.disabled\n ? {\n component: MenuItemLinkComponent,\n href: item.href,\n ...(item.external\n ? { target: '_blank', rel: 'noreferrer' }\n : {}),\n }\n : {}\n const menuItem = (\n <MenuItem\n key={item.key}\n {...(linkProps as any)}\n disabled={item.disabled}\n onClick={() => {\n handleClose()\n item.onClick?.()\n }}\n >\n {item.icon ? (\n <ListItemIcon\n sx={item.destructive ? { color: 'error.main' } : undefined}\n >\n {item.icon}\n </ListItemIcon>\n ) : null}\n <ListItemText\n slotProps={\n item.destructive\n ? { primary: { color: 'error.main' } }\n : undefined\n }\n >\n {item.label}\n </ListItemText>\n </MenuItem>\n )\n // span: a disabled item takes no pointer events, so the tooltip\n // needs a wrapper that does. `MenuList` reads its items from\n // context rather than from its direct children, so the wrapper\n // costs nothing in keyboard navigation.\n return item.disabled && item.disabledReason ? (\n <Tooltip key={item.key} title={item.disabledReason}>\n <span>{menuItem}</span>\n </Tooltip>\n ) : (\n menuItem\n )\n })}\n </Menu>\n </>\n )\n}\n\nRowActionsMenu.displayName = 'RowActionsMenu'\n\nexport default RowActionsMenu\n"],"names":["AppLink","MdiIcon","mdiDotsVertical","IconButton","ListItemIcon","ListItemText","Menu","MenuItem","Tooltip","forwardRef","useCallback","useState","MenuItemLinkComponent","props","ref","componentVariant","displayName","RowActionsMenu","items","label","anchorEl","setAnchorEl","handleOpen","event","stopPropagation","currentTarget","handleClose","length","size","aria-label","aria-haspopup","onClick","path","open","Boolean","onClose","map","item","linkProps","href","disabled","component","external","target","rel","menuItem","icon","sx","destructive","color","undefined","slotProps","primary","key","disabledReason","title","span"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;;;AAEA,SAASA,OAAO,QAAoC,gBAAY;AAChE,SAASC,OAAO,QAAQ,yBAAqB;AAC7C,SAASC,eAAe,QAAQ,yBAAwB;AACxD,SACEC,UAAU,EACVC,YAAY,EACZC,YAAY,EACZC,IAAI,EACJC,QAAQ,EACRC,OAAO,QACF,gBAAe;AACtB,SACEC,UAAU,EACVC,WAAW,EACXC,QAAQ,QAGH,QAAO;AA4Bd;;;;;;CAMC,GACD,MAAMC,sCAAwBH,WAC5B,CAACI,OAAOC,oBAAQ,KAACd;QAAQc,KAAKA;OAASD;QAAOE,kBAAkB;;AAElEH,sBAAsBI,WAAW,GAAG;AAQpC;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC,eAAeJ,KAA0B;IACvD,MAAM,EAAEK,KAAK,EAAEC,KAAK,EAAE,GAAGN;IACzB,MAAM,CAACO,UAAUC,YAAY,GAAGV,SAA6B;IAC7D,MAAMW,aAAaZ,YAAY,CAACa;QAC9B,sEAAsE;QACtE,mDAAmD;QACnDA,MAAMC,eAAe;QACrBH,YAAYE,MAAME,aAAa;IACjC,GAAG,EAAE;IACL,MAAMC,cAAchB,YAAY,IAAMW,YAAY,OAAO,EAAE;IAC3D,IAAI,CAACH,MAAMS,MAAM,EAAE,OAAO;IAC1B,qBACE;;0BACE,KAACxB;gBACCyB,MAAK;gBACLC,cAAYV,QAAQ,CAAC,iBAAiB,EAAEA,OAAO,GAAG;gBAClDW,iBAAc;gBACdC,SAAST;0BAET,cAAA,KAACrB;oBAAQ+B,MAAM9B,gBAAgB8B,IAAI;oBAAEJ,MAAM;;;0BAE7C,KAACtB;gBACCc,UAAUA;gBACVa,MAAMC,QAAQd;gBACde,SAAST;gBACTK,SAAS,CAACR,QAAUA,MAAMC,eAAe;0BAExCN,MAAMkB,GAAG,CAAC,CAACC;oBACV,kEAAkE;oBAClE,oEAAoE;oBACpE,gEAAgE;oBAChE,MAAMC,YACJD,KAAKE,IAAI,IAAI,CAACF,KAAKG,QAAQ,GACvB;wBACEC,WAAW7B;wBACX2B,MAAMF,KAAKE,IAAI;uBACXF,KAAKK,QAAQ,GACb;wBAAEC,QAAQ;wBAAUC,KAAK;oBAAa,IACtC,CAAC,KAEP,CAAC;oBACP,MAAMC,yBACJ,MAACtC,uBAEM+B;wBACLE,UAAUH,KAAKG,QAAQ;wBACvBT,SAAS;4BACPL;4BACAW,KAAKN,OAAO,oBAAZM,KAAKN,OAAO,MAAZM;wBACF;;4BAECA,KAAKS,IAAI,iBACR,KAAC1C;gCACC2C,IAAIV,KAAKW,WAAW,GAAG;oCAAEC,OAAO;gCAAa,IAAIC;0CAEhDb,KAAKS,IAAI;iCAEV;0CACJ,KAACzC;gCACC8C,WACEd,KAAKW,WAAW,GACZ;oCAAEI,SAAS;wCAAEH,OAAO;oCAAa;gCAAE,IACnCC;0CAGLb,KAAKlB,KAAK;;;wBAtBRkB,KAAKgB,GAAG;oBA0BjB,gEAAgE;oBAChE,6DAA6D;oBAC7D,+DAA+D;oBAC/D,wCAAwC;oBACxC,OAAOhB,KAAKG,QAAQ,IAAIH,KAAKiB,cAAc,iBACzC,KAAC9C;wBAAuB+C,OAAOlB,KAAKiB,cAAc;kCAChD,cAAA,KAACE;sCAAMX;;uBADKR,KAAKgB,GAAG,IAItBR;gBAEJ;;;;AAIR;AAEA5B,eAAeD,WAAW,GAAG;AAE7B,eAAeC,eAAc"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2024 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { BoxProps } from '@mui/material/Box';
|
|
18
|
+
import React from 'react';
|
|
19
|
+
export interface RulerComponentProps extends BoxProps {
|
|
20
|
+
variant?: 'vertical' | 'horizontal';
|
|
21
|
+
}
|
|
22
|
+
export declare const RulerComponent: import("@emotion/styled").StyledComponent<Pick<RulerComponentProps, keyof RulerComponentProps> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & RulerComponentProps, {}, {}>;
|
|
23
|
+
export interface GuideComponentProps extends BoxProps {
|
|
24
|
+
offset?: number;
|
|
25
|
+
variant?: 'vertical' | 'horizontal';
|
|
26
|
+
}
|
|
27
|
+
export interface RulerGuidesProps extends BoxProps {
|
|
28
|
+
guides?: GuideComponentProps[];
|
|
29
|
+
RulerComponentProps?: {
|
|
30
|
+
vertical?: RulerComponentProps;
|
|
31
|
+
horizontal?: RulerComponentProps;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export declare const RulerGuidesComponent: React.ForwardRefExoticComponent<Omit<RulerGuidesProps, "ref"> & React.RefAttributes<any>>;
|
|
35
|
+
export default RulerGuidesComponent;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2024 Aglyn LLC
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/ import { generateComponentClassKeys, styled } from "@aglyn/shared-ui-theme";
|
|
20
|
+
import { _isArr, _isEqualitySameType } from "@aglyn/shared-util-tools";
|
|
21
|
+
import Box from "@mui/material/Box";
|
|
22
|
+
import { teal } from "@mui/material/colors";
|
|
23
|
+
import clsx from "clsx";
|
|
24
|
+
import React from "react";
|
|
25
|
+
const rulerClassKey = generateComponentClassKeys('AglynRuler', [
|
|
26
|
+
'vertical',
|
|
27
|
+
'horizontal'
|
|
28
|
+
]);
|
|
29
|
+
export const RulerComponent = styled((_0)=>{
|
|
30
|
+
let { variant, className } = _0, props = _object_without_properties_loose(_0, [
|
|
31
|
+
"variant",
|
|
32
|
+
"className"
|
|
33
|
+
]);
|
|
34
|
+
return /*#__PURE__*/ _jsx(Box, _extends({
|
|
35
|
+
className: clsx({
|
|
36
|
+
[rulerClassKey.horizontal]: variant === 'horizontal',
|
|
37
|
+
[rulerClassKey.vertical]: variant === 'vertical' || variant !== 'horizontal'
|
|
38
|
+
}, className)
|
|
39
|
+
}, props));
|
|
40
|
+
}, {
|
|
41
|
+
name: 'RulerComponent'
|
|
42
|
+
})(({ theme })=>({
|
|
43
|
+
position: 'absolute',
|
|
44
|
+
boxShadow: theme.shadows[3],
|
|
45
|
+
borderBottom: `1px solid ${theme.palette.divider}`,
|
|
46
|
+
backgroundColor: theme.palette.background.paper,
|
|
47
|
+
backgroundPosition: '0 0, 0px 10px, 0 12px',
|
|
48
|
+
backgroundSize: '50px 50px, 10px 50px, 5px 50px',
|
|
49
|
+
backgroundImage: [
|
|
50
|
+
0,
|
|
51
|
+
0,
|
|
52
|
+
0
|
|
53
|
+
].map(()=>`linear-gradient(to left, ${theme.palette.divider} 1px, transparent 1px)`).join(),
|
|
54
|
+
backgroundRepeat: 'repeat-x',
|
|
55
|
+
[`&.${rulerClassKey.horizontal}`]: {
|
|
56
|
+
top: 0,
|
|
57
|
+
left: 16,
|
|
58
|
+
width: '100%',
|
|
59
|
+
height: 15
|
|
60
|
+
},
|
|
61
|
+
[`&.${rulerClassKey.vertical}`]: {
|
|
62
|
+
top: 0,
|
|
63
|
+
left: 16,
|
|
64
|
+
width: '100%',
|
|
65
|
+
height: 15,
|
|
66
|
+
transform: 'rotateZ(90deg) rotateX(180deg)',
|
|
67
|
+
transformOrigin: '0% 100%'
|
|
68
|
+
}
|
|
69
|
+
}));
|
|
70
|
+
RulerComponent.displayName = 'RulerComponent';
|
|
71
|
+
RulerComponent.aglyn = true;
|
|
72
|
+
const guideClassKey = generateComponentClassKeys('AglynGuide', [
|
|
73
|
+
'vertical',
|
|
74
|
+
'horizontal'
|
|
75
|
+
]);
|
|
76
|
+
const GuideComponent = styled((_0)=>{
|
|
77
|
+
let { variant, className } = _0, props = _object_without_properties_loose(_0, [
|
|
78
|
+
"variant",
|
|
79
|
+
"className"
|
|
80
|
+
]);
|
|
81
|
+
return /*#__PURE__*/ _jsx(Box, _extends({
|
|
82
|
+
className: clsx({
|
|
83
|
+
[guideClassKey.horizontal]: variant === 'horizontal',
|
|
84
|
+
[guideClassKey.vertical]: variant !== 'horizontal'
|
|
85
|
+
}, className)
|
|
86
|
+
}, props));
|
|
87
|
+
}, {
|
|
88
|
+
name: 'GuideContainer',
|
|
89
|
+
shouldForwardProp (propName) {
|
|
90
|
+
return !_isEqualitySameType(propName, null, 'offset');
|
|
91
|
+
}
|
|
92
|
+
})(({ offset })=>({
|
|
93
|
+
position: 'absolute',
|
|
94
|
+
'&:after': {
|
|
95
|
+
display: 'block',
|
|
96
|
+
content: '" "',
|
|
97
|
+
position: 'absolute',
|
|
98
|
+
backgroundColor: teal['A200']
|
|
99
|
+
},
|
|
100
|
+
[`&.${guideClassKey.horizontal}`]: {
|
|
101
|
+
width: 11,
|
|
102
|
+
height: '100%',
|
|
103
|
+
top: offset != null ? offset : 0,
|
|
104
|
+
cursor: 'ew-resize',
|
|
105
|
+
'&:after': {
|
|
106
|
+
height: 1,
|
|
107
|
+
width: '100%',
|
|
108
|
+
top: 5,
|
|
109
|
+
left: 0
|
|
110
|
+
}
|
|
111
|
+
},
|
|
112
|
+
[`&.${guideClassKey.vertical}`]: {
|
|
113
|
+
cursor: 'ns-resize',
|
|
114
|
+
height: 11,
|
|
115
|
+
width: '100%',
|
|
116
|
+
left: offset != null ? offset : 0,
|
|
117
|
+
'&:after': {
|
|
118
|
+
width: 1,
|
|
119
|
+
height: '100%',
|
|
120
|
+
left: 5,
|
|
121
|
+
top: 0
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}));
|
|
125
|
+
GuideComponent.displayName = 'GuideComponent';
|
|
126
|
+
GuideComponent.aglyn = true;
|
|
127
|
+
const RulerGuidesContainer = styled(Box, {
|
|
128
|
+
name: 'RulerGuidesContainer'
|
|
129
|
+
})(({ theme })=>({
|
|
130
|
+
zIndex: theme.zIndex.speedDial,
|
|
131
|
+
// pointerEvents: 'none',
|
|
132
|
+
position: 'relative'
|
|
133
|
+
}));
|
|
134
|
+
export const RulerGuidesComponent = /*#__PURE__*/ React.forwardRef(function RefRenderFn(props, ref) {
|
|
135
|
+
const { children, guides, RulerComponentProps } = props, rest = _object_without_properties_loose(props, [
|
|
136
|
+
"children",
|
|
137
|
+
"guides",
|
|
138
|
+
"RulerComponentProps"
|
|
139
|
+
]);
|
|
140
|
+
return /*#__PURE__*/ _jsxs(RulerGuidesContainer, _extends({
|
|
141
|
+
ref: ref
|
|
142
|
+
}, rest, {
|
|
143
|
+
children: [
|
|
144
|
+
children,
|
|
145
|
+
/*#__PURE__*/ _jsx(RulerComponent, _extends({
|
|
146
|
+
variant: "horizontal"
|
|
147
|
+
}, RulerComponentProps == null ? void 0 : RulerComponentProps.horizontal)),
|
|
148
|
+
/*#__PURE__*/ _jsx(RulerComponent, _extends({
|
|
149
|
+
variant: "vertical"
|
|
150
|
+
}, RulerComponentProps == null ? void 0 : RulerComponentProps.vertical)),
|
|
151
|
+
_isArr(guides) && guides.map((_0, _1)=>{
|
|
152
|
+
let _ref = [
|
|
153
|
+
_0,
|
|
154
|
+
_1
|
|
155
|
+
], [_ref1, ..._rest] = _ref, {} = _ref1, guide = _extends({}, _ref1), [i] = _rest;
|
|
156
|
+
var _ref2, _guide_key;
|
|
157
|
+
return /*#__PURE__*/ _jsx(GuideComponent, _extends({}, guide), (_ref2 = (_guide_key = guide.key) != null ? _guide_key : guide.id) != null ? _ref2 : i);
|
|
158
|
+
})
|
|
159
|
+
]
|
|
160
|
+
}));
|
|
161
|
+
});
|
|
162
|
+
RulerGuidesComponent.displayName = 'RulerGuidesComponent';
|
|
163
|
+
RulerGuidesComponent.aglyn = true;
|
|
164
|
+
export default RulerGuidesComponent;
|
|
165
|
+
|
|
166
|
+
//# sourceMappingURL=ruler-guides.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/components/ruler-guides.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2024 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { generateComponentClassKeys, styled } from '@aglyn/shared-ui-theme'\nimport { _isArr, _isEqualitySameType } from '@aglyn/shared-util-tools'\nimport Box, { BoxProps } from '@mui/material/Box'\nimport { teal } from '@mui/material/colors'\n\nimport clsx from 'clsx'\nimport React from 'react'\n\nconst rulerClassKey = generateComponentClassKeys('AglynRuler', [\n 'vertical',\n 'horizontal',\n])\n\nexport interface RulerComponentProps extends BoxProps {\n variant?: 'vertical' | 'horizontal'\n}\n\nexport const RulerComponent = styled(\n ({ variant, className, ...props }: RulerComponentProps) => (\n <Box\n className={clsx(\n {\n [rulerClassKey.horizontal]: variant === 'horizontal',\n [rulerClassKey.vertical]:\n variant === 'vertical' || variant !== 'horizontal',\n },\n className,\n )}\n {...props}\n />\n ),\n {\n name: 'RulerComponent',\n },\n)<RulerComponentProps>(({ theme }) => ({\n position: 'absolute',\n boxShadow: theme.shadows[3],\n borderBottom: `1px solid ${theme.palette.divider}`,\n backgroundColor: theme.palette.background.paper,\n backgroundPosition: '0 0, 0px 10px, 0 12px',\n backgroundSize: '50px 50px, 10px 50px, 5px 50px',\n backgroundImage: [0, 0, 0]\n .map(\n () =>\n `linear-gradient(to left, ${theme.palette.divider} 1px, transparent 1px)`,\n )\n .join(),\n backgroundRepeat: 'repeat-x',\n [`&.${rulerClassKey.horizontal}`]: {\n top: 0,\n left: 16,\n width: '100%',\n height: 15,\n },\n [`&.${rulerClassKey.vertical}`]: {\n top: 0,\n left: 16,\n width: '100%',\n height: 15,\n transform: 'rotateZ(90deg) rotateX(180deg)',\n transformOrigin: '0% 100%',\n },\n}))\nRulerComponent.displayName = 'RulerComponent'\nRulerComponent.aglyn = true\n\nconst guideClassKey = generateComponentClassKeys('AglynGuide', [\n 'vertical',\n 'horizontal',\n])\n\nexport interface GuideComponentProps extends BoxProps {\n offset?: number /* The amount of pixels to displace from the ruler */\n variant?: 'vertical' | 'horizontal'\n}\n\nconst GuideComponent = styled(\n ({ variant, className, ...props }: GuideComponentProps) => (\n <Box\n className={clsx(\n {\n [guideClassKey.horizontal]: variant === 'horizontal',\n [guideClassKey.vertical]: variant !== 'horizontal',\n },\n className,\n )}\n {...props}\n />\n ),\n {\n name: 'GuideContainer',\n shouldForwardProp(propName) {\n return !_isEqualitySameType(propName, null, 'offset')\n },\n },\n)<GuideComponentProps>(({ offset }) => ({\n position: 'absolute',\n '&:after': {\n display: 'block',\n content: '\" \"',\n position: 'absolute',\n backgroundColor: teal['A200'],\n },\n [`&.${guideClassKey.horizontal}`]: {\n width: 11,\n height: '100%',\n top: offset ?? 0,\n cursor: 'ew-resize',\n '&:after': {\n height: 1,\n width: '100%',\n top: 5,\n left: 0,\n },\n },\n [`&.${guideClassKey.vertical}`]: {\n cursor: 'ns-resize',\n height: 11,\n width: '100%',\n left: offset ?? 0,\n '&:after': {\n width: 1,\n height: '100%',\n left: 5,\n top: 0,\n },\n },\n}))\nGuideComponent.displayName = 'GuideComponent'\nGuideComponent.aglyn = true\n\nconst RulerGuidesContainer = styled(Box, { name: 'RulerGuidesContainer' })(\n ({ theme }) => ({\n zIndex: theme.zIndex.speedDial,\n // pointerEvents: 'none',\n position: 'relative',\n // left: 0, right: 0, top: 0,\n // width: '100%', height: '100%',\n }),\n)\n\nexport interface RulerGuidesProps extends BoxProps {\n guides?: GuideComponentProps[]\n RulerComponentProps?: {\n vertical?: RulerComponentProps\n horizontal?: RulerComponentProps\n }\n}\n\nexport const RulerGuidesComponent = React.forwardRef<any, RulerGuidesProps>(\n function RefRenderFn(props, ref) {\n const { children, guides, RulerComponentProps, ...rest } = props\n\n return (\n <RulerGuidesContainer ref={ref} {...rest}>\n {children}\n <RulerComponent\n variant=\"horizontal\"\n {...RulerComponentProps?.horizontal}\n />\n <RulerComponent variant=\"vertical\" {...RulerComponentProps?.vertical} />\n {_isArr(guides) &&\n guides.map(({ ...guide }, i) => (\n <GuideComponent key={guide.key ?? guide.id ?? i} {...guide} />\n ))}\n </RulerGuidesContainer>\n )\n },\n)\n\nRulerGuidesComponent.displayName = 'RulerGuidesComponent'\nRulerGuidesComponent.aglyn = true\n\nexport default RulerGuidesComponent\n"],"names":["generateComponentClassKeys","styled","_isArr","_isEqualitySameType","Box","teal","clsx","React","rulerClassKey","RulerComponent","variant","className","props","horizontal","vertical","name","theme","position","boxShadow","shadows","borderBottom","palette","divider","backgroundColor","background","paper","backgroundPosition","backgroundSize","backgroundImage","map","join","backgroundRepeat","top","left","width","height","transform","transformOrigin","displayName","aglyn","guideClassKey","GuideComponent","shouldForwardProp","propName","offset","display","content","cursor","RulerGuidesContainer","zIndex","speedDial","RulerGuidesComponent","forwardRef","RefRenderFn","ref","children","guides","RulerComponentProps","rest","guide","i","key","id"],"mappings":"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"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { type Jss, type JssOptions } from 'jss';
|
|
18
|
+
import type { ComponentProps } from 'react';
|
|
19
|
+
import React, { type ReactElement } from 'react';
|
|
20
|
+
import ReactFrameComponent from 'react-frame-component';
|
|
21
|
+
export type FrameComponentProps = ComponentProps<typeof ReactFrameComponent>;
|
|
22
|
+
export type SandboxFrameDocument = HTMLIFrameElement['contentDocument'];
|
|
23
|
+
export type SandboxFrameWindow = HTMLIFrameElement['contentWindow'];
|
|
24
|
+
type State = {
|
|
25
|
+
ready: boolean;
|
|
26
|
+
sandboxFrameDocument: SandboxFrameDocument;
|
|
27
|
+
sandboxFrameWindow: SandboxFrameWindow;
|
|
28
|
+
sheetsManager?: Map<any, any>;
|
|
29
|
+
jss?: Jss;
|
|
30
|
+
};
|
|
31
|
+
export interface SandboxFrameProps extends Omit<FrameComponentProps, 'contentDidMount' | 'contentDidUpdate' | 'title'> {
|
|
32
|
+
onContentDidMount?: (state: State) => void;
|
|
33
|
+
onContentDidUpdate?: (state: State) => void;
|
|
34
|
+
jssPlugins?: JssOptions['plugins'];
|
|
35
|
+
baseStyles?: string;
|
|
36
|
+
title?: ReactElement;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @component
|
|
40
|
+
*/
|
|
41
|
+
export declare const SandboxFrame: React.ForwardRefExoticComponent<Omit<SandboxFrameProps, "ref"> & React.RefAttributes<HTMLIFrameElement>>;
|
|
42
|
+
export default SandboxFrame;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
2
|
+
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
3
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2026 Aglyn LLC
|
|
7
|
+
*
|
|
8
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
9
|
+
* you may not use this file except in compliance with the License.
|
|
10
|
+
* You may obtain a copy of the License at
|
|
11
|
+
*
|
|
12
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
13
|
+
*
|
|
14
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
15
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
16
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
17
|
+
* See the License for the specific language governing permissions and
|
|
18
|
+
* limitations under the License.
|
|
19
|
+
*/ import { jssPreset, StylesProvider, useTheme } from "@mui/styles";
|
|
20
|
+
import { create } from "jss";
|
|
21
|
+
import rtl from "jss-rtl";
|
|
22
|
+
import React, { Children, cloneElement, forwardRef, Fragment, isValidElement, useCallback, useMemo, useRef, useState } from "react";
|
|
23
|
+
import ReactFrameComponent from "react-frame-component";
|
|
24
|
+
import { useMergeRefs } from "../hooks/use-merge-refs.js";
|
|
25
|
+
/**
|
|
26
|
+
* @component
|
|
27
|
+
*/ export const SandboxFrame = /*#__PURE__*/ forwardRef(function RefRenderFn(props, ref) {
|
|
28
|
+
const theme = useTheme();
|
|
29
|
+
const { children, title, onContentDidMount, onContentDidUpdate, jssPlugins, baseStyles = 'html, body, .frame-root, .frame-content { width: 100%; height: 100%; }' } = props, rest = _object_without_properties_loose(props, [
|
|
30
|
+
"children",
|
|
31
|
+
"title",
|
|
32
|
+
"onContentDidMount",
|
|
33
|
+
"onContentDidUpdate",
|
|
34
|
+
"jssPlugins",
|
|
35
|
+
"baseStyles"
|
|
36
|
+
]);
|
|
37
|
+
// Current frame state
|
|
38
|
+
const [state, setState] = useState({
|
|
39
|
+
ready: false,
|
|
40
|
+
sandboxFrameDocument: null,
|
|
41
|
+
sandboxFrameWindow: null
|
|
42
|
+
});
|
|
43
|
+
// Reference for frame context
|
|
44
|
+
const styleRef = useRef(null);
|
|
45
|
+
const frameRef = useRef(null);
|
|
46
|
+
const rootRef = useMergeRefs(frameRef, ref);
|
|
47
|
+
const head = useMemo(()=>/*#__PURE__*/ _jsxs(Fragment, {
|
|
48
|
+
children: [
|
|
49
|
+
title && /*#__PURE__*/ _jsx("title", {
|
|
50
|
+
children: title
|
|
51
|
+
}),
|
|
52
|
+
/*#__PURE__*/ _jsx("style", {
|
|
53
|
+
ref: styleRef,
|
|
54
|
+
dangerouslySetInnerHTML: {
|
|
55
|
+
__html: baseStyles
|
|
56
|
+
},
|
|
57
|
+
id: 'sandbox-frame-jss'
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
}), [
|
|
61
|
+
title,
|
|
62
|
+
baseStyles
|
|
63
|
+
]);
|
|
64
|
+
const handleContentDidMount = useCallback(()=>{
|
|
65
|
+
const instance = frameRef.current;
|
|
66
|
+
const styleInstance = styleRef.current;
|
|
67
|
+
if (instance) {
|
|
68
|
+
const nextState = _extends({}, state, {
|
|
69
|
+
ready: true,
|
|
70
|
+
sandboxFrameDocument: instance.contentDocument,
|
|
71
|
+
sandboxFrameWindow: instance.contentWindow,
|
|
72
|
+
sheetsManager: new Map(),
|
|
73
|
+
jss: create({
|
|
74
|
+
plugins: [
|
|
75
|
+
...jssPreset().plugins,
|
|
76
|
+
rtl(),
|
|
77
|
+
...jssPlugins
|
|
78
|
+
],
|
|
79
|
+
insertionPoint: styleInstance
|
|
80
|
+
})
|
|
81
|
+
});
|
|
82
|
+
setState(nextState);
|
|
83
|
+
onContentDidMount && onContentDidMount(nextState);
|
|
84
|
+
} else {
|
|
85
|
+
onContentDidMount && onContentDidMount(state);
|
|
86
|
+
}
|
|
87
|
+
}, [
|
|
88
|
+
onContentDidMount,
|
|
89
|
+
state,
|
|
90
|
+
jssPlugins
|
|
91
|
+
]);
|
|
92
|
+
const handleContentDidUpdate = useCallback(()=>{
|
|
93
|
+
const instance = frameRef.current;
|
|
94
|
+
if (instance) {
|
|
95
|
+
instance.contentDocument.body.dir = theme.direction;
|
|
96
|
+
}
|
|
97
|
+
onContentDidUpdate && onContentDidUpdate(state);
|
|
98
|
+
}, [
|
|
99
|
+
onContentDidUpdate,
|
|
100
|
+
theme.direction,
|
|
101
|
+
state
|
|
102
|
+
]);
|
|
103
|
+
const childElement = Children.only(children);
|
|
104
|
+
console.debug('[RENDERING SANDBOX FRAME]', title, `STATE READY? ${state.ready}`);
|
|
105
|
+
return /*#__PURE__*/ _jsx(ReactFrameComponent, _extends({
|
|
106
|
+
ref: rootRef,
|
|
107
|
+
contentDidMount: handleContentDidMount,
|
|
108
|
+
contentDidUpdate: handleContentDidUpdate,
|
|
109
|
+
head: head
|
|
110
|
+
}, rest, {
|
|
111
|
+
children: state.ready ? /*#__PURE__*/ _jsx(StylesProvider, {
|
|
112
|
+
jss: state.jss,
|
|
113
|
+
sheetsManager: state.sheetsManager,
|
|
114
|
+
children: /*#__PURE__*/ isValidElement(childElement) ? /*#__PURE__*/ cloneElement(childElement, state) : 'INVALID SANDBOX FRAME CHILD ELEMENT!'
|
|
115
|
+
}) : null
|
|
116
|
+
}));
|
|
117
|
+
});
|
|
118
|
+
SandboxFrame.displayName = 'SandboxFrame';
|
|
119
|
+
SandboxFrame.aglyn = true;
|
|
120
|
+
export default SandboxFrame;
|
|
121
|
+
|
|
122
|
+
//# sourceMappingURL=sandbox-frame.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/components/sandbox-frame.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { jssPreset, StylesProvider, useTheme } from '@mui/styles'\n\nimport { create, type Jss, type JssOptions } from 'jss'\nimport rtl from 'jss-rtl'\nimport type { ComponentProps } from 'react'\nimport React, {\n Children,\n cloneElement,\n forwardRef,\n Fragment,\n isValidElement,\n type ReactElement,\n useCallback,\n useMemo,\n useRef,\n useState,\n} from 'react'\n\nimport ReactFrameComponent from 'react-frame-component'\n\nimport { useMergeRefs } from '../hooks/use-merge-refs'\n\nexport type FrameComponentProps = ComponentProps<typeof ReactFrameComponent>\nexport type SandboxFrameDocument = HTMLIFrameElement['contentDocument']\nexport type SandboxFrameWindow = HTMLIFrameElement['contentWindow']\ntype State = {\n ready: boolean\n sandboxFrameDocument: SandboxFrameDocument\n sandboxFrameWindow: SandboxFrameWindow\n sheetsManager?: Map<any, any>\n jss?: Jss\n}\n\n/* eslint-disable-next-line */\nexport interface SandboxFrameProps\n extends Omit<\n FrameComponentProps,\n 'contentDidMount' | 'contentDidUpdate' | 'title'\n > {\n onContentDidMount?: (state: State) => void\n onContentDidUpdate?: (state: State) => void\n jssPlugins?: JssOptions['plugins']\n baseStyles?: string\n title?: ReactElement\n}\n\n/**\n * @component\n */\nexport const SandboxFrame = forwardRef<HTMLIFrameElement, SandboxFrameProps>(\n function RefRenderFn(props, ref) {\n const theme = useTheme()\n const {\n children,\n title,\n onContentDidMount,\n onContentDidUpdate,\n jssPlugins,\n baseStyles = 'html, body, .frame-root, .frame-content { width: 100%; height: 100%; }',\n ...rest\n } = props\n // Current frame state\n const [state, setState]: any = useState<State>({\n ready: false,\n sandboxFrameDocument: null,\n sandboxFrameWindow: null,\n })\n // Reference for frame context\n const styleRef = useRef(null)\n const frameRef = useRef(null)\n const rootRef = useMergeRefs(frameRef, ref)\n const head = useMemo(\n () => (\n <Fragment>\n {title && <title>{title}</title>}\n {/* JSS Insertion Point */}\n <style\n ref={styleRef}\n dangerouslySetInnerHTML={{ __html: baseStyles }}\n id={'sandbox-frame-jss'}\n />\n </Fragment>\n ),\n [title, baseStyles],\n )\n const handleContentDidMount = useCallback(() => {\n const instance = frameRef.current\n const styleInstance = styleRef.current\n if (instance) {\n const nextState = {\n ...state,\n ready: true,\n sandboxFrameDocument: instance.contentDocument,\n sandboxFrameWindow: instance.contentWindow,\n sheetsManager: new Map(),\n jss: create({\n plugins: [...jssPreset().plugins, rtl(), ...jssPlugins],\n insertionPoint: styleInstance,\n }),\n }\n setState(nextState)\n onContentDidMount && onContentDidMount(nextState)\n } else {\n onContentDidMount && onContentDidMount(state)\n }\n }, [onContentDidMount, state, jssPlugins])\n const handleContentDidUpdate = useCallback(() => {\n const instance = frameRef.current\n if (instance) {\n instance.contentDocument.body.dir = theme.direction\n }\n onContentDidUpdate && onContentDidUpdate(state)\n }, [onContentDidUpdate, theme.direction, state])\n const childElement = Children.only(children)\n console.debug(\n '[RENDERING SANDBOX FRAME]',\n title,\n `STATE READY? ${state.ready}`,\n )\n return (\n <ReactFrameComponent\n ref={rootRef as any}\n contentDidMount={handleContentDidMount}\n contentDidUpdate={handleContentDidUpdate}\n head={head}\n {...rest}\n >\n {state.ready ? (\n <StylesProvider jss={state.jss} sheetsManager={state.sheetsManager}>\n {isValidElement(childElement)\n ? cloneElement(childElement, state)\n : 'INVALID SANDBOX FRAME CHILD ELEMENT!'}\n </StylesProvider>\n ) : null}\n </ReactFrameComponent>\n )\n },\n)\n\nSandboxFrame.displayName = 'SandboxFrame'\nSandboxFrame.aglyn = true\n\nexport default SandboxFrame\n"],"names":["jssPreset","StylesProvider","useTheme","create","rtl","React","Children","cloneElement","forwardRef","Fragment","isValidElement","useCallback","useMemo","useRef","useState","ReactFrameComponent","useMergeRefs","SandboxFrame","RefRenderFn","props","ref","theme","children","title","onContentDidMount","onContentDidUpdate","jssPlugins","baseStyles","rest","state","setState","ready","sandboxFrameDocument","sandboxFrameWindow","styleRef","frameRef","rootRef","head","style","dangerouslySetInnerHTML","__html","id","handleContentDidMount","instance","current","styleInstance","nextState","contentDocument","contentWindow","sheetsManager","Map","jss","plugins","insertionPoint","handleContentDidUpdate","body","dir","direction","childElement","only","console","debug","contentDidMount","contentDidUpdate","displayName","aglyn"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,SAAS,EAAEC,cAAc,EAAEC,QAAQ,QAAQ,cAAa;AAEjE,SAASC,MAAM,QAAmC,MAAK;AACvD,OAAOC,SAAS,UAAS;AAEzB,OAAOC,SACLC,QAAQ,EACRC,YAAY,EACZC,UAAU,EACVC,QAAQ,EACRC,cAAc,EAEdC,WAAW,EACXC,OAAO,EACPC,MAAM,EACNC,QAAQ,QACH,QAAO;AAEd,OAAOC,yBAAyB,wBAAuB;AAEvD,SAASC,YAAY,QAAQ,6BAAyB;AA0BtD;;CAEC,GACD,OAAO,MAAMC,6BAAeT,WAC1B,SAASU,YAAYC,KAAK,EAAEC,GAAG;IAC7B,MAAMC,QAAQnB;IACd,MAAM,EACJoB,QAAQ,EACRC,KAAK,EACLC,iBAAiB,EACjBC,kBAAkB,EAClBC,UAAU,EACVC,aAAa,wEAAwE,EAEtF,GAAGR,OADCS,wCACDT;;;;;;;;IACJ,sBAAsB;IACtB,MAAM,CAACU,OAAOC,SAAS,GAAQhB,SAAgB;QAC7CiB,OAAO;QACPC,sBAAsB;QACtBC,oBAAoB;IACtB;IACA,8BAA8B;IAC9B,MAAMC,WAAWrB,OAAO;IACxB,MAAMsB,WAAWtB,OAAO;IACxB,MAAMuB,UAAUpB,aAAamB,UAAUf;IACvC,MAAMiB,OAAOzB,QACX,kBACE,MAACH;;gBACEc,uBAAS,KAACA;8BAAOA;;8BAElB,KAACe;oBACClB,KAAKc;oBACLK,yBAAyB;wBAAEC,QAAQb;oBAAW;oBAC9Cc,IAAI;;;YAIV;QAAClB;QAAOI;KAAW;IAErB,MAAMe,wBAAwB/B,YAAY;QACxC,MAAMgC,WAAWR,SAASS,OAAO;QACjC,MAAMC,gBAAgBX,SAASU,OAAO;QACtC,IAAID,UAAU;YACZ,MAAMG,YAAY,aACbjB;gBACHE,OAAO;gBACPC,sBAAsBW,SAASI,eAAe;gBAC9Cd,oBAAoBU,SAASK,aAAa;gBAC1CC,eAAe,IAAIC;gBACnBC,KAAKhD,OAAO;oBACViD,SAAS;2BAAIpD,YAAYoD,OAAO;wBAAEhD;2BAAUsB;qBAAW;oBACvD2B,gBAAgBR;gBAClB;;YAEFf,SAASgB;YACTtB,qBAAqBA,kBAAkBsB;QACzC,OAAO;YACLtB,qBAAqBA,kBAAkBK;QACzC;IACF,GAAG;QAACL;QAAmBK;QAAOH;KAAW;IACzC,MAAM4B,yBAAyB3C,YAAY;QACzC,MAAMgC,WAAWR,SAASS,OAAO;QACjC,IAAID,UAAU;YACZA,SAASI,eAAe,CAACQ,IAAI,CAACC,GAAG,GAAGnC,MAAMoC,SAAS;QACrD;QACAhC,sBAAsBA,mBAAmBI;IAC3C,GAAG;QAACJ;QAAoBJ,MAAMoC,SAAS;QAAE5B;KAAM;IAC/C,MAAM6B,eAAepD,SAASqD,IAAI,CAACrC;IACnCsC,QAAQC,KAAK,CACX,6BACAtC,OACA,CAAC,aAAa,EAAEM,MAAME,KAAK,EAAE;IAE/B,qBACE,KAAChB;QACCK,KAAKgB;QACL0B,iBAAiBpB;QACjBqB,kBAAkBT;QAClBjB,MAAMA;OACFT;kBAEHC,MAAME,KAAK,iBACV,KAAC9B;YAAekD,KAAKtB,MAAMsB,GAAG;YAAEF,eAAepB,MAAMoB,aAAa;sBAC/DvC,cAAAA,eAAegD,8BACZnD,aAAamD,cAAc7B,SAC3B;aAEJ;;AAGV,GACD;AAEDZ,aAAa+C,WAAW,GAAG;AAC3B/C,aAAagD,KAAK,GAAG;AAErB,eAAehD,aAAY"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/
|
|
17
|
+
import { useScrollTrigger } from '@mui/material';
|
|
18
|
+
import { type ReactElement } from 'react';
|
|
19
|
+
type UseScrollTriggerOptions = Parameters<typeof useScrollTrigger>[0];
|
|
20
|
+
export type ElevatedRenderProps = {
|
|
21
|
+
activeWithHysteresis: boolean;
|
|
22
|
+
activeWithoutHysteresis: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type ScrollTriggerOptions = Omit<UseScrollTriggerOptions, 'disableHysteresis'>;
|
|
25
|
+
export interface ScrollReactionProps<P = any> extends ScrollTriggerOptions {
|
|
26
|
+
/**
|
|
27
|
+
* If children is a render function then passes local state to parameter.
|
|
28
|
+
* Otherwise will clone child element, passing or calling renderProps
|
|
29
|
+
*/
|
|
30
|
+
children: ReactElement<P> | ((state: ElevatedRenderProps) => ReactElement<P>);
|
|
31
|
+
/**
|
|
32
|
+
* Optionally, provide a render props function to contextually change passed
|
|
33
|
+
* props based on the local state provided through the
|
|
34
|
+
*/
|
|
35
|
+
renderProps?: Partial<P> | ((state: ElevatedRenderProps) => Partial<P>);
|
|
36
|
+
/**
|
|
37
|
+
* Optionally provided to override the options passed to useScrollTrigger for
|
|
38
|
+
* the hook responding to triggers *WITH* hysteresis.
|
|
39
|
+
*
|
|
40
|
+
* __Meaning of Hysteresis__
|
|
41
|
+
* > The meaning of hysteresis is "lagging." Hysteresis is characterized as a
|
|
42
|
+
* > lag of magnetic flux density (B) behind the magnetic field strength (H).
|
|
43
|
+
*/
|
|
44
|
+
withHysteresis?: ScrollTriggerOptions;
|
|
45
|
+
/**
|
|
46
|
+
* Optionally provided to override the options passed to
|
|
47
|
+
* the`useScrollTrigger` for the hook responding to triggers *WITHOUT*
|
|
48
|
+
* hysteresis.
|
|
49
|
+
*
|
|
50
|
+
* @see {@link withHysteresis} for Hysteresis meaning
|
|
51
|
+
*/
|
|
52
|
+
withoutHysteresis?: ScrollTriggerOptions;
|
|
53
|
+
}
|
|
54
|
+
export declare function ScrollReaction<P>(props: ScrollReactionProps<P>): ReactElement<P>;
|
|
55
|
+
export declare namespace ScrollReaction {
|
|
56
|
+
var displayName: string;
|
|
57
|
+
var aglyn: boolean;
|
|
58
|
+
}
|
|
59
|
+
export default ScrollReaction;
|