@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,44 @@
|
|
|
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 } 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 { forwardRef } from "react";
|
|
20
|
+
export const AglynText = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
21
|
+
const { children } = props, rest = _object_without_properties_loose(props, [
|
|
22
|
+
"children"
|
|
23
|
+
]);
|
|
24
|
+
// `aglyn-text` is not a registered custom element and never was — there is
|
|
25
|
+
// no `customElements.define` for it anywhere in the repo. React renders an
|
|
26
|
+
// unknown lowercase tag as-is, which is all this needs to be.
|
|
27
|
+
const Tag = 'aglyn-text';
|
|
28
|
+
// React refuses an element that carries both, and the JSX children slot
|
|
29
|
+
// counts as `children` even when the value in it is undefined on some
|
|
30
|
+
// toolchains — so the formatted branch is a separate element expression
|
|
31
|
+
// rather than a conditional inside one.
|
|
32
|
+
if (rest.dangerouslySetInnerHTML) return /*#__PURE__*/ _jsx(Tag, _extends({
|
|
33
|
+
ref: ref
|
|
34
|
+
}, rest));
|
|
35
|
+
return /*#__PURE__*/ _jsx(Tag, _extends({
|
|
36
|
+
ref: ref
|
|
37
|
+
}, rest, {
|
|
38
|
+
children: children
|
|
39
|
+
}));
|
|
40
|
+
});
|
|
41
|
+
AglynText.displayName = 'AglynText';
|
|
42
|
+
export default AglynText;
|
|
43
|
+
|
|
44
|
+
//# sourceMappingURL=aglyn-text.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/components/aglyn-text.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 { forwardRef } from 'react'\n\n/**\n * The authored text of a leaf, as a plain element (AGL-2011).\n *\n * ## Why this is no longer a shadow host\n *\n * This used to be `ShadowDom.AglynText` — a `shadowDomRootFactory` host that\n * `attachShadow`ed and then rendered the string through a `createPortal` into\n * the shadow root. The tag name is unchanged, so every\n * `querySelectorAll('aglyn-text')` and every editor ref target still resolves;\n * what is gone is the shadow boundary.\n *\n * A shadow root exists to encapsulate STYLE, and here it encapsulated nothing.\n * Measured on the live `/pricing` page: **960 hosts, 960 shadow roots holding a\n * single bare text node, zero elements inside any of them, and zero carrying\n * any CSS** — no `adoptedStyleSheets`, no `<style>`, no `<link>`. There was\n * nothing for a selector to match, and inherited typography (font, colour,\n * line-height) crosses a shadow boundary regardless. The encapsulation was a\n * no-op.\n *\n * The COSTS were not. A shadow root makes text invisible to `textContent`,\n * and the repo paid for that four separate times:\n *\n * - **AGL-2349 shipped a bug.** Every published split accordion summary named\n * its chevron \"Toggle section\", because the label could not be read back.\n * `accordion.tsx` still carries the bespoke `childText` React-tree walker\n * written to work around it.\n * - Legal-page verification had to read the **Flight payload** rather than the\n * DOM (`published-legal-pages.ts`).\n * - `leaf.spec.tsx` records that `textContent` cannot see it.\n * - Every external check — drift tooling, a11y tooling, find-in-page — needed\n * a bespoke shadow-piercing walk before the page would yield any text.\n *\n * ## Why dropping it is safe\n *\n * The original reason for the shadow root was to give the editor a ref target\n * for inline editing. That is not load-bearing: an ELEMENT provides the ref,\n * not a shadow root, and the besigner's inline text and markdown editors mount\n * **light-DOM** `contenteditable` halves (`besigner/core` → `text-entry.ts`).\n * Nothing edits inside this element.\n *\n * Layout is unchanged: an unknown element defaults to `display: inline`, which\n * is what the shadow HOST already was, and the host was always in the light\n * tree — only its CONTENT moved.\n *\n * Hydration gets simpler rather than riskier. The old component rendered the\n * text as light DOM on the server and during the first client render, then\n * attached the shadow in a layout effect and re-rendered the same string\n * through a portal; the light copy stopped displaying only because a shadow\n * host without slots hides its children. Now the server output is final — and\n * a page like `/pricing` does 960 fewer `attachShadow` calls and mounts 960\n * fewer portals.\n */\nexport interface AglynTextProps {\n children?: any\n /**\n * Sanitized author markup, for a leaf whose text carries formatting\n * (AGL-2557). Every caller passes the output of `sanitizeAuthorHtml`,\n * re-sanitized on each render per AGL-497 — this element does no filtering\n * of its own and must never be handed a raw stored value.\n *\n * It rides this element rather than a wrapper of its own so the formatted\n * label and the plain one are the SAME edit target on the canvas, which is\n * the element the besigner looks for (AGL-2556).\n */\n dangerouslySetInnerHTML?: { __html: string }\n}\n\nexport const AglynText = forwardRef<HTMLElement, AglynTextProps>(\n (props, ref) => {\n const { children, ...rest } = props\n // `aglyn-text` is not a registered custom element and never was — there is\n // no `customElements.define` for it anywhere in the repo. React renders an\n // unknown lowercase tag as-is, which is all this needs to be.\n const Tag = 'aglyn-text' as any\n // React refuses an element that carries both, and the JSX children slot\n // counts as `children` even when the value in it is undefined on some\n // toolchains — so the formatted branch is a separate element expression\n // rather than a conditional inside one.\n if (rest.dangerouslySetInnerHTML) return <Tag ref={ref} {...rest} />\n return (\n <Tag ref={ref} {...rest}>\n {children}\n </Tag>\n )\n },\n)\nAglynText.displayName = 'AglynText'\n\nexport default AglynText\n"],"names":["forwardRef","AglynText","props","ref","children","rest","Tag","dangerouslySetInnerHTML","displayName"],"mappings":";;;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,UAAU,QAAQ,QAAO;AAqElC,OAAO,MAAMC,0BAAYD,WACvB,CAACE,OAAOC;IACN,MAAM,EAAEC,QAAQ,EAAW,GAAGF,OAATG,wCAASH;;;IAC9B,2EAA2E;IAC3E,2EAA2E;IAC3E,8DAA8D;IAC9D,MAAMI,MAAM;IACZ,wEAAwE;IACxE,sEAAsE;IACtE,wEAAwE;IACxE,wCAAwC;IACxC,IAAID,KAAKE,uBAAuB,EAAE,qBAAO,KAACD;QAAIH,KAAKA;OAASE;IAC5D,qBACE,KAACC;QAAIH,KAAKA;OAASE;kBAChBD;;AAGP,GACD;AACDH,UAAUO,WAAW,GAAG;AAExB,eAAeP,UAAS"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { ButtonBaseProps as MuiButtonBaseProps, ButtonProps as MuiButtonProps, FabProps as MuiFabProps, IconButtonProps as MuiIconButtonProps, LinkProps as MuiLinkProps } from '@mui/material';
|
|
2
|
+
import { type NextLinkProps } from './next-link';
|
|
3
|
+
export type AppLinkVariant = 'naked' | 'button' | 'button-base' | 'icon-button' | 'fab' | 'text' | 'default' | undefined | never;
|
|
4
|
+
type BaseLinkProps = Omit<NextLinkProps, 'hrefTo'>;
|
|
5
|
+
export type ButtonBaseProps = MuiButtonBaseProps<any, BaseLinkProps>;
|
|
6
|
+
export type ButtonProps = MuiButtonProps<any, BaseLinkProps>;
|
|
7
|
+
export type DefaultProps = TextProps;
|
|
8
|
+
export type FabProps = MuiFabProps<any, BaseLinkProps>;
|
|
9
|
+
export type IconButtonProps = MuiIconButtonProps<any, BaseLinkProps>;
|
|
10
|
+
export type NakedProps = MuiLinkProps<any, BaseLinkProps>;
|
|
11
|
+
export type TextProps = MuiLinkProps<any, BaseLinkProps>;
|
|
12
|
+
export type AppLinkVariantDefault = Extract<AppLinkVariant, 'text' | 'default' | undefined | never>;
|
|
13
|
+
export type AppLinkProps<T = AppLinkVariant> = T extends string ? T extends AppLinkVariant ? T extends AppLinkVariantDefault ? DefaultProps & {
|
|
14
|
+
componentVariant?: T;
|
|
15
|
+
} : T extends 'button' ? ButtonProps & {
|
|
16
|
+
componentVariant: T;
|
|
17
|
+
} : T extends 'button-base' ? ButtonBaseProps & {
|
|
18
|
+
componentVariant: T;
|
|
19
|
+
} : T extends 'icon-button' ? IconButtonProps & {
|
|
20
|
+
componentVariant: T;
|
|
21
|
+
} : T extends 'fab' ? FabProps & {
|
|
22
|
+
componentVariant: T;
|
|
23
|
+
} : T extends 'naked' ? NakedProps & {
|
|
24
|
+
componentVariant: T;
|
|
25
|
+
} : never : never : DefaultProps & {
|
|
26
|
+
componentVariant?: undefined | never;
|
|
27
|
+
};
|
|
28
|
+
export type AppLinkSimpleLinkProps = AppLinkProps<AppLinkVariantDefault>;
|
|
29
|
+
export type AppLinkNakedLinkProps = AppLinkProps<'naked'>;
|
|
30
|
+
export type AppLinkButtonProps = AppLinkProps<'button'>;
|
|
31
|
+
export type AppLinkButtonBaseProps = AppLinkProps<'button-base'>;
|
|
32
|
+
export type AppLinkIconButtonProps = AppLinkProps<'icon-button'>;
|
|
33
|
+
export type AppLinkFabProps = AppLinkProps<'fab'>;
|
|
34
|
+
export declare const appLinkClassKey: import("@aglyn/shared-ui-theme").ClassKeyMap<"disabled" | "active" | "activeAsAncestor" | "variantButton" | "variantButtonBase" | "variantDefault" | "variantFab" | "variantIconButton" | "variantNaked" | "variantText", "AglynAppLink">;
|
|
35
|
+
/**
|
|
36
|
+
* A Material-UI styled version of a "composed" Next.js Link.
|
|
37
|
+
*
|
|
38
|
+
* Specify the `componentVariant` props to conditionally render output element
|
|
39
|
+
* componentVariant === 'naked' = NextLink
|
|
40
|
+
* componentVariant === 'button' = MuiButton
|
|
41
|
+
* componentVariant === any = MuiLink
|
|
42
|
+
*/
|
|
43
|
+
declare const AppLink: import("react").ForwardRefExoticComponent<(Omit<BaseLinkProps & import("@mui/material").LinkOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<any, keyof NextLinkProps> & {
|
|
44
|
+
component?: React.ElementType | undefined;
|
|
45
|
+
} & {
|
|
46
|
+
componentVariant?: "text";
|
|
47
|
+
}, "ref"> | Omit<BaseLinkProps & import("@mui/material").LinkOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<any, keyof NextLinkProps> & {
|
|
48
|
+
component?: React.ElementType | undefined;
|
|
49
|
+
} & {
|
|
50
|
+
componentVariant?: "default";
|
|
51
|
+
}, "ref"> | Omit<BaseLinkProps & import("@mui/material").LinkOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<any, keyof NextLinkProps> & {
|
|
52
|
+
component?: React.ElementType | undefined;
|
|
53
|
+
} & {
|
|
54
|
+
componentVariant: "naked";
|
|
55
|
+
}, "ref"> | Omit<BaseLinkProps & import("@mui/material").ButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, string | number> & import("@mui/material/OverridableComponent").CommonProps & Omit<any, keyof NextLinkProps> & {
|
|
56
|
+
component?: React.ElementType | undefined;
|
|
57
|
+
} & {
|
|
58
|
+
componentVariant: "button";
|
|
59
|
+
}, "ref"> | Omit<BaseLinkProps & import("@mui/material").ButtonBaseOwnProps & import("@mui/material/OverridableComponent").CommonProps & Omit<any, keyof NextLinkProps> & {
|
|
60
|
+
component?: React.ElementType | undefined;
|
|
61
|
+
} & {
|
|
62
|
+
componentVariant: "button-base";
|
|
63
|
+
}, "ref"> | Omit<BaseLinkProps & import("@mui/material").IconButtonOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, string | number> & import("@mui/material/OverridableComponent").CommonProps & Omit<any, keyof NextLinkProps> & {
|
|
64
|
+
component?: React.ElementType | undefined;
|
|
65
|
+
} & {
|
|
66
|
+
componentVariant: "icon-button";
|
|
67
|
+
}, "ref"> | Omit<BaseLinkProps & import("@mui/material").FabOwnProps & Omit<import("@mui/material").ButtonBaseOwnProps, string | number> & import("@mui/material/OverridableComponent").CommonProps & Omit<any, keyof NextLinkProps> & {
|
|
68
|
+
component?: React.ElementType | undefined;
|
|
69
|
+
} & {
|
|
70
|
+
componentVariant: "fab";
|
|
71
|
+
}, "ref">) & import("react").RefAttributes<any>>;
|
|
72
|
+
type AppLink = typeof AppLink;
|
|
73
|
+
export { AppLink };
|
|
74
|
+
export default AppLink;
|
|
@@ -0,0 +1,139 @@
|
|
|
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
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
19
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
|
+
import { generateComponentClassKeys } from "@aglyn/shared-ui-theme";
|
|
21
|
+
import { _isObj } from "@aglyn/shared-util-tools";
|
|
22
|
+
import { truthy } from "@aglyn/shared-util-tools";
|
|
23
|
+
// AGL-926: `Fab` and `IconButton` used to be pulled in with `next/dynamic`,
|
|
24
|
+
// which returns a plain function component and therefore swallows the ref.
|
|
25
|
+
// That made those two variants unusable as a child of anything that clones
|
|
26
|
+
// its child and measures it — MUI `Tooltip` threw
|
|
27
|
+
// `childNode.getAttribute is not a function` and took out every help tip.
|
|
28
|
+
// They are ordinary static imports now, like the other four variants.
|
|
29
|
+
import { Button as MuiButton, ButtonBase as MuiButtonBase, Fab as MuiFab, IconButton as MuiIconButton, Link as MuiLink } from "@mui/material";
|
|
30
|
+
import clsx from "clsx";
|
|
31
|
+
import { usePathname } from "next/navigation";
|
|
32
|
+
import { forwardRef, useMemo } from "react";
|
|
33
|
+
import NextLink from "./next-link.js";
|
|
34
|
+
export const appLinkClassKey = generateComponentClassKeys('AglynAppLink', [
|
|
35
|
+
'active',
|
|
36
|
+
'activeAsAncestor',
|
|
37
|
+
'disabled',
|
|
38
|
+
'variantButton',
|
|
39
|
+
'variantButtonBase',
|
|
40
|
+
'variantDefault',
|
|
41
|
+
'variantFab',
|
|
42
|
+
'variantIconButton',
|
|
43
|
+
'variantNaked',
|
|
44
|
+
'variantText'
|
|
45
|
+
]);
|
|
46
|
+
/**
|
|
47
|
+
* A Material-UI styled version of a "composed" Next.js Link.
|
|
48
|
+
*
|
|
49
|
+
* Specify the `componentVariant` props to conditionally render output element
|
|
50
|
+
* componentVariant === 'naked' = NextLink
|
|
51
|
+
* componentVariant === 'button' = MuiButton
|
|
52
|
+
* componentVariant === any = MuiLink
|
|
53
|
+
*/ const AppLink = /*#__PURE__*/ forwardRef((props, ref)=>{
|
|
54
|
+
var _usePathname;
|
|
55
|
+
const { className, componentVariant, href } = props, rest = _object_without_properties_loose(props, [
|
|
56
|
+
"className",
|
|
57
|
+
"componentVariant",
|
|
58
|
+
"href"
|
|
59
|
+
]);
|
|
60
|
+
const variant = componentVariant;
|
|
61
|
+
const pathname = (_usePathname = usePathname()) != null ? _usePathname : '';
|
|
62
|
+
const [active, activeAsAncestor] = useMemo(()=>{
|
|
63
|
+
const hrefPath = _isObj(href) ? href['pathname'] : href, samePath = hrefPath === pathname, isRootHref = hrefPath === '/', pathIsAncestor = pathname.startsWith(hrefPath), currentlyNested = pathname.lastIndexOf('/') > 0, isSpecified = truthy(hrefPath);
|
|
64
|
+
const active = isSpecified && samePath;
|
|
65
|
+
const activeAsAncestor = isSpecified && !isRootHref && currentlyNested && pathIsAncestor;
|
|
66
|
+
return [
|
|
67
|
+
active,
|
|
68
|
+
!active && activeAsAncestor
|
|
69
|
+
];
|
|
70
|
+
}, [
|
|
71
|
+
href,
|
|
72
|
+
pathname
|
|
73
|
+
]);
|
|
74
|
+
const elemClassName = clsx({
|
|
75
|
+
[appLinkClassKey.active]: active || truthy(rest['active']),
|
|
76
|
+
[appLinkClassKey.activeAsAncestor]: activeAsAncestor,
|
|
77
|
+
[appLinkClassKey.disabled]: truthy(rest['disabled']),
|
|
78
|
+
[appLinkClassKey.variantNaked]: variant === 'naked',
|
|
79
|
+
[appLinkClassKey.variantButton]: variant === 'button',
|
|
80
|
+
[appLinkClassKey.variantButtonBase]: variant === 'button-base',
|
|
81
|
+
[appLinkClassKey.variantIconButton]: variant === 'icon-button',
|
|
82
|
+
[appLinkClassKey.variantFab]: variant === 'fab',
|
|
83
|
+
[appLinkClassKey.variantText]: variant === 'text' || variant === 'default' || !variant,
|
|
84
|
+
[appLinkClassKey.variantDefault]: variant === 'default' || !variant
|
|
85
|
+
}, className);
|
|
86
|
+
switch(variant){
|
|
87
|
+
case 'naked':
|
|
88
|
+
return /*#__PURE__*/ _jsx(NextLink, _extends({
|
|
89
|
+
ref: ref,
|
|
90
|
+
className: elemClassName,
|
|
91
|
+
hrefTo: href || ''
|
|
92
|
+
}, rest));
|
|
93
|
+
case 'button':
|
|
94
|
+
return /*#__PURE__*/ _jsx(MuiButton, _extends({
|
|
95
|
+
ref: ref,
|
|
96
|
+
className: elemClassName,
|
|
97
|
+
component: NextLink,
|
|
98
|
+
nativeButton: false,
|
|
99
|
+
hrefTo: href || ''
|
|
100
|
+
}, rest));
|
|
101
|
+
case 'button-base':
|
|
102
|
+
return /*#__PURE__*/ _jsx(MuiButtonBase, _extends({
|
|
103
|
+
ref: ref,
|
|
104
|
+
className: elemClassName,
|
|
105
|
+
component: NextLink,
|
|
106
|
+
nativeButton: false,
|
|
107
|
+
hrefTo: href || ''
|
|
108
|
+
}, rest));
|
|
109
|
+
case 'icon-button':
|
|
110
|
+
return /*#__PURE__*/ _jsx(MuiIconButton, _extends({
|
|
111
|
+
ref: ref,
|
|
112
|
+
className: elemClassName,
|
|
113
|
+
component: NextLink,
|
|
114
|
+
nativeButton: false,
|
|
115
|
+
hrefTo: href || ''
|
|
116
|
+
}, rest));
|
|
117
|
+
case 'fab':
|
|
118
|
+
return /*#__PURE__*/ _jsx(MuiFab, _extends({
|
|
119
|
+
ref: ref,
|
|
120
|
+
className: elemClassName,
|
|
121
|
+
component: NextLink,
|
|
122
|
+
nativeButton: false,
|
|
123
|
+
hrefTo: href || ''
|
|
124
|
+
}, rest));
|
|
125
|
+
default:
|
|
126
|
+
return /*#__PURE__*/ _jsx(MuiLink, _extends({
|
|
127
|
+
ref: ref,
|
|
128
|
+
className: elemClassName,
|
|
129
|
+
component: NextLink,
|
|
130
|
+
hrefTo: href || ''
|
|
131
|
+
}, rest));
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
AppLink.displayName = 'AppLink';
|
|
135
|
+
AppLink.aglyn = true;
|
|
136
|
+
export { AppLink };
|
|
137
|
+
export default AppLink;
|
|
138
|
+
|
|
139
|
+
//# sourceMappingURL=app-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/components/app-link.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'use client'\n\nimport { generateComponentClassKeys } from '@aglyn/shared-ui-theme'\nimport { _isObj } from '@aglyn/shared-util-tools'\nimport { truthy } from '@aglyn/shared-util-tools'\nimport type {\n ButtonBaseProps as MuiButtonBaseProps,\n ButtonProps as MuiButtonProps,\n FabProps as MuiFabProps,\n IconButtonProps as MuiIconButtonProps,\n LinkProps as MuiLinkProps,\n} from '@mui/material'\n// AGL-926: `Fab` and `IconButton` used to be pulled in with `next/dynamic`,\n// which returns a plain function component and therefore swallows the ref.\n// That made those two variants unusable as a child of anything that clones\n// its child and measures it — MUI `Tooltip` threw\n// `childNode.getAttribute is not a function` and took out every help tip.\n// They are ordinary static imports now, like the other four variants.\nimport {\n Button as MuiButton,\n ButtonBase as MuiButtonBase,\n Fab as MuiFab,\n IconButton as MuiIconButton,\n Link as MuiLink,\n} from '@mui/material'\nimport clsx from 'clsx'\nimport { usePathname } from 'next/navigation'\nimport { forwardRef, type Ref, useMemo } from 'react'\nimport NextLink, { type NextLinkProps } from './next-link'\n\nexport type AppLinkVariant =\n | 'naked'\n | 'button'\n | 'button-base'\n | 'icon-button'\n | 'fab'\n | 'text'\n | 'default'\n | undefined\n | never\n\ntype BaseLinkProps = Omit<NextLinkProps, 'hrefTo'>\nexport type ButtonBaseProps = MuiButtonBaseProps<any, BaseLinkProps>\nexport type ButtonProps = MuiButtonProps<any, BaseLinkProps>\nexport type DefaultProps = TextProps\nexport type FabProps = MuiFabProps<any, BaseLinkProps>\nexport type IconButtonProps = MuiIconButtonProps<any, BaseLinkProps>\nexport type NakedProps = MuiLinkProps<any, BaseLinkProps>\nexport type TextProps = MuiLinkProps<any, BaseLinkProps>\n\nexport type AppLinkVariantDefault = Extract<\n AppLinkVariant,\n 'text' | 'default' | undefined | never\n>\n\nexport type AppLinkProps<T = AppLinkVariant> = T extends string\n ? T extends AppLinkVariant\n ? T extends AppLinkVariantDefault\n ? DefaultProps & { componentVariant?: T }\n : T extends 'button'\n ? ButtonProps & { componentVariant: T }\n : T extends 'button-base'\n ? ButtonBaseProps & { componentVariant: T }\n : T extends 'icon-button'\n ? IconButtonProps & { componentVariant: T }\n : T extends 'fab'\n ? FabProps & { componentVariant: T }\n : T extends 'naked'\n ? NakedProps & { componentVariant: T }\n : never\n : never\n : DefaultProps & { componentVariant?: undefined | never }\n\nexport type AppLinkSimpleLinkProps = AppLinkProps<AppLinkVariantDefault>\nexport type AppLinkNakedLinkProps = AppLinkProps<'naked'>\nexport type AppLinkButtonProps = AppLinkProps<'button'>\nexport type AppLinkButtonBaseProps = AppLinkProps<'button-base'>\nexport type AppLinkIconButtonProps = AppLinkProps<'icon-button'>\nexport type AppLinkFabProps = AppLinkProps<'fab'>\n\nexport const appLinkClassKey = generateComponentClassKeys('AglynAppLink', [\n 'active',\n 'activeAsAncestor',\n 'disabled',\n 'variantButton',\n 'variantButtonBase',\n 'variantDefault',\n 'variantFab',\n 'variantIconButton',\n 'variantNaked',\n 'variantText',\n])\n\n/**\n * A Material-UI styled version of a \"composed\" Next.js Link.\n *\n * Specify the `componentVariant` props to conditionally render output element\n * componentVariant === 'naked' = NextLink\n * componentVariant === 'button' = MuiButton\n * componentVariant === any = MuiLink\n */\nconst AppLink = forwardRef(\n <T extends AppLinkVariant>(props: AppLinkProps<T>, ref: Ref<any>) => {\n const { className, componentVariant, href, ...rest } = props\n\n const variant = componentVariant\n const pathname = usePathname() ?? ''\n const [active, activeAsAncestor] = useMemo(() => {\n const hrefPath = _isObj(href) ? href['pathname'] : href,\n samePath = hrefPath === pathname,\n isRootHref = hrefPath === '/',\n pathIsAncestor = pathname.startsWith(hrefPath),\n currentlyNested = pathname.lastIndexOf('/') > 0,\n isSpecified = truthy(hrefPath)\n const active = isSpecified && samePath\n const activeAsAncestor =\n isSpecified && !isRootHref && currentlyNested && pathIsAncestor\n return [active, !active && activeAsAncestor]\n }, [href, pathname])\n\n const elemClassName = clsx(\n {\n [appLinkClassKey.active]: active || truthy(rest['active']),\n [appLinkClassKey.activeAsAncestor]: activeAsAncestor,\n [appLinkClassKey.disabled]: truthy(rest['disabled']),\n [appLinkClassKey.variantNaked]: variant === 'naked',\n [appLinkClassKey.variantButton]: variant === 'button',\n [appLinkClassKey.variantButtonBase]: variant === 'button-base',\n [appLinkClassKey.variantIconButton]: variant === 'icon-button',\n [appLinkClassKey.variantFab]: variant === 'fab',\n [appLinkClassKey.variantText]:\n variant === 'text' || variant === 'default' || !variant,\n [appLinkClassKey.variantDefault]: variant === 'default' || !variant,\n },\n className,\n )\n\n switch (variant) {\n case 'naked':\n return (\n <NextLink\n ref={ref}\n className={elemClassName}\n hrefTo={href || ''}\n {...rest}\n />\n )\n\n case 'button':\n return (\n <MuiButton\n ref={ref}\n className={elemClassName}\n component={NextLink}\n nativeButton={false}\n hrefTo={href || ''}\n {...rest}\n />\n )\n\n case 'button-base':\n return (\n <MuiButtonBase\n ref={ref}\n className={elemClassName}\n component={NextLink}\n nativeButton={false}\n hrefTo={href || ''}\n {...rest}\n />\n )\n\n case 'icon-button':\n return (\n <MuiIconButton\n ref={ref}\n className={elemClassName}\n component={NextLink}\n nativeButton={false}\n hrefTo={href || ''}\n {...rest}\n />\n )\n\n case 'fab':\n return (\n <MuiFab\n ref={ref}\n className={elemClassName}\n component={NextLink}\n nativeButton={false}\n hrefTo={href || ''}\n {...rest}\n />\n )\n\n default:\n return (\n <MuiLink\n ref={ref}\n className={elemClassName}\n component={NextLink}\n hrefTo={href || ''}\n {...rest}\n />\n )\n }\n },\n)\nAppLink.displayName = 'AppLink'\nAppLink.aglyn = true\n\ntype AppLink = typeof AppLink\nexport { AppLink }\nexport default AppLink\n"],"names":["generateComponentClassKeys","_isObj","truthy","Button","MuiButton","ButtonBase","MuiButtonBase","Fab","MuiFab","IconButton","MuiIconButton","Link","MuiLink","clsx","usePathname","forwardRef","useMemo","NextLink","appLinkClassKey","AppLink","props","ref","className","componentVariant","href","rest","variant","pathname","active","activeAsAncestor","hrefPath","samePath","isRootHref","pathIsAncestor","startsWith","currentlyNested","lastIndexOf","isSpecified","elemClassName","disabled","variantNaked","variantButton","variantButtonBase","variantIconButton","variantFab","variantText","variantDefault","hrefTo","component","nativeButton","displayName","aglyn"],"mappings":"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"}
|
|
@@ -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
|
+
export interface AspectRatioClasses {
|
|
18
|
+
/** Styles applied to the root element. */
|
|
19
|
+
root: string;
|
|
20
|
+
/** Styles applied to the content element. */
|
|
21
|
+
content: string;
|
|
22
|
+
/** Styles applied to the content element if `color="primary"`. */
|
|
23
|
+
colorPrimary: string;
|
|
24
|
+
/** Styles applied to the content element if `color="neutral"`. */
|
|
25
|
+
colorNeutral: string;
|
|
26
|
+
/** Styles applied to the content element if `color="danger"`. */
|
|
27
|
+
colorDanger: string;
|
|
28
|
+
/** Styles applied to the content element if `color="info"`. */
|
|
29
|
+
colorInfo: string;
|
|
30
|
+
/** Styles applied to the content element if `color="success"`. */
|
|
31
|
+
colorSuccess: string;
|
|
32
|
+
/** Styles applied to the content element if `color="warning"`. */
|
|
33
|
+
colorWarning: string;
|
|
34
|
+
/** Styles applied to the root element when color inversion is triggered. */
|
|
35
|
+
colorContext: string;
|
|
36
|
+
/** Styles applied to the content element if `variant="plain"`. */
|
|
37
|
+
variantPlain: string;
|
|
38
|
+
/** Styles applied to the content element if `variant="outlined"`. */
|
|
39
|
+
variantOutlined: string;
|
|
40
|
+
/** Styles applied to the content element if `variant="soft"`. */
|
|
41
|
+
variantSoft: string;
|
|
42
|
+
/** Styles applied to the content element if `variant="solid"`. */
|
|
43
|
+
variantSolid: string;
|
|
44
|
+
}
|
|
45
|
+
export type AspectRatioClassKey = keyof AspectRatioClasses;
|
|
46
|
+
export declare function getAspectRatioUtilityClass(slot: string): string;
|
|
47
|
+
type AspectRatioOwnerState = {
|
|
48
|
+
ratio?: number | string;
|
|
49
|
+
minHeight?: number | string;
|
|
50
|
+
maxHeight?: number | string;
|
|
51
|
+
objectFit?: '-moz-initial' | 'contain' | 'cover' | 'fill' | 'inherit' | 'initial' | 'none' | 'revert-layer' | 'revert' | 'scale-down' | 'unset';
|
|
52
|
+
variant?: 'outlined' | 'plain' | 'soft' | 'solid' | string;
|
|
53
|
+
color?: 'danger' | 'info' | 'neutral' | 'primary' | 'success' | 'warning';
|
|
54
|
+
};
|
|
55
|
+
export interface AspectRatioProps extends AspectRatioOwnerState {
|
|
56
|
+
children?: JSX.Children;
|
|
57
|
+
}
|
|
58
|
+
export declare const AspectRatio: import("react").ForwardRefExoticComponent<AspectRatioProps & import("react").RefAttributes<any>>;
|
|
59
|
+
export default AspectRatio;
|
|
@@ -0,0 +1,153 @@
|
|
|
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 } from "react/jsx-runtime";
|
|
4
|
+
/**
|
|
5
|
+
* @license
|
|
6
|
+
* Copyright 2023 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 { unstable_composeClasses as composeClasses } from "@mui/base";
|
|
20
|
+
import { capitalize, generateUtilityClass, generateUtilityClasses, useThemeProps } from "@mui/material";
|
|
21
|
+
import { styled } from "@mui/material/styles";
|
|
22
|
+
import { Children, cloneElement, forwardRef, isValidElement } from "react";
|
|
23
|
+
export function getAspectRatioUtilityClass(slot) {
|
|
24
|
+
return generateUtilityClass('MuiAspectRatio', slot);
|
|
25
|
+
}
|
|
26
|
+
const aspectRatioClasses = generateUtilityClasses('MuiAspectRatio', [
|
|
27
|
+
'root',
|
|
28
|
+
'content',
|
|
29
|
+
'colorPrimary',
|
|
30
|
+
'colorNeutral',
|
|
31
|
+
'colorDanger',
|
|
32
|
+
'colorInfo',
|
|
33
|
+
'colorSuccess',
|
|
34
|
+
'colorWarning',
|
|
35
|
+
'colorContext',
|
|
36
|
+
'variantPlain',
|
|
37
|
+
'variantOutlined',
|
|
38
|
+
'variantSoft',
|
|
39
|
+
'variantSolid'
|
|
40
|
+
]);
|
|
41
|
+
const useUtilityClasses = (ownerState)=>{
|
|
42
|
+
const { variant, color } = ownerState;
|
|
43
|
+
const slots = {
|
|
44
|
+
root: [
|
|
45
|
+
'root'
|
|
46
|
+
],
|
|
47
|
+
content: [
|
|
48
|
+
'content',
|
|
49
|
+
variant && `variant${capitalize(variant)}`,
|
|
50
|
+
color && `color${capitalize(color)}`
|
|
51
|
+
]
|
|
52
|
+
};
|
|
53
|
+
return composeClasses(slots, getAspectRatioUtilityClass, {});
|
|
54
|
+
};
|
|
55
|
+
// Use to control the width of the content, usually in a flexbox row container
|
|
56
|
+
const AspectRatioRoot = styled('div', {
|
|
57
|
+
name: 'MuiAspectRatio',
|
|
58
|
+
slot: 'Root',
|
|
59
|
+
shouldForwardProp (propName) {
|
|
60
|
+
return propName !== 'ratio';
|
|
61
|
+
}
|
|
62
|
+
})(({ ownerState })=>{
|
|
63
|
+
const minHeight = typeof ownerState.minHeight === 'number' ? `${ownerState.minHeight}px` : ownerState.minHeight;
|
|
64
|
+
const maxHeight = typeof ownerState.maxHeight === 'number' ? `${ownerState.maxHeight}px` : ownerState.maxHeight;
|
|
65
|
+
return {
|
|
66
|
+
// a context variable for any child component
|
|
67
|
+
'--AspectRatio-paddingBottom': minHeight || maxHeight ? `clamp(${minHeight || '0px'}, calc(100% / (${ownerState.ratio})), ${maxHeight || '9999px'})` : `calc(100% / (${ownerState.ratio}))`,
|
|
68
|
+
borderRadius: 'var(--AspectRatio-radius)',
|
|
69
|
+
flexDirection: 'column',
|
|
70
|
+
margin: 'var(--AspectRatio-margin)'
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
const AspectRatioContent = styled('div', {
|
|
74
|
+
name: 'MuiAspectRatio',
|
|
75
|
+
slot: 'Content',
|
|
76
|
+
overridesResolver: (props, styles)=>styles['content']
|
|
77
|
+
})(({ theme, ownerState })=>{
|
|
78
|
+
var _theme_palette_ownerState_variant;
|
|
79
|
+
return [
|
|
80
|
+
{
|
|
81
|
+
flex: 1,
|
|
82
|
+
position: 'relative',
|
|
83
|
+
borderRadius: 'inherit',
|
|
84
|
+
height: 0,
|
|
85
|
+
paddingBottom: 'var(--AspectRatio-paddingBottom)',
|
|
86
|
+
overflow: 'hidden',
|
|
87
|
+
// use data-attribute instead of :first-child to support zero config SSR (emotion)
|
|
88
|
+
// use nested selector for integrating with nextjs image `fill` layout (spans are inserted on top of the img)
|
|
89
|
+
'& [data-first-child]': {
|
|
90
|
+
display: 'flex',
|
|
91
|
+
justifyContent: 'center',
|
|
92
|
+
alignItems: 'center',
|
|
93
|
+
boxSizing: 'border-box',
|
|
94
|
+
position: 'absolute',
|
|
95
|
+
width: '100%',
|
|
96
|
+
height: '100%',
|
|
97
|
+
objectFit: ownerState.objectFit,
|
|
98
|
+
margin: 0,
|
|
99
|
+
padding: 0,
|
|
100
|
+
'& > img': {
|
|
101
|
+
// support art-direction that uses <picture><img /></picture>
|
|
102
|
+
width: '100%',
|
|
103
|
+
height: '100%',
|
|
104
|
+
objectFit: ownerState.objectFit
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
(_theme_palette_ownerState_variant = theme.palette[ownerState.variant]) == null ? void 0 : _theme_palette_ownerState_variant[ownerState.color]
|
|
109
|
+
];
|
|
110
|
+
});
|
|
111
|
+
export const AspectRatio = /*#__PURE__*/ forwardRef((inProps, ref)=>{
|
|
112
|
+
const props = useThemeProps({
|
|
113
|
+
props: inProps,
|
|
114
|
+
name: 'MuiAspectRatio'
|
|
115
|
+
});
|
|
116
|
+
const { children, ratio = '16 / 9', minHeight, maxHeight, objectFit = 'cover', color: colorProp = 'neutral', variant = 'soft' } = props, other = _object_without_properties_loose(props, [
|
|
117
|
+
"children",
|
|
118
|
+
"ratio",
|
|
119
|
+
"minHeight",
|
|
120
|
+
"maxHeight",
|
|
121
|
+
"objectFit",
|
|
122
|
+
"color",
|
|
123
|
+
"variant"
|
|
124
|
+
]);
|
|
125
|
+
// const { getColor } = useColorInversion(variant)
|
|
126
|
+
// const color = getColor(inProps.color, colorProp)
|
|
127
|
+
const ownerState = _extends({}, props, {
|
|
128
|
+
minHeight,
|
|
129
|
+
maxHeight,
|
|
130
|
+
objectFit,
|
|
131
|
+
ratio,
|
|
132
|
+
// color,
|
|
133
|
+
variant
|
|
134
|
+
});
|
|
135
|
+
const classes = useUtilityClasses(ownerState);
|
|
136
|
+
return /*#__PURE__*/ _jsx(AspectRatioRoot, _extends({
|
|
137
|
+
className: classes.root,
|
|
138
|
+
ownerState: ownerState
|
|
139
|
+
}, other, {
|
|
140
|
+
children: /*#__PURE__*/ _jsx(AspectRatioContent, _extends({
|
|
141
|
+
className: classes.content,
|
|
142
|
+
ownerState: ownerState
|
|
143
|
+
}, other, {
|
|
144
|
+
children: Children.map(children, (child, index)=>index === 0 && /*#__PURE__*/ isValidElement(child) ? /*#__PURE__*/ cloneElement(child, {
|
|
145
|
+
'data-first-child': ''
|
|
146
|
+
}) : child)
|
|
147
|
+
}))
|
|
148
|
+
}));
|
|
149
|
+
});
|
|
150
|
+
AspectRatio.displayName = 'AspectRatio';
|
|
151
|
+
export default AspectRatio;
|
|
152
|
+
|
|
153
|
+
//# sourceMappingURL=aspect-ratio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/components/aspect-ratio.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2023 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 { unstable_composeClasses as composeClasses } from '@mui/base'\nimport {\n capitalize,\n generateUtilityClass,\n generateUtilityClasses,\n useThemeProps,\n} from '@mui/material'\nimport { styled } from '@mui/material/styles'\nimport { Children, cloneElement, forwardRef, isValidElement } from 'react'\n\nexport interface AspectRatioClasses {\n /** Styles applied to the root element. */\n root: string\n /** Styles applied to the content element. */\n content: string\n /** Styles applied to the content element if `color=\"primary\"`. */\n colorPrimary: string\n /** Styles applied to the content element if `color=\"neutral\"`. */\n colorNeutral: string\n /** Styles applied to the content element if `color=\"danger\"`. */\n colorDanger: string\n /** Styles applied to the content element if `color=\"info\"`. */\n colorInfo: string\n /** Styles applied to the content element if `color=\"success\"`. */\n colorSuccess: string\n /** Styles applied to the content element if `color=\"warning\"`. */\n colorWarning: string\n /** Styles applied to the root element when color inversion is triggered. */\n colorContext: string\n /** Styles applied to the content element if `variant=\"plain\"`. */\n variantPlain: string\n /** Styles applied to the content element if `variant=\"outlined\"`. */\n variantOutlined: string\n /** Styles applied to the content element if `variant=\"soft\"`. */\n variantSoft: string\n /** Styles applied to the content element if `variant=\"solid\"`. */\n variantSolid: string\n}\n\nexport type AspectRatioClassKey = keyof AspectRatioClasses\n\nexport function getAspectRatioUtilityClass(slot: string): string {\n return generateUtilityClass('MuiAspectRatio', slot)\n}\n\nconst aspectRatioClasses: AspectRatioClasses = generateUtilityClasses(\n 'MuiAspectRatio',\n [\n 'root',\n 'content',\n 'colorPrimary',\n 'colorNeutral',\n 'colorDanger',\n 'colorInfo',\n 'colorSuccess',\n 'colorWarning',\n 'colorContext',\n 'variantPlain',\n 'variantOutlined',\n 'variantSoft',\n 'variantSolid',\n ],\n)\n\nconst useUtilityClasses = (ownerState: AspectRatioOwnerState) => {\n const { variant, color } = ownerState\n const slots = {\n root: ['root'],\n content: [\n 'content',\n variant && `variant${capitalize(variant)}`,\n color && `color${capitalize(color)}`,\n ],\n }\n\n return composeClasses(slots, getAspectRatioUtilityClass, {})\n}\n\ntype AspectRatioOwnerState = {\n ratio?: number | string\n minHeight?: number | string\n maxHeight?: number | string\n objectFit?:\n | '-moz-initial'\n | 'contain'\n | 'cover'\n | 'fill'\n | 'inherit'\n | 'initial'\n | 'none'\n | 'revert-layer'\n | 'revert'\n | 'scale-down'\n | 'unset'\n variant?: 'outlined' | 'plain' | 'soft' | 'solid' | string\n color?: 'danger' | 'info' | 'neutral' | 'primary' | 'success' | 'warning'\n}\n\n// Use to control the width of the content, usually in a flexbox row container\nconst AspectRatioRoot = styled('div', {\n name: 'MuiAspectRatio',\n slot: 'Root',\n shouldForwardProp(propName) {\n return propName !== 'ratio'\n },\n})<{ ownerState: AspectRatioOwnerState }>(({ ownerState }) => {\n const minHeight =\n typeof ownerState.minHeight === 'number'\n ? `${ownerState.minHeight}px`\n : ownerState.minHeight\n const maxHeight =\n typeof ownerState.maxHeight === 'number'\n ? `${ownerState.maxHeight}px`\n : ownerState.maxHeight\n return {\n // a context variable for any child component\n '--AspectRatio-paddingBottom':\n minHeight || maxHeight\n ? `clamp(${minHeight || '0px'}, calc(100% / (${ownerState.ratio})), ${\n maxHeight || '9999px'\n })`\n : `calc(100% / (${ownerState.ratio}))`,\n borderRadius: 'var(--AspectRatio-radius)',\n flexDirection: 'column',\n margin: 'var(--AspectRatio-margin)',\n }\n})\n\nconst AspectRatioContent = styled('div', {\n name: 'MuiAspectRatio',\n slot: 'Content',\n overridesResolver: (props, styles) => styles['content'],\n})<{ ownerState: AspectRatioOwnerState }>(({ theme, ownerState }) => [\n {\n flex: 1,\n position: 'relative',\n borderRadius: 'inherit',\n height: 0,\n paddingBottom: 'var(--AspectRatio-paddingBottom)',\n overflow: 'hidden',\n // use data-attribute instead of :first-child to support zero config SSR (emotion)\n // use nested selector for integrating with nextjs image `fill` layout (spans are inserted on top of the img)\n '& [data-first-child]': {\n display: 'flex',\n justifyContent: 'center',\n alignItems: 'center',\n boxSizing: 'border-box',\n position: 'absolute',\n width: '100%',\n height: '100%',\n objectFit: ownerState.objectFit,\n margin: 0,\n padding: 0,\n '& > img': {\n // support art-direction that uses <picture><img /></picture>\n width: '100%',\n height: '100%',\n objectFit: ownerState.objectFit,\n },\n },\n },\n (theme.palette as unknown as Record<string, Record<string, unknown>>)[\n ownerState.variant!\n ]?.[ownerState.color!],\n])\n\nexport interface AspectRatioProps extends AspectRatioOwnerState {\n children?: JSX.Children\n}\n\nexport const AspectRatio = forwardRef<any, AspectRatioProps>((inProps, ref) => {\n const props = useThemeProps<any, typeof inProps & AspectRatioProps, any>({\n props: inProps,\n name: 'MuiAspectRatio',\n })\n\n const {\n children,\n ratio = '16 / 9',\n minHeight,\n maxHeight,\n objectFit = 'cover',\n color: colorProp = 'neutral',\n variant = 'soft',\n ...other\n } = props\n // const { getColor } = useColorInversion(variant)\n // const color = getColor(inProps.color, colorProp)\n\n const ownerState = {\n ...props,\n minHeight,\n maxHeight,\n objectFit,\n ratio,\n // color,\n variant,\n }\n\n const classes = useUtilityClasses(ownerState)\n\n return (\n <AspectRatioRoot\n className={classes.root}\n ownerState={ownerState}\n {...(other as any)}\n >\n <AspectRatioContent\n className={classes.content}\n ownerState={ownerState}\n {...(other as any)}\n >\n {Children.map(children, (child, index) =>\n index === 0 && isValidElement(child)\n ? cloneElement(child, { 'data-first-child': '' } as Record<\n string,\n string\n >)\n : child,\n )}\n </AspectRatioContent>\n </AspectRatioRoot>\n )\n})\nAspectRatio.displayName = 'AspectRatio'\n\nexport default AspectRatio\n"],"names":["unstable_composeClasses","composeClasses","capitalize","generateUtilityClass","generateUtilityClasses","useThemeProps","styled","Children","cloneElement","forwardRef","isValidElement","getAspectRatioUtilityClass","slot","aspectRatioClasses","useUtilityClasses","ownerState","variant","color","slots","root","content","AspectRatioRoot","name","shouldForwardProp","propName","minHeight","maxHeight","ratio","borderRadius","flexDirection","margin","AspectRatioContent","overridesResolver","props","styles","theme","flex","position","height","paddingBottom","overflow","display","justifyContent","alignItems","boxSizing","width","objectFit","padding","palette","AspectRatio","inProps","ref","children","colorProp","other","classes","className","map","child","index","displayName"],"mappings":"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"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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 { type BoxProps as MuiBoxProps } from '@mui/material';
|
|
18
|
+
import type { CSSProperties } from 'react';
|
|
19
|
+
interface OverrideProps {
|
|
20
|
+
url: string;
|
|
21
|
+
parallax?: boolean;
|
|
22
|
+
bgPosition?: CSSProperties['backgroundPosition'];
|
|
23
|
+
bgRepeat?: CSSProperties['backgroundRepeat'];
|
|
24
|
+
bgSize?: CSSProperties['backgroundSize'];
|
|
25
|
+
}
|
|
26
|
+
export type BackgroundImageComponentProps = MuiBoxProps<any, OverrideProps>;
|
|
27
|
+
export declare const BackgroundImageComponent: import("@emotion/styled").StyledComponent<import("@mui/system").BoxOwnProps<import("@mui/material").Theme> & Omit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme>> & import("@mui/system").MUIStyledCommonProps<import("@mui/material").Theme> & OverrideProps & import("@mui/material/OverridableComponent").CommonProps & Omit<any, keyof import("@mui/material/OverridableComponent").CommonProps | keyof import("@mui/system").BoxOwnProps<import("@mui/material").Theme> | keyof OverrideProps> & {
|
|
28
|
+
component?: React.ElementType | undefined;
|
|
29
|
+
}, {}, {}>;
|
|
30
|
+
export default BackgroundImageComponent;
|
|
@@ -0,0 +1,42 @@
|
|
|
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
|
+
*/ import { styled } from "@aglyn/shared-ui-theme";
|
|
17
|
+
import { _isEqualitySameType } from "@aglyn/shared-util-tools";
|
|
18
|
+
import { Box as MuiBox } from "@mui/material";
|
|
19
|
+
// Base on MuiBox (not 'div') so that the polymorphic `component` prop is
|
|
20
|
+
// handled natively by Box. styled('div') passes `component` straight to the
|
|
21
|
+
// DOM as an unknown attribute and never changes the rendered element type;
|
|
22
|
+
// styled(Box) converts `component` into an element-type change before
|
|
23
|
+
// rendering. MuiBox also owns sx/ownerState filtering, so we only need to
|
|
24
|
+
// block the background-image-specific custom props here.
|
|
25
|
+
export const BackgroundImageComponent = styled(MuiBox, {
|
|
26
|
+
name: 'BackgroundImage',
|
|
27
|
+
shouldForwardProp (propName) {
|
|
28
|
+
return !_isEqualitySameType(propName, null, 'url', 'parallax', 'bgPosition', 'bgSize', 'bgRepeat');
|
|
29
|
+
}
|
|
30
|
+
})(({ url, parallax, bgRepeat = 'no-repeat', bgPosition = 'bottom center', bgSize = 'cover' })=>({
|
|
31
|
+
backgroundColor: 'inherit',
|
|
32
|
+
backgroundRepeat: bgRepeat,
|
|
33
|
+
backgroundPosition: bgPosition,
|
|
34
|
+
backgroundSize: bgSize,
|
|
35
|
+
backgroundImage: `url(${url})`,
|
|
36
|
+
backgroundAttachment: parallax ? 'fixed' : undefined
|
|
37
|
+
}));
|
|
38
|
+
BackgroundImageComponent.displayName = 'BackgroundImageComponent';
|
|
39
|
+
BackgroundImageComponent.aglyn = true;
|
|
40
|
+
export default BackgroundImageComponent;
|
|
41
|
+
|
|
42
|
+
//# sourceMappingURL=background-image.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/shared/ui/jsx/src/lib/components/background-image.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 { styled } from '@aglyn/shared-ui-theme'\nimport { _isEqualitySameType } from '@aglyn/shared-util-tools'\nimport { Box as MuiBox, type BoxProps as MuiBoxProps } from '@mui/material'\nimport type { CSSProperties } from 'react'\n\ninterface OverrideProps {\n url: string\n parallax?: boolean\n bgPosition?: CSSProperties['backgroundPosition']\n bgRepeat?: CSSProperties['backgroundRepeat']\n bgSize?: CSSProperties['backgroundSize']\n}\n\nexport type BackgroundImageComponentProps = MuiBoxProps<any, OverrideProps>\n\n// Base on MuiBox (not 'div') so that the polymorphic `component` prop is\n// handled natively by Box. styled('div') passes `component` straight to the\n// DOM as an unknown attribute and never changes the rendered element type;\n// styled(Box) converts `component` into an element-type change before\n// rendering. MuiBox also owns sx/ownerState filtering, so we only need to\n// block the background-image-specific custom props here.\nexport const BackgroundImageComponent = styled(MuiBox, {\n name: 'BackgroundImage',\n shouldForwardProp(propName) {\n return !_isEqualitySameType(\n propName,\n null,\n 'url',\n 'parallax',\n 'bgPosition',\n 'bgSize',\n 'bgRepeat',\n )\n },\n})<BackgroundImageComponentProps>(\n ({\n url,\n parallax,\n bgRepeat = 'no-repeat',\n bgPosition = 'bottom center',\n bgSize = 'cover',\n }) => ({\n backgroundColor: 'inherit',\n backgroundRepeat: bgRepeat,\n backgroundPosition: bgPosition,\n backgroundSize: bgSize,\n backgroundImage: `url(${url})`,\n backgroundAttachment: parallax ? 'fixed' : undefined,\n }),\n)\n\nBackgroundImageComponent.displayName = 'BackgroundImageComponent'\nBackgroundImageComponent.aglyn = true\n\nexport default BackgroundImageComponent\n"],"names":["styled","_isEqualitySameType","Box","MuiBox","BackgroundImageComponent","name","shouldForwardProp","propName","url","parallax","bgRepeat","bgPosition","bgSize","backgroundColor","backgroundRepeat","backgroundPosition","backgroundSize","backgroundImage","backgroundAttachment","undefined","displayName","aglyn"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,MAAM,QAAQ,yBAAwB;AAC/C,SAASC,mBAAmB,QAAQ,2BAA0B;AAC9D,SAASC,OAAOC,MAAM,QAAsC,gBAAe;AAa3E,yEAAyE;AACzE,4EAA4E;AAC5E,2EAA2E;AAC3E,sEAAsE;AACtE,0EAA0E;AAC1E,yDAAyD;AACzD,OAAO,MAAMC,2BAA2BJ,OAAOG,QAAQ;IACrDE,MAAM;IACNC,mBAAkBC,QAAQ;QACxB,OAAO,CAACN,oBACNM,UACA,MACA,OACA,YACA,cACA,UACA;IAEJ;AACF,GACE,CAAC,EACCC,GAAG,EACHC,QAAQ,EACRC,WAAW,WAAW,EACtBC,aAAa,eAAe,EAC5BC,SAAS,OAAO,EACjB,GAAM,CAAA;QACLC,iBAAiB;QACjBC,kBAAkBJ;QAClBK,oBAAoBJ;QACpBK,gBAAgBJ;QAChBK,iBAAiB,CAAC,IAAI,EAAET,IAAI,CAAC,CAAC;QAC9BU,sBAAsBT,WAAW,UAAUU;IAC7C,CAAA,GACD;AAEDf,yBAAyBgB,WAAW,GAAG;AACvChB,yBAAyBiB,KAAK,GAAG;AAEjC,eAAejB,yBAAwB"}
|