@desynth/web-components-react 6.7.25-alpha.1

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.
@@ -0,0 +1,32 @@
1
+ /// <reference types="react" />
2
+ import type { JSX } from '@desynth/web-components/dist';
3
+ export declare const DesynthAccordion: import("react").ForwardRefExoticComponent<JSX.DesynthAccordion & Omit<import("react").HTMLAttributes<HTMLDesynthAccordionElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthAccordionElement>>;
4
+ export declare const DesynthAlert: import("react").ForwardRefExoticComponent<JSX.DesynthAlert & Omit<import("react").HTMLAttributes<HTMLDesynthAlertElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthAlertElement>>;
5
+ export declare const DesynthBreadcrumb: import("react").ForwardRefExoticComponent<JSX.DesynthBreadcrumb & Omit<import("react").HTMLAttributes<HTMLDesynthBreadcrumbElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthBreadcrumbElement>>;
6
+ export declare const DesynthButton: import("react").ForwardRefExoticComponent<JSX.DesynthButton & Omit<import("react").HTMLAttributes<HTMLDesynthButtonElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthButtonElement>>;
7
+ export declare const DesynthButtonSlider: import("react").ForwardRefExoticComponent<JSX.DesynthButtonSlider & Omit<import("react").HTMLAttributes<HTMLDesynthButtonSliderElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthButtonSliderElement>>;
8
+ export declare const DesynthCard: import("react").ForwardRefExoticComponent<JSX.DesynthCard & Omit<import("react").HTMLAttributes<HTMLDesynthCardElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthCardElement>>;
9
+ export declare const DesynthCheckbox: import("react").ForwardRefExoticComponent<JSX.DesynthCheckbox & Omit<import("react").HTMLAttributes<HTMLDesynthCheckboxElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthCheckboxElement>>;
10
+ export declare const DesynthDatePicker: import("react").ForwardRefExoticComponent<JSX.DesynthDatePicker & Omit<import("react").HTMLAttributes<HTMLDesynthDatePickerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthDatePickerElement>>;
11
+ export declare const DesynthDivider: import("react").ForwardRefExoticComponent<JSX.DesynthDivider & Omit<import("react").HTMLAttributes<HTMLDesynthDividerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthDividerElement>>;
12
+ export declare const DesynthDrawer: import("react").ForwardRefExoticComponent<JSX.DesynthDrawer & Omit<import("react").HTMLAttributes<HTMLDesynthDrawerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthDrawerElement>>;
13
+ export declare const DesynthDropFile: import("react").ForwardRefExoticComponent<JSX.DesynthDropFile & Omit<import("react").HTMLAttributes<HTMLDesynthDropFileElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthDropFileElement>>;
14
+ export declare const DesynthForm: import("react").ForwardRefExoticComponent<JSX.DesynthForm & Omit<import("react").HTMLAttributes<HTMLDesynthFormElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthFormElement>>;
15
+ export declare const DesynthGrid: import("react").ForwardRefExoticComponent<JSX.DesynthGrid & Omit<import("react").HTMLAttributes<HTMLDesynthGridElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthGridElement>>;
16
+ export declare const DesynthHeader: import("react").ForwardRefExoticComponent<JSX.DesynthHeader & Omit<import("react").HTMLAttributes<HTMLDesynthHeaderElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthHeaderElement>>;
17
+ export declare const DesynthList: import("react").ForwardRefExoticComponent<JSX.DesynthList & Omit<import("react").HTMLAttributes<HTMLDesynthListElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthListElement>>;
18
+ export declare const DesynthLoader: import("react").ForwardRefExoticComponent<JSX.DesynthLoader & Omit<import("react").HTMLAttributes<HTMLDesynthLoaderElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthLoaderElement>>;
19
+ export declare const DesynthModal: import("react").ForwardRefExoticComponent<JSX.DesynthModal & Omit<import("react").HTMLAttributes<HTMLDesynthModalElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthModalElement>>;
20
+ export declare const DesynthMultiStepper: import("react").ForwardRefExoticComponent<JSX.DesynthMultiStepper & Omit<import("react").HTMLAttributes<HTMLDesynthMultiStepperElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthMultiStepperElement>>;
21
+ export declare const DesynthPaper: import("react").ForwardRefExoticComponent<JSX.DesynthPaper & Omit<import("react").HTMLAttributes<HTMLDesynthPaperElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthPaperElement>>;
22
+ export declare const DesynthRating: import("react").ForwardRefExoticComponent<JSX.DesynthRating & Omit<import("react").HTMLAttributes<HTMLDesynthRatingElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthRatingElement>>;
23
+ export declare const DesynthRenderer: import("react").ForwardRefExoticComponent<JSX.DesynthRenderer & Omit<import("react").HTMLAttributes<HTMLDesynthRendererElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthRendererElement>>;
24
+ export declare const DesynthSelect: import("react").ForwardRefExoticComponent<JSX.DesynthSelect & Omit<import("react").HTMLAttributes<HTMLDesynthSelectElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthSelectElement>>;
25
+ export declare const DesynthStepStepper: import("react").ForwardRefExoticComponent<JSX.DesynthStepStepper & Omit<import("react").HTMLAttributes<HTMLDesynthStepStepperElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthStepStepperElement>>;
26
+ export declare const DesynthSwitch: import("react").ForwardRefExoticComponent<JSX.DesynthSwitch & Omit<import("react").HTMLAttributes<HTMLDesynthSwitchElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthSwitchElement>>;
27
+ export declare const DesynthTable: import("react").ForwardRefExoticComponent<JSX.DesynthTable & Omit<import("react").HTMLAttributes<HTMLDesynthTableElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthTableElement>>;
28
+ export declare const DesynthTextArea: import("react").ForwardRefExoticComponent<JSX.DesynthTextArea & Omit<import("react").HTMLAttributes<HTMLDesynthTextAreaElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthTextAreaElement>>;
29
+ export declare const DesynthTextInput: import("react").ForwardRefExoticComponent<JSX.DesynthTextInput & Omit<import("react").HTMLAttributes<HTMLDesynthTextInputElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthTextInputElement>>;
30
+ export declare const DesynthTooltip: import("react").ForwardRefExoticComponent<JSX.DesynthTooltip & Omit<import("react").HTMLAttributes<HTMLDesynthTooltipElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLDesynthTooltipElement>>;
31
+ export declare const HorizontalCards: import("react").ForwardRefExoticComponent<JSX.HorizontalCards & Omit<import("react").HTMLAttributes<HTMLHorizontalCardsElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLHorizontalCardsElement>>;
32
+ export declare const HtmlEditor: import("react").ForwardRefExoticComponent<JSX.HtmlEditor & Omit<import("react").HTMLAttributes<HTMLHtmlEditorElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLHtmlEditorElement>>;
@@ -0,0 +1,64 @@
1
+ /* eslint-disable */
2
+ /* tslint:disable */
3
+ /* auto-generated react proxies */
4
+ import { createReactComponent } from './react-component-lib';
5
+ import { defineCustomElement as defineDesynthAccordion } from '@desynth/web-components/dist/desynth-accordion.js';
6
+ import { defineCustomElement as defineDesynthAlert } from '@desynth/web-components/dist/desynth-alert.js';
7
+ import { defineCustomElement as defineDesynthBreadcrumb } from '@desynth/web-components/dist/desynth-breadcrumb.js';
8
+ import { defineCustomElement as defineDesynthButton } from '@desynth/web-components/dist/desynth-button.js';
9
+ import { defineCustomElement as defineDesynthButtonSlider } from '@desynth/web-components/dist/desynth-button-slider.js';
10
+ import { defineCustomElement as defineDesynthCard } from '@desynth/web-components/dist/desynth-card.js';
11
+ import { defineCustomElement as defineDesynthCheckbox } from '@desynth/web-components/dist/desynth-checkbox.js';
12
+ import { defineCustomElement as defineDesynthDatePicker } from '@desynth/web-components/dist/desynth-date-picker.js';
13
+ import { defineCustomElement as defineDesynthDivider } from '@desynth/web-components/dist/desynth-divider.js';
14
+ import { defineCustomElement as defineDesynthDrawer } from '@desynth/web-components/dist/desynth-drawer.js';
15
+ import { defineCustomElement as defineDesynthDropFile } from '@desynth/web-components/dist/desynth-drop-file.js';
16
+ import { defineCustomElement as defineDesynthForm } from '@desynth/web-components/dist/desynth-form.js';
17
+ import { defineCustomElement as defineDesynthGrid } from '@desynth/web-components/dist/desynth-grid.js';
18
+ import { defineCustomElement as defineDesynthHeader } from '@desynth/web-components/dist/desynth-header.js';
19
+ import { defineCustomElement as defineDesynthList } from '@desynth/web-components/dist/desynth-list.js';
20
+ import { defineCustomElement as defineDesynthLoader } from '@desynth/web-components/dist/desynth-loader.js';
21
+ import { defineCustomElement as defineDesynthModal } from '@desynth/web-components/dist/desynth-modal.js';
22
+ import { defineCustomElement as defineDesynthMultiStepper } from '@desynth/web-components/dist/desynth-multi-stepper.js';
23
+ import { defineCustomElement as defineDesynthPaper } from '@desynth/web-components/dist/desynth-paper.js';
24
+ import { defineCustomElement as defineDesynthRating } from '@desynth/web-components/dist/desynth-rating.js';
25
+ import { defineCustomElement as defineDesynthRenderer } from '@desynth/web-components/dist/desynth-renderer.js';
26
+ import { defineCustomElement as defineDesynthSelect } from '@desynth/web-components/dist/desynth-select.js';
27
+ import { defineCustomElement as defineDesynthStepStepper } from '@desynth/web-components/dist/desynth-step-stepper.js';
28
+ import { defineCustomElement as defineDesynthSwitch } from '@desynth/web-components/dist/desynth-switch.js';
29
+ import { defineCustomElement as defineDesynthTable } from '@desynth/web-components/dist/desynth-table.js';
30
+ import { defineCustomElement as defineDesynthTextArea } from '@desynth/web-components/dist/desynth-text-area.js';
31
+ import { defineCustomElement as defineDesynthTextInput } from '@desynth/web-components/dist/desynth-text-input.js';
32
+ import { defineCustomElement as defineDesynthTooltip } from '@desynth/web-components/dist/desynth-tooltip.js';
33
+ import { defineCustomElement as defineHorizontalCards } from '@desynth/web-components/dist/horizontal-cards.js';
34
+ import { defineCustomElement as defineHtmlEditor } from '@desynth/web-components/dist/html-editor.js';
35
+ export const DesynthAccordion = /*@__PURE__*/ createReactComponent('desynth-accordion', undefined, undefined, defineDesynthAccordion);
36
+ export const DesynthAlert = /*@__PURE__*/ createReactComponent('desynth-alert', undefined, undefined, defineDesynthAlert);
37
+ export const DesynthBreadcrumb = /*@__PURE__*/ createReactComponent('desynth-breadcrumb', undefined, undefined, defineDesynthBreadcrumb);
38
+ export const DesynthButton = /*@__PURE__*/ createReactComponent('desynth-button', undefined, undefined, defineDesynthButton);
39
+ export const DesynthButtonSlider = /*@__PURE__*/ createReactComponent('desynth-button-slider', undefined, undefined, defineDesynthButtonSlider);
40
+ export const DesynthCard = /*@__PURE__*/ createReactComponent('desynth-card', undefined, undefined, defineDesynthCard);
41
+ export const DesynthCheckbox = /*@__PURE__*/ createReactComponent('desynth-checkbox', undefined, undefined, defineDesynthCheckbox);
42
+ export const DesynthDatePicker = /*@__PURE__*/ createReactComponent('desynth-date-picker', undefined, undefined, defineDesynthDatePicker);
43
+ export const DesynthDivider = /*@__PURE__*/ createReactComponent('desynth-divider', undefined, undefined, defineDesynthDivider);
44
+ export const DesynthDrawer = /*@__PURE__*/ createReactComponent('desynth-drawer', undefined, undefined, defineDesynthDrawer);
45
+ export const DesynthDropFile = /*@__PURE__*/ createReactComponent('desynth-drop-file', undefined, undefined, defineDesynthDropFile);
46
+ export const DesynthForm = /*@__PURE__*/ createReactComponent('desynth-form', undefined, undefined, defineDesynthForm);
47
+ export const DesynthGrid = /*@__PURE__*/ createReactComponent('desynth-grid', undefined, undefined, defineDesynthGrid);
48
+ export const DesynthHeader = /*@__PURE__*/ createReactComponent('desynth-header', undefined, undefined, defineDesynthHeader);
49
+ export const DesynthList = /*@__PURE__*/ createReactComponent('desynth-list', undefined, undefined, defineDesynthList);
50
+ export const DesynthLoader = /*@__PURE__*/ createReactComponent('desynth-loader', undefined, undefined, defineDesynthLoader);
51
+ export const DesynthModal = /*@__PURE__*/ createReactComponent('desynth-modal', undefined, undefined, defineDesynthModal);
52
+ export const DesynthMultiStepper = /*@__PURE__*/ createReactComponent('desynth-multi-stepper', undefined, undefined, defineDesynthMultiStepper);
53
+ export const DesynthPaper = /*@__PURE__*/ createReactComponent('desynth-paper', undefined, undefined, defineDesynthPaper);
54
+ export const DesynthRating = /*@__PURE__*/ createReactComponent('desynth-rating', undefined, undefined, defineDesynthRating);
55
+ export const DesynthRenderer = /*@__PURE__*/ createReactComponent('desynth-renderer', undefined, undefined, defineDesynthRenderer);
56
+ export const DesynthSelect = /*@__PURE__*/ createReactComponent('desynth-select', undefined, undefined, defineDesynthSelect);
57
+ export const DesynthStepStepper = /*@__PURE__*/ createReactComponent('desynth-step-stepper', undefined, undefined, defineDesynthStepStepper);
58
+ export const DesynthSwitch = /*@__PURE__*/ createReactComponent('desynth-switch', undefined, undefined, defineDesynthSwitch);
59
+ export const DesynthTable = /*@__PURE__*/ createReactComponent('desynth-table', undefined, undefined, defineDesynthTable);
60
+ export const DesynthTextArea = /*@__PURE__*/ createReactComponent('desynth-text-area', undefined, undefined, defineDesynthTextArea);
61
+ export const DesynthTextInput = /*@__PURE__*/ createReactComponent('desynth-text-input', undefined, undefined, defineDesynthTextInput);
62
+ export const DesynthTooltip = /*@__PURE__*/ createReactComponent('desynth-tooltip', undefined, undefined, defineDesynthTooltip);
63
+ export const HorizontalCards = /*@__PURE__*/ createReactComponent('horizontal-cards', undefined, undefined, defineHorizontalCards);
64
+ export const HtmlEditor = /*@__PURE__*/ createReactComponent('html-editor', undefined, undefined, defineHtmlEditor);
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ export interface HTMLStencilElement extends HTMLElement {
3
+ componentOnReady(): Promise<this>;
4
+ }
5
+ interface StencilReactInternalProps<ElementType> extends React.HTMLAttributes<ElementType> {
6
+ forwardedRef: React.RefObject<ElementType>;
7
+ ref?: React.Ref<any>;
8
+ }
9
+ export declare const createReactComponent: <PropType, ElementType extends HTMLStencilElement, ContextStateType = {}, ExpandedPropsTypes = {}>(tagName: string, ReactComponentContext?: React.Context<ContextStateType> | undefined, manipulatePropsFunction?: ((originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes) | undefined, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
10
+ export {};
@@ -0,0 +1,74 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React, { createElement } from 'react';
13
+ import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
14
+ export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
15
+ if (defineCustomElement !== undefined) {
16
+ defineCustomElement();
17
+ }
18
+ const displayName = dashToPascalCase(tagName);
19
+ const ReactComponent = class extends React.Component {
20
+ constructor(props) {
21
+ super(props);
22
+ this.setComponentElRef = (element) => {
23
+ this.componentEl = element;
24
+ };
25
+ }
26
+ componentDidMount() {
27
+ this.componentDidUpdate(this.props);
28
+ }
29
+ componentDidUpdate(prevProps) {
30
+ attachProps(this.componentEl, this.props, prevProps);
31
+ }
32
+ render() {
33
+ const _a = this.props, { children, forwardedRef, style, className, ref } = _a, cProps = __rest(_a, ["children", "forwardedRef", "style", "className", "ref"]);
34
+ let propsToPass = Object.keys(cProps).reduce((acc, name) => {
35
+ const value = cProps[name];
36
+ if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
37
+ const eventName = name.substring(2).toLowerCase();
38
+ if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
39
+ acc[name] = value;
40
+ }
41
+ }
42
+ else {
43
+ // we should only render strings, booleans, and numbers as attrs in html.
44
+ // objects, functions, arrays etc get synced via properties on mount.
45
+ const type = typeof value;
46
+ if (type === 'string' || type === 'boolean' || type === 'number') {
47
+ acc[camelToDashCase(name)] = value;
48
+ }
49
+ }
50
+ return acc;
51
+ }, {});
52
+ if (manipulatePropsFunction) {
53
+ propsToPass = manipulatePropsFunction(this.props, propsToPass);
54
+ }
55
+ const newProps = Object.assign(Object.assign({}, propsToPass), { ref: mergeRefs(forwardedRef, this.setComponentElRef), style });
56
+ /**
57
+ * We use createElement here instead of
58
+ * React.createElement to work around a
59
+ * bug in Vite (https://github.com/vitejs/vite/issues/6104).
60
+ * React.createElement causes all elements to be rendered
61
+ * as <tagname> instead of the actual Web Component.
62
+ */
63
+ return createElement(tagName, newProps, children);
64
+ }
65
+ static get displayName() {
66
+ return displayName;
67
+ }
68
+ };
69
+ // If context was passed to createReactComponent then conditionally add it to the Component Class
70
+ if (ReactComponentContext) {
71
+ ReactComponent.contextType = ReactComponentContext;
72
+ }
73
+ return createForwardRef(ReactComponent, displayName);
74
+ };
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import { OverlayEventDetail } from './interfaces';
3
+ import { StencilReactForwardedRef } from './utils';
4
+ interface OverlayElement extends HTMLElement {
5
+ present: () => Promise<void>;
6
+ dismiss: (data?: any, role?: string | undefined) => Promise<boolean>;
7
+ }
8
+ export interface ReactOverlayProps {
9
+ children?: React.ReactNode;
10
+ isOpen: boolean;
11
+ onDidDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
12
+ onDidPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
13
+ onWillDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
14
+ onWillPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
15
+ }
16
+ export declare const createOverlayComponent: <OverlayComponent extends object, OverlayType extends OverlayElement>(tagName: string, controller: {
17
+ create: (options: any) => Promise<OverlayType>;
18
+ }, customElement?: any) => React.ForwardRefExoticComponent<React.PropsWithoutRef<OverlayComponent & ReactOverlayProps & {
19
+ forwardedRef?: StencilReactForwardedRef<OverlayType> | undefined;
20
+ }> & React.RefAttributes<OverlayType>>;
21
+ export {};
@@ -0,0 +1,95 @@
1
+ var __rest = (this && this.__rest) || function (s, e) {
2
+ var t = {};
3
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
+ t[p] = s[p];
5
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
+ t[p[i]] = s[p[i]];
9
+ }
10
+ return t;
11
+ };
12
+ import React from 'react';
13
+ import ReactDOM from 'react-dom';
14
+ import { attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
15
+ export const createOverlayComponent = (tagName, controller, customElement) => {
16
+ defineCustomElement(tagName, customElement);
17
+ const displayName = dashToPascalCase(tagName);
18
+ const didDismissEventName = `on${displayName}DidDismiss`;
19
+ const didPresentEventName = `on${displayName}DidPresent`;
20
+ const willDismissEventName = `on${displayName}WillDismiss`;
21
+ const willPresentEventName = `on${displayName}WillPresent`;
22
+ let isDismissing = false;
23
+ class Overlay extends React.Component {
24
+ constructor(props) {
25
+ super(props);
26
+ if (typeof document !== 'undefined') {
27
+ this.el = document.createElement('div');
28
+ }
29
+ this.handleDismiss = this.handleDismiss.bind(this);
30
+ }
31
+ static get displayName() {
32
+ return displayName;
33
+ }
34
+ componentDidMount() {
35
+ if (this.props.isOpen) {
36
+ this.present();
37
+ }
38
+ }
39
+ componentWillUnmount() {
40
+ if (this.overlay) {
41
+ this.overlay.dismiss();
42
+ }
43
+ }
44
+ handleDismiss(event) {
45
+ if (this.props.onDidDismiss) {
46
+ this.props.onDidDismiss(event);
47
+ }
48
+ setRef(this.props.forwardedRef, null);
49
+ }
50
+ shouldComponentUpdate(nextProps) {
51
+ // Check if the overlay component is about to dismiss
52
+ if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
53
+ isDismissing = true;
54
+ }
55
+ return true;
56
+ }
57
+ async componentDidUpdate(prevProps) {
58
+ if (this.overlay) {
59
+ attachProps(this.overlay, this.props, prevProps);
60
+ }
61
+ if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
62
+ this.present(prevProps);
63
+ }
64
+ if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
65
+ await this.overlay.dismiss();
66
+ isDismissing = false;
67
+ /**
68
+ * Now that the overlay is dismissed
69
+ * we need to render again so that any
70
+ * inner components will be unmounted
71
+ */
72
+ this.forceUpdate();
73
+ }
74
+ }
75
+ async present(prevProps) {
76
+ const _a = this.props, { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent } = _a, cProps = __rest(_a, ["children", "isOpen", "onDidDismiss", "onDidPresent", "onWillDismiss", "onWillPresent"]);
77
+ const elementProps = Object.assign(Object.assign({}, cProps), { ref: this.props.forwardedRef, [didDismissEventName]: this.handleDismiss, [didPresentEventName]: (e) => this.props.onDidPresent && this.props.onDidPresent(e), [willDismissEventName]: (e) => this.props.onWillDismiss && this.props.onWillDismiss(e), [willPresentEventName]: (e) => this.props.onWillPresent && this.props.onWillPresent(e) });
78
+ this.overlay = await controller.create(Object.assign(Object.assign({}, elementProps), { component: this.el, componentProps: {} }));
79
+ setRef(this.props.forwardedRef, this.overlay);
80
+ attachProps(this.overlay, elementProps, prevProps);
81
+ await this.overlay.present();
82
+ }
83
+ render() {
84
+ /**
85
+ * Continue to render the component even when
86
+ * overlay is dismissing otherwise component
87
+ * will be hidden before animation is done.
88
+ */
89
+ return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
90
+ }
91
+ }
92
+ return React.forwardRef((props, ref) => {
93
+ return React.createElement(Overlay, Object.assign({}, props, { forwardedRef: ref }));
94
+ });
95
+ };
@@ -0,0 +1,2 @@
1
+ export { createReactComponent } from './createComponent';
2
+ export { createOverlayComponent } from './createOverlayComponent';
@@ -0,0 +1,2 @@
1
+ export { createReactComponent } from './createComponent';
2
+ export { createOverlayComponent } from './createOverlayComponent';
@@ -0,0 +1,29 @@
1
+ export interface EventEmitter<T = any> {
2
+ emit: (data?: T) => CustomEvent<T>;
3
+ }
4
+ export interface StyleReactProps {
5
+ class?: string;
6
+ className?: string;
7
+ style?: {
8
+ [key: string]: any;
9
+ };
10
+ }
11
+ export interface OverlayEventDetail<T = any> {
12
+ data?: T;
13
+ role?: string;
14
+ }
15
+ export interface OverlayInterface {
16
+ el: HTMLElement;
17
+ animated: boolean;
18
+ keyboardClose: boolean;
19
+ overlayIndex: number;
20
+ presented: boolean;
21
+ enterAnimation?: any;
22
+ leaveAnimation?: any;
23
+ didPresent: EventEmitter<void>;
24
+ willPresent: EventEmitter<void>;
25
+ willDismiss: EventEmitter<OverlayEventDetail>;
26
+ didDismiss: EventEmitter<OverlayEventDetail>;
27
+ present(): Promise<void>;
28
+ dismiss(data?: any, role?: string): Promise<boolean>;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ export declare const attachProps: (node: HTMLElement, newProps: any, oldProps?: any) => void;
2
+ export declare const getClassName: (classList: DOMTokenList, newProps: any, oldProps: any) => string;
3
+ /**
4
+ * Transforms a React event name to a browser event name.
5
+ */
6
+ export declare const transformReactEventName: (eventNameSuffix: string) => string;
7
+ /**
8
+ * Checks if an event is supported in the current execution environment.
9
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
10
+ */
11
+ export declare const isCoveredByReact: (eventNameSuffix: string) => boolean;
12
+ export declare const syncEvent: (node: Element & {
13
+ __events?: {
14
+ [key: string]: ((e: Event) => any) | undefined;
15
+ } | undefined;
16
+ }, eventName: string, newEventHandler?: ((e: Event) => any) | undefined) => void;
@@ -0,0 +1,107 @@
1
+ import { camelToDashCase } from './case';
2
+ export const attachProps = (node, newProps, oldProps = {}) => {
3
+ // some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
4
+ if (node instanceof Element) {
5
+ // add any classes in className to the class list
6
+ const className = getClassName(node.classList, newProps, oldProps);
7
+ if (className !== '') {
8
+ node.className = className;
9
+ }
10
+ Object.keys(newProps).forEach((name) => {
11
+ if (name === 'children' ||
12
+ name === 'style' ||
13
+ name === 'ref' ||
14
+ name === 'class' ||
15
+ name === 'className' ||
16
+ name === 'forwardedRef') {
17
+ return;
18
+ }
19
+ if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
20
+ const eventName = name.substring(2);
21
+ const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
22
+ if (!isCoveredByReact(eventNameLc)) {
23
+ syncEvent(node, eventNameLc, newProps[name]);
24
+ }
25
+ }
26
+ else {
27
+ node[name] = newProps[name];
28
+ const propType = typeof newProps[name];
29
+ if (propType === 'string') {
30
+ node.setAttribute(camelToDashCase(name), newProps[name]);
31
+ }
32
+ }
33
+ });
34
+ }
35
+ };
36
+ export const getClassName = (classList, newProps, oldProps) => {
37
+ const newClassProp = newProps.className || newProps.class;
38
+ const oldClassProp = oldProps.className || oldProps.class;
39
+ // map the classes to Maps for performance
40
+ const currentClasses = arrayToMap(classList);
41
+ const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
42
+ const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
43
+ const finalClassNames = [];
44
+ // loop through each of the current classes on the component
45
+ // to see if it should be a part of the classNames added
46
+ currentClasses.forEach((currentClass) => {
47
+ if (incomingPropClasses.has(currentClass)) {
48
+ // add it as its already included in classnames coming in from newProps
49
+ finalClassNames.push(currentClass);
50
+ incomingPropClasses.delete(currentClass);
51
+ }
52
+ else if (!oldPropClasses.has(currentClass)) {
53
+ // add it as it has NOT been removed by user
54
+ finalClassNames.push(currentClass);
55
+ }
56
+ });
57
+ incomingPropClasses.forEach((s) => finalClassNames.push(s));
58
+ return finalClassNames.join(' ');
59
+ };
60
+ /**
61
+ * Transforms a React event name to a browser event name.
62
+ */
63
+ export const transformReactEventName = (eventNameSuffix) => {
64
+ switch (eventNameSuffix) {
65
+ case 'doubleclick':
66
+ return 'dblclick';
67
+ }
68
+ return eventNameSuffix;
69
+ };
70
+ /**
71
+ * Checks if an event is supported in the current execution environment.
72
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
73
+ */
74
+ export const isCoveredByReact = (eventNameSuffix) => {
75
+ if (typeof document === 'undefined') {
76
+ return true;
77
+ }
78
+ else {
79
+ const eventName = 'on' + transformReactEventName(eventNameSuffix);
80
+ let isSupported = eventName in document;
81
+ if (!isSupported) {
82
+ const element = document.createElement('div');
83
+ element.setAttribute(eventName, 'return;');
84
+ isSupported = typeof element[eventName] === 'function';
85
+ }
86
+ return isSupported;
87
+ }
88
+ };
89
+ export const syncEvent = (node, eventName, newEventHandler) => {
90
+ const eventStore = node.__events || (node.__events = {});
91
+ const oldEventHandler = eventStore[eventName];
92
+ // Remove old listener so they don't double up.
93
+ if (oldEventHandler) {
94
+ node.removeEventListener(eventName, oldEventHandler);
95
+ }
96
+ // Bind new listener.
97
+ node.addEventListener(eventName, (eventStore[eventName] = function handler(e) {
98
+ if (newEventHandler) {
99
+ newEventHandler.call(this, e);
100
+ }
101
+ }));
102
+ };
103
+ const arrayToMap = (arr) => {
104
+ const map = new Map();
105
+ arr.forEach((s) => map.set(s, s));
106
+ return map;
107
+ };
@@ -0,0 +1,2 @@
1
+ export declare const dashToPascalCase: (str: string) => string;
2
+ export declare const camelToDashCase: (str: string) => string;
@@ -0,0 +1,6 @@
1
+ export const dashToPascalCase = (str) => str
2
+ .toLowerCase()
3
+ .split('-')
4
+ .map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
5
+ .join('');
6
+ export const camelToDashCase = (str) => str.replace(/([A-Z])/g, (m) => `-${m[0].toLowerCase()}`);
@@ -0,0 +1,2 @@
1
+ export declare const isDevMode: () => boolean;
2
+ export declare const deprecationWarning: (key: string, message: string) => void;
@@ -0,0 +1,12 @@
1
+ export const isDevMode = () => {
2
+ return process && process.env && process.env.NODE_ENV === 'development';
3
+ };
4
+ const warnings = {};
5
+ export const deprecationWarning = (key, message) => {
6
+ if (isDevMode()) {
7
+ if (!warnings[key]) {
8
+ console.warn(message);
9
+ warnings[key] = true;
10
+ }
11
+ }
12
+ };
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import type { StyleReactProps } from '../interfaces';
3
+ export type StencilReactExternalProps<PropType, ElementType> = PropType & Omit<React.HTMLAttributes<ElementType>, 'style'> & StyleReactProps;
4
+ export type StencilReactForwardedRef<T> = ((instance: T | null) => void) | React.MutableRefObject<T | null> | null;
5
+ export declare const setRef: (ref: StencilReactForwardedRef<any> | React.Ref<any> | undefined, value: any) => void;
6
+ export declare const mergeRefs: (...refs: (StencilReactForwardedRef<any> | React.Ref<any> | undefined)[]) => React.RefCallback<any>;
7
+ export declare const createForwardRef: <PropType, ElementType>(ReactComponent: any, displayName: string) => React.ForwardRefExoticComponent<React.PropsWithoutRef<StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
8
+ export declare const defineCustomElement: (tagName: string, customElement: any) => void;
9
+ export * from './attachProps';
10
+ export * from './case';
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ export const setRef = (ref, value) => {
3
+ if (typeof ref === 'function') {
4
+ ref(value);
5
+ }
6
+ else if (ref != null) {
7
+ // Cast as a MutableRef so we can assign current
8
+ ref.current = value;
9
+ }
10
+ };
11
+ export const mergeRefs = (...refs) => {
12
+ return (value) => {
13
+ refs.forEach((ref) => {
14
+ setRef(ref, value);
15
+ });
16
+ };
17
+ };
18
+ export const createForwardRef = (ReactComponent, displayName) => {
19
+ const forwardRef = (props, ref) => {
20
+ return React.createElement(ReactComponent, Object.assign({}, props, { forwardedRef: ref }));
21
+ };
22
+ forwardRef.displayName = displayName;
23
+ return React.forwardRef(forwardRef);
24
+ };
25
+ export const defineCustomElement = (tagName, customElement) => {
26
+ if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
27
+ customElements.define(tagName, customElement);
28
+ }
29
+ };
30
+ export * from './attachProps';
31
+ export * from './case';
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@desynth/web-components-react",
3
+ "sideEffects": false,
4
+ "version": "06.07.25-alpha.1",
5
+ "description": "React proxy for @desynth/web-components",
6
+ "license": "MPL-2.0",
7
+ "homepage": "https://github.com/desynth/desynth-web-components#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/desynth/desynth-web-components.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/desynth/desynth-web-components/issues"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "scripts": {
19
+ "build": "npm run tsc",
20
+ "tsc": "tsc -p ."
21
+ },
22
+ "main": "./dist/index.js",
23
+ "module": "./dist/index.js",
24
+ "types": "./dist/index.d.ts",
25
+ "files": [
26
+ "dist/"
27
+ ],
28
+ "devDependencies": {
29
+ "@types/react": "18.3.3",
30
+ "@types/react-dom": "18.3.0"
31
+ },
32
+ "dependencies": {
33
+ "react": ">=18.3.1",
34
+ "react-dom": ">=18.3.1",
35
+ "typescript": "5.2.2"
36
+ },
37
+ "peerDependencies": {
38
+ "react": ">=18.3.1",
39
+ "react-dom": ">=18.3.1"
40
+ }
41
+ }
package/readme.md ADDED
@@ -0,0 +1,15 @@
1
+ # desynth-web-components - React Proxy
2
+ This is the desynth utility Stencil web component library for general purposes
3
+
4
+ ```bash
5
+ HTML Web Components
6
+ Compatible with:
7
+ ReactJS
8
+ Vue
9
+ Angular
10
+ Svelte
11
+ Ionic
12
+ ```
13
+ ## General Solution's Architecture Design
14
+ ![Architecture Diagram](https://github.com/desynth/desynth-java-utils/assets/61949272/474bf10f-73cf-474c-a34b-45269dc508a2)
15
+