@beeq/react 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -0
- package/package.json +26 -0
- package/src/components.d.ts +39 -0
- package/src/components.js +45 -0
- package/src/components.js.map +1 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +4 -0
- package/src/index.js.map +1 -0
- package/src/react-component-lib/createComponent.d.ts +10 -0
- package/src/react-component-lib/createComponent.js +68 -0
- package/src/react-component-lib/createComponent.js.map +1 -0
- package/src/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/src/react-component-lib/createOverlayComponent.js +97 -0
- package/src/react-component-lib/createOverlayComponent.js.map +1 -0
- package/src/react-component-lib/index.d.ts +2 -0
- package/src/react-component-lib/index.js +3 -0
- package/src/react-component-lib/index.js.map +1 -0
- package/src/react-component-lib/interfaces.d.ts +29 -0
- package/src/react-component-lib/interfaces.js +2 -0
- package/src/react-component-lib/interfaces.js.map +1 -0
- package/src/react-component-lib/utils/attachProps.d.ts +16 -0
- package/src/react-component-lib/utils/attachProps.js +108 -0
- package/src/react-component-lib/utils/attachProps.js.map +1 -0
- package/src/react-component-lib/utils/case.d.ts +2 -0
- package/src/react-component-lib/utils/case.js +7 -0
- package/src/react-component-lib/utils/case.js.map +1 -0
- package/src/react-component-lib/utils/dev.d.ts +2 -0
- package/src/react-component-lib/utils/dev.js +13 -0
- package/src/react-component-lib/utils/dev.js.map +1 -0
- package/src/react-component-lib/utils/index.d.ts +10 -0
- package/src/react-component-lib/utils/index.js +33 -0
- package/src/react-component-lib/utils/index.js.map +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# React Wrapper for BEEQ
|
|
2
|
+
|
|
3
|
+
A lightweight utility that wraps BEEQ custom elements ("web components") so they can be used like native React components.
|
|
4
|
+
|
|
5
|
+
## Package installation
|
|
6
|
+
|
|
7
|
+
- install the package
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
npm install @bee-q/react
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- update the package
|
|
14
|
+
|
|
15
|
+
```
|
|
16
|
+
npm install @bee-q/react@latest
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
if `@bee-q/core` package is installed you should update both
|
|
20
|
+
|
|
21
|
+
```
|
|
22
|
+
npm install @bee-q/{core,react}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Add BEEQ styles and assets
|
|
26
|
+
|
|
27
|
+
Make sure that BEEQ main style is imported into your application's main style file:
|
|
28
|
+
|
|
29
|
+
```css
|
|
30
|
+
@import "@bee-q/core/dist/bee-q/bee-q";
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
> ❗️The icons SVG are shipped in a separate folder. Depending on your React stack, your project will need to include `node_modules/@bee-q/core/dist/bee-q/svg` in the build in such a way that it respond to: `http://<domain>/svg`
|
|
34
|
+
|
|
35
|
+
## Usage
|
|
36
|
+
|
|
37
|
+
```jsx
|
|
38
|
+
import React from 'react';
|
|
39
|
+
import { BqButton } from '@bee-q/react';
|
|
40
|
+
|
|
41
|
+
function App() {
|
|
42
|
+
const handleButtonClick = (ev: CustomEvent) => {
|
|
43
|
+
console.log(ev.detail);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
<BqButton appearance="primary" onBqClick={handleButtonClick}>
|
|
48
|
+
Click Me
|
|
49
|
+
</BqButton>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export default App;
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Why is this necessary?
|
|
57
|
+
|
|
58
|
+
React and custom elements don't play nicely together. The problem is best described by [Custom Elements Everywhere](https://custom-elements-everywhere.com/#react):
|
|
59
|
+
|
|
60
|
+
> **Handling data**
|
|
61
|
+
>
|
|
62
|
+
> React passes all data to Custom Elements in the form of HTML attributes. For primitive data this is fine, but the system breaks down when passing rich data, like objects or arrays. In these instances you end up with stringified values like some-attr="[object Object]" which can't actually be used.
|
|
63
|
+
>
|
|
64
|
+
> **Handling events**
|
|
65
|
+
>
|
|
66
|
+
> Because React implements its own synthetic event system, it cannot listen for DOM events coming from Custom Elements without the use of a workaround. Developers will need to reference their Custom Elements using a ref and manually attach event listeners with addEventListener. This makes working with Custom Elements cumbersome.
|
|
67
|
+
|
|
68
|
+
This utility solves these problems by exposing a native React component that maps properties and events to the underlying custom element. ✨
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@beeq/react",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"license": "Apache-2.0",
|
|
5
|
+
"description": "React specific wrapper for BEEQ Design System components",
|
|
6
|
+
"main": "./src/index.js",
|
|
7
|
+
"module": "./src/index.js",
|
|
8
|
+
"types": "./src/index.d.ts",
|
|
9
|
+
"dependencies": {
|
|
10
|
+
"@beeq/core": "*"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"react": ">=18.0.0",
|
|
14
|
+
"react-dom": ">=18.0.0",
|
|
15
|
+
"tslib": "^2.6.2"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/Endava/BEEQ"
|
|
20
|
+
},
|
|
21
|
+
"publishConfig": {
|
|
22
|
+
"access": "public",
|
|
23
|
+
"registry": "https://registry.npmjs.org"
|
|
24
|
+
},
|
|
25
|
+
"type": "module"
|
|
26
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { JSX } from '@beeq/core';
|
|
2
|
+
export declare const BqAccordion: import("react").ForwardRefExoticComponent<JSX.BqAccordion & Omit<import("react").HTMLAttributes<HTMLBqAccordionElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqAccordionElement>>;
|
|
3
|
+
export declare const BqAccordionGroup: import("react").ForwardRefExoticComponent<JSX.BqAccordionGroup & Omit<import("react").HTMLAttributes<HTMLBqAccordionGroupElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqAccordionGroupElement>>;
|
|
4
|
+
export declare const BqAlert: import("react").ForwardRefExoticComponent<JSX.BqAlert & Omit<import("react").HTMLAttributes<HTMLBqAlertElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqAlertElement>>;
|
|
5
|
+
export declare const BqAvatar: import("react").ForwardRefExoticComponent<JSX.BqAvatar & Omit<import("react").HTMLAttributes<HTMLBqAvatarElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqAvatarElement>>;
|
|
6
|
+
export declare const BqBadge: import("react").ForwardRefExoticComponent<JSX.BqBadge & Omit<import("react").HTMLAttributes<HTMLBqBadgeElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqBadgeElement>>;
|
|
7
|
+
export declare const BqBreadcrumb: import("react").ForwardRefExoticComponent<JSX.BqBreadcrumb & Omit<import("react").HTMLAttributes<HTMLBqBreadcrumbElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqBreadcrumbElement>>;
|
|
8
|
+
export declare const BqBreadcrumbItem: import("react").ForwardRefExoticComponent<JSX.BqBreadcrumbItem & Omit<import("react").HTMLAttributes<HTMLBqBreadcrumbItemElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqBreadcrumbItemElement>>;
|
|
9
|
+
export declare const BqButton: import("react").ForwardRefExoticComponent<JSX.BqButton & Omit<import("react").HTMLAttributes<HTMLBqButtonElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqButtonElement>>;
|
|
10
|
+
export declare const BqCard: import("react").ForwardRefExoticComponent<JSX.BqCard & Omit<import("react").HTMLAttributes<HTMLBqCardElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqCardElement>>;
|
|
11
|
+
export declare const BqCheckbox: import("react").ForwardRefExoticComponent<JSX.BqCheckbox & Omit<import("react").HTMLAttributes<HTMLBqCheckboxElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqCheckboxElement>>;
|
|
12
|
+
export declare const BqDialog: import("react").ForwardRefExoticComponent<JSX.BqDialog & Omit<import("react").HTMLAttributes<HTMLBqDialogElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqDialogElement>>;
|
|
13
|
+
export declare const BqDivider: import("react").ForwardRefExoticComponent<JSX.BqDivider & Omit<import("react").HTMLAttributes<HTMLBqDividerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqDividerElement>>;
|
|
14
|
+
export declare const BqDropdown: import("react").ForwardRefExoticComponent<JSX.BqDropdown & Omit<import("react").HTMLAttributes<HTMLBqDropdownElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqDropdownElement>>;
|
|
15
|
+
export declare const BqEmptyState: import("react").ForwardRefExoticComponent<JSX.BqEmptyState & Omit<import("react").HTMLAttributes<HTMLBqEmptyStateElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqEmptyStateElement>>;
|
|
16
|
+
export declare const BqIcon: import("react").ForwardRefExoticComponent<JSX.BqIcon & Omit<import("react").HTMLAttributes<HTMLBqIconElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqIconElement>>;
|
|
17
|
+
export declare const BqInput: import("react").ForwardRefExoticComponent<JSX.BqInput & Omit<import("react").HTMLAttributes<HTMLBqInputElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqInputElement>>;
|
|
18
|
+
export declare const BqNotification: import("react").ForwardRefExoticComponent<JSX.BqNotification & Omit<import("react").HTMLAttributes<HTMLBqNotificationElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqNotificationElement>>;
|
|
19
|
+
export declare const BqOption: import("react").ForwardRefExoticComponent<JSX.BqOption & Omit<import("react").HTMLAttributes<HTMLBqOptionElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqOptionElement>>;
|
|
20
|
+
export declare const BqOptionGroup: import("react").ForwardRefExoticComponent<JSX.BqOptionGroup & Omit<import("react").HTMLAttributes<HTMLBqOptionGroupElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqOptionGroupElement>>;
|
|
21
|
+
export declare const BqOptionList: import("react").ForwardRefExoticComponent<JSX.BqOptionList & Omit<import("react").HTMLAttributes<HTMLBqOptionListElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqOptionListElement>>;
|
|
22
|
+
export declare const BqPanel: import("react").ForwardRefExoticComponent<JSX.BqPanel & Omit<import("react").HTMLAttributes<HTMLBqPanelElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqPanelElement>>;
|
|
23
|
+
export declare const BqRadio: import("react").ForwardRefExoticComponent<JSX.BqRadio & Omit<import("react").HTMLAttributes<HTMLBqRadioElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqRadioElement>>;
|
|
24
|
+
export declare const BqRadioGroup: import("react").ForwardRefExoticComponent<JSX.BqRadioGroup & Omit<import("react").HTMLAttributes<HTMLBqRadioGroupElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqRadioGroupElement>>;
|
|
25
|
+
export declare const BqSelect: import("react").ForwardRefExoticComponent<JSX.BqSelect & Omit<import("react").HTMLAttributes<HTMLBqSelectElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqSelectElement>>;
|
|
26
|
+
export declare const BqSideMenu: import("react").ForwardRefExoticComponent<JSX.BqSideMenu & Omit<import("react").HTMLAttributes<HTMLBqSideMenuElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqSideMenuElement>>;
|
|
27
|
+
export declare const BqSideMenuItem: import("react").ForwardRefExoticComponent<JSX.BqSideMenuItem & Omit<import("react").HTMLAttributes<HTMLBqSideMenuItemElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqSideMenuItemElement>>;
|
|
28
|
+
export declare const BqSlider: import("react").ForwardRefExoticComponent<JSX.BqSlider & Omit<import("react").HTMLAttributes<HTMLBqSliderElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqSliderElement>>;
|
|
29
|
+
export declare const BqSpinner: import("react").ForwardRefExoticComponent<JSX.BqSpinner & Omit<import("react").HTMLAttributes<HTMLBqSpinnerElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqSpinnerElement>>;
|
|
30
|
+
export declare const BqStatus: import("react").ForwardRefExoticComponent<JSX.BqStatus & Omit<import("react").HTMLAttributes<HTMLBqStatusElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqStatusElement>>;
|
|
31
|
+
export declare const BqStepItem: import("react").ForwardRefExoticComponent<JSX.BqStepItem & Omit<import("react").HTMLAttributes<HTMLBqStepItemElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqStepItemElement>>;
|
|
32
|
+
export declare const BqSteps: import("react").ForwardRefExoticComponent<JSX.BqSteps & Omit<import("react").HTMLAttributes<HTMLBqStepsElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqStepsElement>>;
|
|
33
|
+
export declare const BqSwitch: import("react").ForwardRefExoticComponent<JSX.BqSwitch & Omit<import("react").HTMLAttributes<HTMLBqSwitchElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqSwitchElement>>;
|
|
34
|
+
export declare const BqTab: import("react").ForwardRefExoticComponent<JSX.BqTab & Omit<import("react").HTMLAttributes<HTMLBqTabElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqTabElement>>;
|
|
35
|
+
export declare const BqTabGroup: import("react").ForwardRefExoticComponent<JSX.BqTabGroup & Omit<import("react").HTMLAttributes<HTMLBqTabGroupElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqTabGroupElement>>;
|
|
36
|
+
export declare const BqTag: import("react").ForwardRefExoticComponent<JSX.BqTag & Omit<import("react").HTMLAttributes<HTMLBqTagElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqTagElement>>;
|
|
37
|
+
export declare const BqTextarea: import("react").ForwardRefExoticComponent<JSX.BqTextarea & Omit<import("react").HTMLAttributes<HTMLBqTextareaElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqTextareaElement>>;
|
|
38
|
+
export declare const BqToast: import("react").ForwardRefExoticComponent<JSX.BqToast & Omit<import("react").HTMLAttributes<HTMLBqToastElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqToastElement>>;
|
|
39
|
+
export declare const BqTooltip: import("react").ForwardRefExoticComponent<JSX.BqTooltip & Omit<import("react").HTMLAttributes<HTMLBqTooltipElement>, "style"> & import("./react-component-lib/interfaces").StyleReactProps & import("react").RefAttributes<HTMLBqTooltipElement>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* auto-generated react proxies */
|
|
4
|
+
import { createReactComponent } from './react-component-lib';
|
|
5
|
+
import { defineCustomElements } from '@beeq/core/dist/loader';
|
|
6
|
+
defineCustomElements();
|
|
7
|
+
export const BqAccordion = /*@__PURE__*/ createReactComponent('bq-accordion');
|
|
8
|
+
export const BqAccordionGroup = /*@__PURE__*/ createReactComponent('bq-accordion-group');
|
|
9
|
+
export const BqAlert = /*@__PURE__*/ createReactComponent('bq-alert');
|
|
10
|
+
export const BqAvatar = /*@__PURE__*/ createReactComponent('bq-avatar');
|
|
11
|
+
export const BqBadge = /*@__PURE__*/ createReactComponent('bq-badge');
|
|
12
|
+
export const BqBreadcrumb = /*@__PURE__*/ createReactComponent('bq-breadcrumb');
|
|
13
|
+
export const BqBreadcrumbItem = /*@__PURE__*/ createReactComponent('bq-breadcrumb-item');
|
|
14
|
+
export const BqButton = /*@__PURE__*/ createReactComponent('bq-button');
|
|
15
|
+
export const BqCard = /*@__PURE__*/ createReactComponent('bq-card');
|
|
16
|
+
export const BqCheckbox = /*@__PURE__*/ createReactComponent('bq-checkbox');
|
|
17
|
+
export const BqDialog = /*@__PURE__*/ createReactComponent('bq-dialog');
|
|
18
|
+
export const BqDivider = /*@__PURE__*/ createReactComponent('bq-divider');
|
|
19
|
+
export const BqDropdown = /*@__PURE__*/ createReactComponent('bq-dropdown');
|
|
20
|
+
export const BqEmptyState = /*@__PURE__*/ createReactComponent('bq-empty-state');
|
|
21
|
+
export const BqIcon = /*@__PURE__*/ createReactComponent('bq-icon');
|
|
22
|
+
export const BqInput = /*@__PURE__*/ createReactComponent('bq-input');
|
|
23
|
+
export const BqNotification = /*@__PURE__*/ createReactComponent('bq-notification');
|
|
24
|
+
export const BqOption = /*@__PURE__*/ createReactComponent('bq-option');
|
|
25
|
+
export const BqOptionGroup = /*@__PURE__*/ createReactComponent('bq-option-group');
|
|
26
|
+
export const BqOptionList = /*@__PURE__*/ createReactComponent('bq-option-list');
|
|
27
|
+
export const BqPanel = /*@__PURE__*/ createReactComponent('bq-panel');
|
|
28
|
+
export const BqRadio = /*@__PURE__*/ createReactComponent('bq-radio');
|
|
29
|
+
export const BqRadioGroup = /*@__PURE__*/ createReactComponent('bq-radio-group');
|
|
30
|
+
export const BqSelect = /*@__PURE__*/ createReactComponent('bq-select');
|
|
31
|
+
export const BqSideMenu = /*@__PURE__*/ createReactComponent('bq-side-menu');
|
|
32
|
+
export const BqSideMenuItem = /*@__PURE__*/ createReactComponent('bq-side-menu-item');
|
|
33
|
+
export const BqSlider = /*@__PURE__*/ createReactComponent('bq-slider');
|
|
34
|
+
export const BqSpinner = /*@__PURE__*/ createReactComponent('bq-spinner');
|
|
35
|
+
export const BqStatus = /*@__PURE__*/ createReactComponent('bq-status');
|
|
36
|
+
export const BqStepItem = /*@__PURE__*/ createReactComponent('bq-step-item');
|
|
37
|
+
export const BqSteps = /*@__PURE__*/ createReactComponent('bq-steps');
|
|
38
|
+
export const BqSwitch = /*@__PURE__*/ createReactComponent('bq-switch');
|
|
39
|
+
export const BqTab = /*@__PURE__*/ createReactComponent('bq-tab');
|
|
40
|
+
export const BqTabGroup = /*@__PURE__*/ createReactComponent('bq-tab-group');
|
|
41
|
+
export const BqTag = /*@__PURE__*/ createReactComponent('bq-tag');
|
|
42
|
+
export const BqTextarea = /*@__PURE__*/ createReactComponent('bq-textarea');
|
|
43
|
+
export const BqToast = /*@__PURE__*/ createReactComponent('bq-toast');
|
|
44
|
+
export const BqTooltip = /*@__PURE__*/ createReactComponent('bq-tooltip');
|
|
45
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../packages/beeq-react/src/components.ts"],"names":[],"mappings":"AAAA,oBAAoB;AACpB,oBAAoB;AACpB,kCAAkC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAI7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAE9D,oBAAoB,EAAE,CAAC;AACvB,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAA,oBAAoB,CAA0C,cAAc,CAAC,CAAC;AACtH,MAAM,CAAC,MAAM,gBAAgB,GAAG,aAAa,CAAA,o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M,CAAC,MAAM,QAAQ,GAAG,aAAa,CAAA,oBAAoB,CAAoC,WAAW,CAAC,CAAC;AAC1G,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAA,oBAAoB,CAA8B,QAAQ,CAAC,CAAC;AAC9F,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA,oBAAoB,CAAwC,cAAc,CAAC,CAAC;AACnH,MAAM,CAAC,MAAM,KAAK,GAAG,aAAa,CAAA,oBAAoB,CAA8B,QAAQ,CAAC,CAAC;AAC9F,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAA,oBAAoB,CAAwC,aAAa,CAAC,CAAC;AAClH,MAAM,CAAC,MAAM,OAAO,GAAG,aAAa,CAAA,oBAAoB,CAAkC,UAAU,CAAC,CAAC;AACtG,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAA,oBAAoB,CAAsC,YAAY,CAAC,CAAC"}
|
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
package/src/index.js
ADDED
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../packages/beeq-react/src/index.ts"],"names":[],"mappings":"AAAA,6DAA6D;AAC7D,cAAc;AACd,cAAc,cAAc,CAAC"}
|
|
@@ -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>, manipulatePropsFunction?: (originalProps: StencilReactInternalProps<ElementType>, propsToPass: any) => ExpandedPropsTypes, defineCustomElement?: () => void) => React.ForwardRefExoticComponent<React.PropsWithoutRef<import("./utils").StencilReactExternalProps<PropType, ElementType>> & React.RefAttributes<ElementType>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React, { createElement } from 'react';
|
|
2
|
+
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
|
|
3
|
+
export const createReactComponent = (tagName, ReactComponentContext, manipulatePropsFunction, defineCustomElement) => {
|
|
4
|
+
if (defineCustomElement !== undefined) {
|
|
5
|
+
defineCustomElement();
|
|
6
|
+
}
|
|
7
|
+
const displayName = dashToPascalCase(tagName);
|
|
8
|
+
const ReactComponent = class extends React.Component {
|
|
9
|
+
constructor(props) {
|
|
10
|
+
super(props);
|
|
11
|
+
this.setComponentElRef = (element) => {
|
|
12
|
+
this.componentEl = element;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
componentDidMount() {
|
|
16
|
+
this.componentDidUpdate(this.props);
|
|
17
|
+
}
|
|
18
|
+
componentDidUpdate(prevProps) {
|
|
19
|
+
attachProps(this.componentEl, this.props, prevProps);
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
const { children, forwardedRef, style, className, ref, ...cProps } = this.props;
|
|
23
|
+
let propsToPass = Object.keys(cProps).reduce((acc, name) => {
|
|
24
|
+
const value = cProps[name];
|
|
25
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
26
|
+
const eventName = name.substring(2).toLowerCase();
|
|
27
|
+
if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
|
|
28
|
+
acc[name] = value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
// we should only render strings, booleans, and numbers as attrs in html.
|
|
33
|
+
// objects, functions, arrays etc get synced via properties on mount.
|
|
34
|
+
const type = typeof value;
|
|
35
|
+
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
36
|
+
acc[camelToDashCase(name)] = value;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return acc;
|
|
40
|
+
}, {});
|
|
41
|
+
if (manipulatePropsFunction) {
|
|
42
|
+
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
43
|
+
}
|
|
44
|
+
const newProps = {
|
|
45
|
+
...propsToPass,
|
|
46
|
+
ref: mergeRefs(forwardedRef, this.setComponentElRef),
|
|
47
|
+
style,
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* We use createElement here instead of
|
|
51
|
+
* React.createElement to work around a
|
|
52
|
+
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
|
53
|
+
* React.createElement causes all elements to be rendered
|
|
54
|
+
* as <tagname> instead of the actual Web Component.
|
|
55
|
+
*/
|
|
56
|
+
return createElement(tagName, newProps, children);
|
|
57
|
+
}
|
|
58
|
+
static get displayName() {
|
|
59
|
+
return displayName;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
// If context was passed to createReactComponent then conditionally add it to the Component Class
|
|
63
|
+
if (ReactComponentContext) {
|
|
64
|
+
ReactComponent.contextType = ReactComponentContext;
|
|
65
|
+
}
|
|
66
|
+
return createForwardRef(ReactComponent, displayName);
|
|
67
|
+
};
|
|
68
|
+
//# sourceMappingURL=createComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createComponent.js","sourceRoot":"","sources":["../../../../packages/beeq-react/src/react-component-lib/createComponent.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE7C,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAWxH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAMlC,OAAe,EACf,qBA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AE;wBAClE,GAAG,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;qBACnB;iBACF;qBAAM;oBACL,yEAAyE;oBACzE,qEAAqE;oBACrE,MAAM,IAAI,GAAG,OAAO,KAAK,CAAC;oBAE1B,IAAI,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,QAAQ,EAAE;wBAChE,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC;qBACpC;iBACF;gBACD,OAAO,GAAG,CAAC;YACb,CAAC,EAAE,EAAwB,CAAC,CAAC;YAE7B,IAAI,uBAAuB,EAAE;gBAC3B,WAAW,GAAG,uBAAuB,CAAC,IAAI,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;aAChE;YAED,MAAM,QAAQ,GAAiE;gBAC7E,GAAG,WAAW;gBACd,GAAG,EAAE,SAAS,CAAC,YAAY,EAAE,IAAI,CAAC,iBAAiB,CAAC;gBACpD,KAAK;aACN,CAAC;YAEF;;;;;;eAMG;YACH,OAAO,aAAa,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,KAAK,WAAW;YACpB,OAAO,WAAW,CAAC;QACrB,CAAC;KACF,CAAC;IAEF,iGAAiG;IACjG,IAAI,qBAAqB,EAAE;QACzB,cAAc,CAAC,WAAW,GAAG,qBAAqB,CAAC;KACpD;IAED,OAAO,gBAAgB,CAAwB,cAAc,EAAE,WAAW,CAAC,CAAC;AAC9E,CAAC,CAAC"}
|
|
@@ -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>;
|
|
20
|
+
}> & React.RefAttributes<OverlayType>>;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import ReactDOM from 'react-dom';
|
|
4
|
+
import { attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
|
|
5
|
+
export const createOverlayComponent = (tagName, controller, customElement) => {
|
|
6
|
+
defineCustomElement(tagName, customElement);
|
|
7
|
+
const displayName = dashToPascalCase(tagName);
|
|
8
|
+
const didDismissEventName = `on${displayName}DidDismiss`;
|
|
9
|
+
const didPresentEventName = `on${displayName}DidPresent`;
|
|
10
|
+
const willDismissEventName = `on${displayName}WillDismiss`;
|
|
11
|
+
const willPresentEventName = `on${displayName}WillPresent`;
|
|
12
|
+
let isDismissing = false;
|
|
13
|
+
class Overlay extends React.Component {
|
|
14
|
+
constructor(props) {
|
|
15
|
+
super(props);
|
|
16
|
+
if (typeof document !== 'undefined') {
|
|
17
|
+
this.el = document.createElement('div');
|
|
18
|
+
}
|
|
19
|
+
this.handleDismiss = this.handleDismiss.bind(this);
|
|
20
|
+
}
|
|
21
|
+
static get displayName() {
|
|
22
|
+
return displayName;
|
|
23
|
+
}
|
|
24
|
+
componentDidMount() {
|
|
25
|
+
if (this.props.isOpen) {
|
|
26
|
+
this.present();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
componentWillUnmount() {
|
|
30
|
+
if (this.overlay) {
|
|
31
|
+
this.overlay.dismiss();
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
handleDismiss(event) {
|
|
35
|
+
if (this.props.onDidDismiss) {
|
|
36
|
+
this.props.onDidDismiss(event);
|
|
37
|
+
}
|
|
38
|
+
setRef(this.props.forwardedRef, null);
|
|
39
|
+
}
|
|
40
|
+
shouldComponentUpdate(nextProps) {
|
|
41
|
+
// Check if the overlay component is about to dismiss
|
|
42
|
+
if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
|
|
43
|
+
isDismissing = true;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
async componentDidUpdate(prevProps) {
|
|
48
|
+
if (this.overlay) {
|
|
49
|
+
attachProps(this.overlay, this.props, prevProps);
|
|
50
|
+
}
|
|
51
|
+
if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
|
|
52
|
+
this.present(prevProps);
|
|
53
|
+
}
|
|
54
|
+
if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
|
|
55
|
+
await this.overlay.dismiss();
|
|
56
|
+
isDismissing = false;
|
|
57
|
+
/**
|
|
58
|
+
* Now that the overlay is dismissed
|
|
59
|
+
* we need to render again so that any
|
|
60
|
+
* inner components will be unmounted
|
|
61
|
+
*/
|
|
62
|
+
this.forceUpdate();
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
async present(prevProps) {
|
|
66
|
+
const { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent, ...cProps } = this.props;
|
|
67
|
+
const elementProps = {
|
|
68
|
+
...cProps,
|
|
69
|
+
ref: this.props.forwardedRef,
|
|
70
|
+
[didDismissEventName]: this.handleDismiss,
|
|
71
|
+
[didPresentEventName]: (e) => this.props.onDidPresent && this.props.onDidPresent(e),
|
|
72
|
+
[willDismissEventName]: (e) => this.props.onWillDismiss && this.props.onWillDismiss(e),
|
|
73
|
+
[willPresentEventName]: (e) => this.props.onWillPresent && this.props.onWillPresent(e),
|
|
74
|
+
};
|
|
75
|
+
this.overlay = await controller.create({
|
|
76
|
+
...elementProps,
|
|
77
|
+
component: this.el,
|
|
78
|
+
componentProps: {},
|
|
79
|
+
});
|
|
80
|
+
setRef(this.props.forwardedRef, this.overlay);
|
|
81
|
+
attachProps(this.overlay, elementProps, prevProps);
|
|
82
|
+
await this.overlay.present();
|
|
83
|
+
}
|
|
84
|
+
render() {
|
|
85
|
+
/**
|
|
86
|
+
* Continue to render the component even when
|
|
87
|
+
* overlay is dismissing otherwise component
|
|
88
|
+
* will be hidden before animation is done.
|
|
89
|
+
*/
|
|
90
|
+
return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return React.forwardRef((props, ref) => {
|
|
94
|
+
return _jsx(Overlay, { ...props, forwardedRef: ref });
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
//# sourceMappingURL=createOverlayComponent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createOverlayComponent.js","sourceRoot":"","sources":["../../../../packages/beeq-react/src/react-component-lib/createOverlayComponent.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,WAAW,CAAC;AAGjC,OAAO,EAA4B,WAAW,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AAgB/G,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,OAAe,EACf,UAA8D,EAC9D,aAAmB,EACnB,EAAE;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":"index.js","sourceRoot":"","sources":["../../../../packages/beeq-react/src/react-component-lib/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC"}
|
|
@@ -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
|
+
{"version":3,"file":"interfaces.js","sourceRoot":"","sources":["../../../../packages/beeq-react/src/react-component-lib/interfaces.ts"],"names":[],"mappings":""}
|
|
@@ -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;
|
|
15
|
+
};
|
|
16
|
+
}, eventName: string, newEventHandler?: (e: Event) => any) => void;
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
};
|
|
108
|
+
//# sourceMappingURL=attachProps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attachProps.js","sourceRoot":"","sources":["../../../../../packages/beeq-react/src/react-component-lib/utils/attachProps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAEzC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAiB,EAAE,QAAa,EAAE,WAAgB,EAAE,EAAE,EAAE;IAClF,6GAA6G;IAC7G,IAA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AC,CAAQ;QAChD,IAAI,eAAe,EAAE;YACnB,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;SAC/B;IACH,CAAC,CAAC,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,UAAU,GAAG,CAAC,GAA4B,EAAE,EAAE;IAClD,MAAM,GAAG,GAAG,IAAI,GAAG,EAAkB,CAAC;IACrC,GAAgB,CAAC,OAAO,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACxD,OAAO,GAAG,CAAC;AACb,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
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()}`);
|
|
7
|
+
//# sourceMappingURL=case.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"case.js","sourceRoot":"","sources":["../../../../../packages/beeq-react/src/react-component-lib/utils/case.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,GAAW,EAAE,EAAE,CAC9C,GAAG;KACA,WAAW,EAAE;KACb,KAAK,CAAC,GAAG,CAAC;KACV,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;KACpE,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAW,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAS,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
};
|
|
13
|
+
//# sourceMappingURL=dev.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../../../../packages/beeq-react/src/react-component-lib/utils/dev.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,GAAG,EAAE;IAC5B,OAAO,OAAO,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,aAAa,CAAC;AAC1E,CAAC,CAAC;AAEF,MAAM,QAAQ,GAA+B,EAAE,CAAC;AAEhD,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAW,EAAE,OAAe,EAAE,EAAE;IACjE,IAAI,SAAS,EAAE,EAAE;QACf,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YAClB,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACtB,QAAQ,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;SACtB;KACF;AACH,CAAC,CAAC"}
|
|
@@ -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,33 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export const setRef = (ref, value) => {
|
|
4
|
+
if (typeof ref === 'function') {
|
|
5
|
+
ref(value);
|
|
6
|
+
}
|
|
7
|
+
else if (ref != null) {
|
|
8
|
+
// Cast as a MutableRef so we can assign current
|
|
9
|
+
ref.current = value;
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
export const mergeRefs = (...refs) => {
|
|
13
|
+
return (value) => {
|
|
14
|
+
refs.forEach((ref) => {
|
|
15
|
+
setRef(ref, value);
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
export const createForwardRef = (ReactComponent, displayName) => {
|
|
20
|
+
const forwardRef = (props, ref) => {
|
|
21
|
+
return _jsx(ReactComponent, { ...props, forwardedRef: ref });
|
|
22
|
+
};
|
|
23
|
+
forwardRef.displayName = displayName;
|
|
24
|
+
return React.forwardRef(forwardRef);
|
|
25
|
+
};
|
|
26
|
+
export const defineCustomElement = (tagName, customElement) => {
|
|
27
|
+
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
|
|
28
|
+
customElements.define(tagName, customElement);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export * from './attachProps';
|
|
32
|
+
export * from './case';
|
|
33
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../packages/beeq-react/src/react-component-lib/utils/index.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAW1B,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,GAA+D,EAAE,KAAU,EAAE,EAAE;IACpG,IAAI,OAAO,GAAG,KAAK,UAAU,EAAE;QAC7B,GAAG,CAAC,KAAK,CAAC,CAAC;KACZ;SAAM,IAAI,GAAG,IAAI,IAAI,EAAE;QACtB,gDAAgD;QAC/C,GAAmC,CAAC,OAAO,GAAG,KAAK,CAAC;KACtD;AACH,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAAG,IAAoE,EAC/C,EAAE;IAC1B,OAAO,CAAC,KAAU,EAAE,EAAE;QACpB,IAAI,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,EAAE;YACnB,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACrB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAwB,cAAmB,EAAE,WAAmB,EAAE,EAAE;IAClG,MAAM,UAAU,GAAG,CACjB,KAAuD,EACvD,GAA0C,EAC1C,EAAE;QACF,OAAO,KAAC,cAAc,OAAK,KAAK,EAAE,YAAY,EAAE,GAAG,GAAI,CAAC;IAC1D,CAAC,CAAC;IACF,UAAU,CAAC,WAAW,GAAG,WAAW,CAAC;IAErC,OAAO,KAAK,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC;AACtC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,OAAe,EAAE,aAAkB,EAAE,EAAE;IACzE,IAAI,aAAa,KAAK,SAAS,IAAI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