@ebrains/react 0.9.0-beta → 0.9.2-beta
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/.babelrc +12 -0
- package/LICENSE +21 -0
- package/README.md +5 -1
- package/package.json +2 -6
- package/project.json +10 -0
- package/rollup.config.js +43 -0
- package/src/components.ts +49 -0
- package/src/generated/components.ts +47 -0
- package/src/generated/react-component-lib/attachProps.ts +125 -0
- package/src/generated/react-component-lib/case.ts +7 -0
- package/src/generated/react-component-lib/createComponent.tsx +106 -0
- package/src/generated/react-component-lib/createOverlayComponent.tsx +142 -0
- package/src/generated/react-component-lib/dev.ts +14 -0
- package/src/generated/react-component-lib/index.tsx +50 -0
- package/src/generated/react-component-lib/interfaces.ts +34 -0
- package/src/generated/react-component-lib/utils/attachProps.ts +125 -0
- package/src/generated/react-component-lib/utils/case.ts +7 -0
- package/src/generated/react-component-lib/utils/dev.ts +14 -0
- package/src/generated/react-component-lib/utils/index.tsx +50 -0
- package/src/react-component-lib/attachProps.ts +125 -0
- package/src/react-component-lib/case.ts +7 -0
- package/src/react-component-lib/createComponent.tsx +106 -0
- package/src/react-component-lib/createOverlayComponent.tsx +142 -0
- package/src/react-component-lib/dev.ts +14 -0
- package/src/react-component-lib/index.tsx +50 -0
- package/src/react-component-lib/interfaces.ts +34 -0
- package/src/react-component-lib/utils/attachProps.ts +125 -0
- package/src/react-component-lib/utils/case.ts +7 -0
- package/src/react-component-lib/utils/index.tsx +50 -0
- package/tsconfig.json +17 -0
- package/tsconfig.lib.json +23 -0
- package/analytics-44b1416b.esm.js +0 -55
- package/arrow-diagonal-black-8f0494c3.esm.js +0 -3
- package/arrow-right-9322ba8a.esm.js +0 -5
- package/bluesky-cc5edd2d.esm.js +0 -14
- package/bookmark-c200037c.esm.js +0 -16
- package/chevron-down-6144c823.esm.js +0 -12
- package/chevron-left-ca6c66e1.esm.js +0 -11
- package/chevron-right-b88ed2d4.esm.js +0 -5
- package/chevron-up-c66bd477.esm.js +0 -12
- package/close-87fc0d63.esm.js +0 -5
- package/color-2554aad6.esm.js +0 -122
- package/color-primary-palette_6.entry.esm.js +0 -778
- package/components-section.entry.esm.js +0 -165
- package/copy-03b72cb6.esm.js +0 -5
- package/correct-use-of-colors.entry.esm.js +0 -243
- package/docs-palettes.entry.esm.js +0 -29
- package/docs-tokens.entry.esm.js +0 -45
- package/eds-accordion.entry.esm.js +0 -132
- package/eds-alert.entry.esm.js +0 -112
- package/eds-app-root.entry.esm.js +0 -53
- package/eds-avatar_24.entry.esm.js +0 -275
- package/eds-breadcrumb.entry.esm.js +0 -174
- package/eds-card-desc_3.entry.esm.js +0 -125
- package/eds-card-generic.entry.esm.js +0 -114
- package/eds-card-project.entry.esm.js +0 -93
- package/eds-card-section.entry.esm.js +0 -56
- package/eds-card-tags.entry.esm.js +0 -27
- package/eds-card-tool.entry.esm.js +0 -105
- package/eds-card-wrapper.entry.esm.js +0 -39
- package/eds-code-block.entry.esm.js +0 -2290
- package/eds-cookies-preference.entry.esm.js +0 -47
- package/eds-feedback.entry.esm.js +0 -82
- package/eds-frame.entry.esm.js +0 -112
- package/eds-icon-arrow-diagonal.entry.esm.js +0 -21
- package/eds-icon-arrow-right.entry.esm.js +0 -21
- package/eds-icon-bluesky.entry.esm.js +0 -21
- package/eds-icon-bookmark.entry.esm.js +0 -21
- package/eds-icon-chevron-down.entry.esm.js +0 -21
- package/eds-icon-chevron-left.entry.esm.js +0 -21
- package/eds-icon-chevron-right.entry.esm.js +0 -21
- package/eds-icon-chevron-up.entry.esm.js +0 -21
- package/eds-icon-close.entry.esm.js +0 -21
- package/eds-icon-copy.entry.esm.js +0 -21
- package/eds-icon-eu.entry.esm.js +0 -21
- package/eds-icon-external.entry.esm.js +0 -21
- package/eds-icon-facebook.entry.esm.js +0 -21
- package/eds-icon-gitlab.entry.esm.js +0 -21
- package/eds-icon-linkedin.entry.esm.js +0 -21
- package/eds-icon-loader.entry.esm.js +0 -21
- package/eds-icon-mastodon.entry.esm.js +0 -21
- package/eds-icon-menu.entry.esm.js +0 -21
- package/eds-icon-minus.entry.esm.js +0 -21
- package/eds-icon-more.entry.esm.js +0 -21
- package/eds-icon-paper.entry.esm.js +0 -21
- package/eds-icon-plus.entry.esm.js +0 -21
- package/eds-icon-portal.entry.esm.js +0 -21
- package/eds-icon-private.entry.esm.js +0 -21
- package/eds-icon-public.entry.esm.js +0 -21
- package/eds-icon-search.entry.esm.js +0 -21
- package/eds-icon-star.entry.esm.js +0 -21
- package/eds-icon-success.entry.esm.js +0 -21
- package/eds-icon-thumbs-down.entry.esm.js +0 -21
- package/eds-icon-thumbs-up.entry.esm.js +0 -21
- package/eds-icon-tutorial.entry.esm.js +0 -21
- package/eds-icon-twitter.entry.esm.js +0 -21
- package/eds-icon-unknown.entry.esm.js +0 -21
- package/eds-icon-updown.entry.esm.js +0 -21
- package/eds-icon-user.entry.esm.js +0 -21
- package/eds-icon-youtube.entry.esm.js +0 -21
- package/eds-login_2.entry.esm.js +0 -1828
- package/eds-matomo-notice.entry.esm.js +0 -162
- package/eds-modal.entry.esm.js +0 -142
- package/eds-pagination_2.entry.esm.js +0 -493
- package/eds-progress-bar.entry.esm.js +0 -41
- package/eds-rating.entry.esm.js +0 -79
- package/eds-section-core_2.entry.esm.js +0 -69
- package/eds-spinner.entry.esm.js +0 -67
- package/eds-switch.entry.esm.js +0 -58
- package/eds-tabs.entry.esm.js +0 -143
- package/eds-timeline.entry.esm.js +0 -117
- package/eds-toast-manager.entry.esm.js +0 -62
- package/eds-toast.entry.esm.js +0 -92
- package/eds-tooltip.entry.esm.js +0 -125
- package/eds-trl.entry.esm.js +0 -68
- package/eu-9ddde93a.esm.js +0 -30
- package/facebook-9cb5c17f.esm.js +0 -14
- package/incorrect-use-of-colors.entry.esm.js +0 -71
- package/index-39c58238.esm.js +0 -58
- package/index.esm.d.ts +0 -1
- package/index.esm.js +0 -4
- package/index.esm2.js +0 -4840
- package/linkedin-e8650abb.esm.js +0 -28
- package/loader-c9628637.esm.js +0 -30
- package/logo-color-7f1fd803.esm.js +0 -115
- package/logo-color-margins-ff8ce71b.esm.js +0 -118
- package/logo-space.entry.esm.js +0 -48
- package/logo-variations-horizontal_2.entry.esm.js +0 -123
- package/logo-variations-tabs.entry.esm.js +0 -29
- package/logo-white-no-bg-f382f86f.esm.js +0 -1021
- package/logo-wrong-usage.entry.esm.js +0 -101
- package/mastodon-3703ec61.esm.js +0 -14
- package/menu-340ea948.esm.js +0 -11
- package/minus-b30a7c71.esm.js +0 -11
- package/mono-53f70232.esm.js +0 -11
- package/more-4449d549.esm.js +0 -13
- package/paper-8e74ea31.esm.js +0 -15
- package/plus-89c07be2.esm.js +0 -12
- package/portal-d6c8ce56.esm.js +0 -18
- package/private-1c25ff8e.esm.js +0 -25
- package/public-d4d8c585.esm.js +0 -16
- package/search-fbcd79c2.esm.js +0 -12
- package/sharedUtils-a550989c.esm.js +0 -17
- package/src/components.d.ts +0 -41
- package/src/generated/components.d.ts +0 -38
- package/src/generated/react-component-lib/attachProps.d.ts +0 -16
- package/src/generated/react-component-lib/case.d.ts +0 -2
- package/src/generated/react-component-lib/createComponent.d.ts +0 -10
- package/src/generated/react-component-lib/createOverlayComponent.d.ts +0 -21
- package/src/generated/react-component-lib/dev.d.ts +0 -2
- package/src/generated/react-component-lib/interfaces.d.ts +0 -29
- package/src/generated/react-component-lib/utils/attachProps.d.ts +0 -16
- package/src/generated/react-component-lib/utils/case.d.ts +0 -2
- package/src/generated/react-component-lib/utils/dev.d.ts +0 -2
- package/src/generated/react-component-lib/utils/index.d.ts +0 -10
- package/src/react-component-lib/attachProps.d.ts +0 -16
- package/src/react-component-lib/case.d.ts +0 -2
- package/src/react-component-lib/createComponent.d.ts +0 -10
- package/src/react-component-lib/createOverlayComponent.d.ts +0 -21
- package/src/react-component-lib/dev.d.ts +0 -2
- package/src/react-component-lib/interfaces.d.ts +0 -29
- package/src/react-component-lib/utils/attachProps.d.ts +0 -16
- package/src/react-component-lib/utils/case.d.ts +0 -2
- package/src/react-component-lib/utils/index.d.ts +0 -10
- package/star-0da9b5e9.esm.js +0 -5
- package/success-443809da.esm.js +0 -18
- package/svg-repository.entry.esm.js +0 -337
- package/thumbs-down-a18fd049.esm.js +0 -5
- package/thumbs-up-c19a71bc.esm.js +0 -6
- package/toastManager-d9eee791.esm.js +0 -34
- package/token-list_3.entry.esm.js +0 -385
- package/token-ratios.entry.esm.js +0 -49
- package/token-typography.entry.esm.js +0 -267
- package/tutotial-150ee1fd.esm.js +0 -27
- package/twitter-ac21b505.esm.js +0 -14
- package/unknown-ed01a24c.esm.js +0 -22
- package/up-and-down-d747abee.esm.js +0 -12
- package/user-71ebdc15.esm.js +0 -16
- package/youtube-efbfbdc4.esm.js +0 -14
- /package/src/generated/react-component-lib/{index.d.ts → index.ts} +0 -0
- /package/src/{index.d.ts → index.ts} +0 -0
- /package/src/react-component-lib/{index.d.ts → index.ts} +0 -0
package/.babelrc
ADDED
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -4,4 +4,8 @@ React target wrappers for Stencil output, allowing for seamless integration of S
|
|
|
4
4
|
|
|
5
5
|
## Usage
|
|
6
6
|
|
|
7
|
-
More information about importing and using the package can be found currently in the
|
|
7
|
+
More information about importing and using the package can be found currently in the [https://design.ebrains.eu/ui-components/](EBRAINS Design System).
|
|
8
|
+
|
|
9
|
+
## Licensing
|
|
10
|
+
|
|
11
|
+
The contents of this package are licensed under `MIT`.
|
package/package.json
CHANGED
package/project.json
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "react",
|
|
3
|
+
"$schema": "../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
+
"sourceRoot": "packages/react/src",
|
|
5
|
+
"projectType": "library",
|
|
6
|
+
"tags": [],
|
|
7
|
+
"implicitDependencies": ["components"],
|
|
8
|
+
"// targets": "to see all targets run: nx show project react --web",
|
|
9
|
+
"targets": {}
|
|
10
|
+
}
|
package/rollup.config.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const { withNx } = require('@nx/rollup/with-nx');
|
|
2
|
+
const url = require('@rollup/plugin-url');
|
|
3
|
+
const svg = require('@svgr/rollup');
|
|
4
|
+
//const nodeResolve = require('@rollup/plugin-node-resolve');
|
|
5
|
+
const alias = require('@rollup/plugin-alias');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
//const commonjs = require('@rollup/plugin-commonjs');
|
|
8
|
+
//const typescript = require('@rollup/plugin-typescript');
|
|
9
|
+
|
|
10
|
+
module.exports = withNx(
|
|
11
|
+
{
|
|
12
|
+
main: './src/index.ts',
|
|
13
|
+
outputPath: '../../dist/packages/react',
|
|
14
|
+
tsConfig: './tsconfig.lib.json',
|
|
15
|
+
compiler: 'babel',
|
|
16
|
+
//external: ['react', 'react-dom', 'react/jsx-runtime', '@ebrains/components', '@ebrains/components/loader'],
|
|
17
|
+
external: ['react', 'react-dom', 'react/jsx-runtime'],
|
|
18
|
+
format: ['esm'],
|
|
19
|
+
assets: [{ input: 'packages/react', output: '.', glob: '{README.md,LICENSE}'}],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
// Provide additional rollup configuration here. See: https://rollupjs.org/configuration-options
|
|
23
|
+
plugins: [
|
|
24
|
+
//nodeResolve(),
|
|
25
|
+
//commonjs(), // Convert CommonJS to ES modules
|
|
26
|
+
//typescript(), // Support for TypeScript files
|
|
27
|
+
alias({
|
|
28
|
+
entries: [
|
|
29
|
+
{ find: '@ebrains/components', replacement: path.resolve(__dirname, '../../dist/packages/components') },
|
|
30
|
+
{ find: '@ebrains/components/loader', replacement: path.resolve(__dirname, '../../dist/packages/components/loader') }
|
|
31
|
+
],
|
|
32
|
+
}),
|
|
33
|
+
svg({
|
|
34
|
+
svgo: false,
|
|
35
|
+
titleProp: true,
|
|
36
|
+
ref: true,
|
|
37
|
+
}),
|
|
38
|
+
url({
|
|
39
|
+
limit: 10000, // 10kB
|
|
40
|
+
}),
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* auto-generated react proxies */
|
|
4
|
+
import { createReactComponent } from './react-component-lib';
|
|
5
|
+
|
|
6
|
+
import type { JSX } from '@ebrains/components';
|
|
7
|
+
|
|
8
|
+
import { defineCustomElements } from '@ebrains/components/loader';
|
|
9
|
+
|
|
10
|
+
defineCustomElements();
|
|
11
|
+
export const EdsAccordion = /*@__PURE__*/createReactComponent<JSX.EdsAccordion, HTMLEdsAccordionElement>('eds-accordion');
|
|
12
|
+
export const EdsAlert = /*@__PURE__*/createReactComponent<JSX.EdsAlert, HTMLEdsAlertElement>('eds-alert');
|
|
13
|
+
export const EdsAvatar = /*@__PURE__*/createReactComponent<JSX.EdsAvatar, HTMLEdsAvatarElement>('eds-avatar');
|
|
14
|
+
export const EdsBlockBreak = /*@__PURE__*/createReactComponent<JSX.EdsBlockBreak, HTMLEdsBlockBreakElement>('eds-block-break');
|
|
15
|
+
export const EdsBreadcrumb = /*@__PURE__*/createReactComponent<JSX.EdsBreadcrumb, HTMLEdsBreadcrumbElement>('eds-breadcrumb');
|
|
16
|
+
export const EdsButton = /*@__PURE__*/createReactComponent<JSX.EdsButton, HTMLEdsButtonElement>('eds-button');
|
|
17
|
+
export const EdsCardGeneric = /*@__PURE__*/createReactComponent<JSX.EdsCardGeneric, HTMLEdsCardGenericElement>('eds-card-generic');
|
|
18
|
+
export const EdsCardSection = /*@__PURE__*/createReactComponent<JSX.EdsCardSection, HTMLEdsCardSectionElement>('eds-card-section');
|
|
19
|
+
export const EdsCodeBlock = /*@__PURE__*/createReactComponent<JSX.EdsCodeBlock, HTMLEdsCodeBlockElement>('eds-code-block');
|
|
20
|
+
export const EdsDropdown = /*@__PURE__*/createReactComponent<JSX.EdsDropdown, HTMLEdsDropdownElement>('eds-dropdown');
|
|
21
|
+
export const EdsFeedback = /*@__PURE__*/createReactComponent<JSX.EdsFeedback, HTMLEdsFeedbackElement>('eds-feedback');
|
|
22
|
+
export const EdsFooter = /*@__PURE__*/createReactComponent<JSX.EdsFooter, HTMLEdsFooterElement>('eds-footer');
|
|
23
|
+
export const EdsForm = /*@__PURE__*/createReactComponent<JSX.EdsForm, HTMLEdsFormElement>('eds-form');
|
|
24
|
+
export const EdsFullscreenMenu = /*@__PURE__*/createReactComponent<JSX.EdsFullscreenMenu, HTMLEdsFullscreenMenuElement>('eds-fullscreen-menu');
|
|
25
|
+
export const EdsHeader = /*@__PURE__*/createReactComponent<JSX.EdsHeader, HTMLEdsHeaderElement>('eds-header');
|
|
26
|
+
export const EdsIconWrapper = /*@__PURE__*/createReactComponent<JSX.EdsIconWrapper, HTMLEdsIconWrapperElement>('eds-icon-wrapper');
|
|
27
|
+
export const EdsImg = /*@__PURE__*/createReactComponent<JSX.EdsImg, HTMLEdsImgElement>('eds-img');
|
|
28
|
+
export const EdsInputField = /*@__PURE__*/createReactComponent<JSX.EdsInputField, HTMLEdsInputFieldElement>('eds-input-field');
|
|
29
|
+
export const EdsLink = /*@__PURE__*/createReactComponent<JSX.EdsLink, HTMLEdsLinkElement>('eds-link');
|
|
30
|
+
export const EdsLogo = /*@__PURE__*/createReactComponent<JSX.EdsLogo, HTMLEdsLogoElement>('eds-logo');
|
|
31
|
+
export const EdsMatomoNotice = /*@__PURE__*/createReactComponent<JSX.EdsMatomoNotice, HTMLEdsMatomoNoticeElement>('eds-matomo-notice');
|
|
32
|
+
export const EdsModal = /*@__PURE__*/createReactComponent<JSX.EdsModal, HTMLEdsModalElement>('eds-modal');
|
|
33
|
+
export const EdsPagination = /*@__PURE__*/createReactComponent<JSX.EdsPagination, HTMLEdsPaginationElement>('eds-pagination');
|
|
34
|
+
export const EdsProgressBar = /*@__PURE__*/createReactComponent<JSX.EdsProgressBar, HTMLEdsProgressBarElement>('eds-progress-bar');
|
|
35
|
+
export const EdsRating = /*@__PURE__*/createReactComponent<JSX.EdsRating, HTMLEdsRatingElement>('eds-rating');
|
|
36
|
+
export const EdsSectionCore = /*@__PURE__*/createReactComponent<JSX.EdsSectionCore, HTMLEdsSectionCoreElement>('eds-section-core');
|
|
37
|
+
export const EdsSocialNetworks = /*@__PURE__*/createReactComponent<JSX.EdsSocialNetworks, HTMLEdsSocialNetworksElement>('eds-social-networks');
|
|
38
|
+
export const EdsSpinner = /*@__PURE__*/createReactComponent<JSX.EdsSpinner, HTMLEdsSpinnerElement>('eds-spinner');
|
|
39
|
+
export const EdsSplashScreen = /*@__PURE__*/createReactComponent<JSX.EdsSplashScreen, HTMLEdsSplashScreenElement>('eds-splash-screen');
|
|
40
|
+
export const EdsSteps = /*@__PURE__*/createReactComponent<JSX.EdsSteps, HTMLEdsStepsElement>('eds-steps');
|
|
41
|
+
export const EdsStepsV2 = /*@__PURE__*/createReactComponent<JSX.EdsStepsV2, HTMLEdsStepsV2Element>('eds-steps-v2');
|
|
42
|
+
export const EdsSwitch = /*@__PURE__*/createReactComponent<JSX.EdsSwitch, HTMLEdsSwitchElement>('eds-switch');
|
|
43
|
+
export const EdsTable = /*@__PURE__*/createReactComponent<JSX.EdsTable, HTMLEdsTableElement>('eds-table');
|
|
44
|
+
export const EdsTabs = /*@__PURE__*/createReactComponent<JSX.EdsTabs, HTMLEdsTabsElement>('eds-tabs');
|
|
45
|
+
export const EdsTag = /*@__PURE__*/createReactComponent<JSX.EdsTag, HTMLEdsTagElement>('eds-tag');
|
|
46
|
+
export const EdsTimeline = /*@__PURE__*/createReactComponent<JSX.EdsTimeline, HTMLEdsTimelineElement>('eds-timeline');
|
|
47
|
+
export const EdsToast = /*@__PURE__*/createReactComponent<JSX.EdsToast, HTMLEdsToastElement>('eds-toast');
|
|
48
|
+
export const EdsTooltip = /*@__PURE__*/createReactComponent<JSX.EdsTooltip, HTMLEdsTooltipElement>('eds-tooltip');
|
|
49
|
+
export const EdsUser = /*@__PURE__*/createReactComponent<JSX.EdsUser, HTMLEdsUserElement>('eds-user');
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/* auto-generated react proxies */
|
|
4
|
+
import { createReactComponent } from './react-component-lib';
|
|
5
|
+
|
|
6
|
+
import type { JSX } from '@ebrains/components';
|
|
7
|
+
|
|
8
|
+
import { defineCustomElements } from '@ebrains/components/loader';
|
|
9
|
+
|
|
10
|
+
defineCustomElements();
|
|
11
|
+
export const EdsAccordion = /*@__PURE__*/createReactComponent<JSX.EdsAccordion, HTMLEdsAccordionElement>('eds-accordion');
|
|
12
|
+
export const EdsAlert = /*@__PURE__*/createReactComponent<JSX.EdsAlert, HTMLEdsAlertElement>('eds-alert');
|
|
13
|
+
export const EdsAvatar = /*@__PURE__*/createReactComponent<JSX.EdsAvatar, HTMLEdsAvatarElement>('eds-avatar');
|
|
14
|
+
export const EdsBlockBreak = /*@__PURE__*/createReactComponent<JSX.EdsBlockBreak, HTMLEdsBlockBreakElement>('eds-block-break');
|
|
15
|
+
export const EdsBreadcrumb = /*@__PURE__*/createReactComponent<JSX.EdsBreadcrumb, HTMLEdsBreadcrumbElement>('eds-breadcrumb');
|
|
16
|
+
export const EdsButton = /*@__PURE__*/createReactComponent<JSX.EdsButton, HTMLEdsButtonElement>('eds-button');
|
|
17
|
+
export const EdsCardDesc = /*@__PURE__*/createReactComponent<JSX.EdsCardDesc, HTMLEdsCardDescElement>('eds-card-desc');
|
|
18
|
+
export const EdsCardGeneric = /*@__PURE__*/createReactComponent<JSX.EdsCardGeneric, HTMLEdsCardGenericElement>('eds-card-generic');
|
|
19
|
+
export const EdsCardSection = /*@__PURE__*/createReactComponent<JSX.EdsCardSection, HTMLEdsCardSectionElement>('eds-card-section');
|
|
20
|
+
export const EdsCodeBlock = /*@__PURE__*/createReactComponent<JSX.EdsCodeBlock, HTMLEdsCodeBlockElement>('eds-code-block');
|
|
21
|
+
export const EdsDropdown = /*@__PURE__*/createReactComponent<JSX.EdsDropdown, HTMLEdsDropdownElement>('eds-dropdown');
|
|
22
|
+
export const EdsFooter = /*@__PURE__*/createReactComponent<JSX.EdsFooter, HTMLEdsFooterElement>('eds-footer');
|
|
23
|
+
export const EdsForm = /*@__PURE__*/createReactComponent<JSX.EdsForm, HTMLEdsFormElement>('eds-form');
|
|
24
|
+
export const EdsFrame = /*@__PURE__*/createReactComponent<JSX.EdsFrame, HTMLEdsFrameElement>('eds-frame');
|
|
25
|
+
export const EdsFullscreenMenu = /*@__PURE__*/createReactComponent<JSX.EdsFullscreenMenu, HTMLEdsFullscreenMenuElement>('eds-fullscreen-menu');
|
|
26
|
+
export const EdsHeader = /*@__PURE__*/createReactComponent<JSX.EdsHeader, HTMLEdsHeaderElement>('eds-header');
|
|
27
|
+
export const EdsIconWrapper = /*@__PURE__*/createReactComponent<JSX.EdsIconWrapper, HTMLEdsIconWrapperElement>('eds-icon-wrapper');
|
|
28
|
+
export const EdsImg = /*@__PURE__*/createReactComponent<JSX.EdsImg, HTMLEdsImgElement>('eds-img');
|
|
29
|
+
export const EdsInputField = /*@__PURE__*/createReactComponent<JSX.EdsInputField, HTMLEdsInputFieldElement>('eds-input-field');
|
|
30
|
+
export const EdsLink = /*@__PURE__*/createReactComponent<JSX.EdsLink, HTMLEdsLinkElement>('eds-link');
|
|
31
|
+
export const EdsLogin = /*@__PURE__*/createReactComponent<JSX.EdsLogin, HTMLEdsLoginElement>('eds-login');
|
|
32
|
+
export const EdsLogo = /*@__PURE__*/createReactComponent<JSX.EdsLogo, HTMLEdsLogoElement>('eds-logo');
|
|
33
|
+
export const EdsMatomoNotice = /*@__PURE__*/createReactComponent<JSX.EdsMatomoNotice, HTMLEdsMatomoNoticeElement>('eds-matomo-notice');
|
|
34
|
+
export const EdsModal = /*@__PURE__*/createReactComponent<JSX.EdsModal, HTMLEdsModalElement>('eds-modal');
|
|
35
|
+
export const EdsPagination = /*@__PURE__*/createReactComponent<JSX.EdsPagination, HTMLEdsPaginationElement>('eds-pagination');
|
|
36
|
+
export const EdsProgressBar = /*@__PURE__*/createReactComponent<JSX.EdsProgressBar, HTMLEdsProgressBarElement>('eds-progress-bar');
|
|
37
|
+
export const EdsRating = /*@__PURE__*/createReactComponent<JSX.EdsRating, HTMLEdsRatingElement>('eds-rating');
|
|
38
|
+
export const EdsSectionCore = /*@__PURE__*/createReactComponent<JSX.EdsSectionCore, HTMLEdsSectionCoreElement>('eds-section-core');
|
|
39
|
+
export const EdsSectionHeading = /*@__PURE__*/createReactComponent<JSX.EdsSectionHeading, HTMLEdsSectionHeadingElement>('eds-section-heading');
|
|
40
|
+
export const EdsSocialNetworks = /*@__PURE__*/createReactComponent<JSX.EdsSocialNetworks, HTMLEdsSocialNetworksElement>('eds-social-networks');
|
|
41
|
+
export const EdsTable = /*@__PURE__*/createReactComponent<JSX.EdsTable, HTMLEdsTableElement>('eds-table');
|
|
42
|
+
export const EdsTabs = /*@__PURE__*/createReactComponent<JSX.EdsTabs, HTMLEdsTabsElement>('eds-tabs');
|
|
43
|
+
export const EdsTag = /*@__PURE__*/createReactComponent<JSX.EdsTag, HTMLEdsTagElement>('eds-tag');
|
|
44
|
+
export const EdsToast = /*@__PURE__*/createReactComponent<JSX.EdsToast, HTMLEdsToastElement>('eds-toast');
|
|
45
|
+
export const EdsToastManager = /*@__PURE__*/createReactComponent<JSX.EdsToastManager, HTMLEdsToastManagerElement>('eds-toast-manager');
|
|
46
|
+
export const EdsTooltip = /*@__PURE__*/createReactComponent<JSX.EdsTooltip, HTMLEdsTooltipElement>('eds-tooltip');
|
|
47
|
+
export const EdsUser = /*@__PURE__*/createReactComponent<JSX.EdsUser, HTMLEdsUserElement>('eds-user');
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { camelToDashCase } from './case';
|
|
2
|
+
|
|
3
|
+
export const attachProps = (node: HTMLElement, newProps: any, oldProps: any = {}) => {
|
|
4
|
+
// some test frameworks don't render DOM elements, so we test here to make sure we are dealing with DOM first
|
|
5
|
+
if (node instanceof Element) {
|
|
6
|
+
// add any classes in className to the class list
|
|
7
|
+
const className = getClassName(node.classList, newProps, oldProps);
|
|
8
|
+
if (className !== '') {
|
|
9
|
+
node.className = className;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Object.keys(newProps).forEach((name) => {
|
|
13
|
+
if (
|
|
14
|
+
name === 'children' ||
|
|
15
|
+
name === 'style' ||
|
|
16
|
+
name === 'ref' ||
|
|
17
|
+
name === 'class' ||
|
|
18
|
+
name === 'className' ||
|
|
19
|
+
name === 'forwardedRef'
|
|
20
|
+
) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
24
|
+
const eventName = name.substring(2);
|
|
25
|
+
const eventNameLc = eventName[0].toLowerCase() + eventName.substring(1);
|
|
26
|
+
|
|
27
|
+
if (!isCoveredByReact(eventNameLc)) {
|
|
28
|
+
syncEvent(node, eventNameLc, newProps[name]);
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
(node as any)[name] = newProps[name];
|
|
32
|
+
const propType = typeof newProps[name];
|
|
33
|
+
if (propType === 'string') {
|
|
34
|
+
node.setAttribute(camelToDashCase(name), newProps[name]);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export const getClassName = (classList: DOMTokenList, newProps: any, oldProps: any) => {
|
|
42
|
+
const newClassProp: string = newProps.className || newProps.class;
|
|
43
|
+
const oldClassProp: string = oldProps.className || oldProps.class;
|
|
44
|
+
// map the classes to Maps for performance
|
|
45
|
+
const currentClasses = arrayToMap(classList);
|
|
46
|
+
const incomingPropClasses = arrayToMap(newClassProp ? newClassProp.split(' ') : []);
|
|
47
|
+
const oldPropClasses = arrayToMap(oldClassProp ? oldClassProp.split(' ') : []);
|
|
48
|
+
const finalClassNames: string[] = [];
|
|
49
|
+
// loop through each of the current classes on the component
|
|
50
|
+
// to see if it should be a part of the classNames added
|
|
51
|
+
currentClasses.forEach((currentClass) => {
|
|
52
|
+
if (incomingPropClasses.has(currentClass)) {
|
|
53
|
+
// add it as its already included in classnames coming in from newProps
|
|
54
|
+
finalClassNames.push(currentClass);
|
|
55
|
+
incomingPropClasses.delete(currentClass);
|
|
56
|
+
} else if (!oldPropClasses.has(currentClass)) {
|
|
57
|
+
// add it as it has NOT been removed by user
|
|
58
|
+
finalClassNames.push(currentClass);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
incomingPropClasses.forEach((s) => finalClassNames.push(s));
|
|
62
|
+
return finalClassNames.join(' ');
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Transforms a React event name to a browser event name.
|
|
67
|
+
*/
|
|
68
|
+
export const transformReactEventName = (eventNameSuffix: string) => {
|
|
69
|
+
switch (eventNameSuffix) {
|
|
70
|
+
case 'doubleclick':
|
|
71
|
+
return 'dblclick';
|
|
72
|
+
}
|
|
73
|
+
return eventNameSuffix;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Checks if an event is supported in the current execution environment.
|
|
78
|
+
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
79
|
+
*/
|
|
80
|
+
export const isCoveredByReact = (eventNameSuffix: string) => {
|
|
81
|
+
if (typeof document === 'undefined') {
|
|
82
|
+
return true;
|
|
83
|
+
} else {
|
|
84
|
+
const eventName = 'on' + transformReactEventName(eventNameSuffix);
|
|
85
|
+
let isSupported = eventName in document;
|
|
86
|
+
|
|
87
|
+
if (!isSupported) {
|
|
88
|
+
const element = document.createElement('div');
|
|
89
|
+
element.setAttribute(eventName, 'return;');
|
|
90
|
+
isSupported = typeof (element as any)[eventName] === 'function';
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return isSupported;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const syncEvent = (
|
|
98
|
+
node: Element & { __events?: { [key: string]: ((e: Event) => any) | undefined } },
|
|
99
|
+
eventName: string,
|
|
100
|
+
newEventHandler?: (e: Event) => any
|
|
101
|
+
) => {
|
|
102
|
+
const eventStore = node.__events || (node.__events = {});
|
|
103
|
+
const oldEventHandler = eventStore[eventName];
|
|
104
|
+
|
|
105
|
+
// Remove old listener so they don't double up.
|
|
106
|
+
if (oldEventHandler) {
|
|
107
|
+
node.removeEventListener(eventName, oldEventHandler);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Bind new listener.
|
|
111
|
+
node.addEventListener(
|
|
112
|
+
eventName,
|
|
113
|
+
(eventStore[eventName] = function handler(e: Event) {
|
|
114
|
+
if (newEventHandler) {
|
|
115
|
+
newEventHandler.call(this, e);
|
|
116
|
+
}
|
|
117
|
+
})
|
|
118
|
+
);
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const arrayToMap = (arr: string[] | DOMTokenList) => {
|
|
122
|
+
const map = new Map<string, string>();
|
|
123
|
+
(arr as string[]).forEach((s: string) => map.set(s, s));
|
|
124
|
+
return map;
|
|
125
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const dashToPascalCase = (str: string) =>
|
|
2
|
+
str
|
|
3
|
+
.toLowerCase()
|
|
4
|
+
.split('-')
|
|
5
|
+
.map((segment) => segment.charAt(0).toUpperCase() + segment.slice(1))
|
|
6
|
+
.join('');
|
|
7
|
+
export const camelToDashCase = (str: string) => str.replace(/([A-Z])/g, (m: string) => `-${m[0].toLowerCase()}`);
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import React, { createElement } from 'react';
|
|
2
|
+
|
|
3
|
+
import { attachProps, camelToDashCase, createForwardRef, dashToPascalCase, isCoveredByReact, mergeRefs } from './utils';
|
|
4
|
+
|
|
5
|
+
export interface HTMLStencilElement extends HTMLElement {
|
|
6
|
+
componentOnReady(): Promise<this>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface StencilReactInternalProps<ElementType> extends React.HTMLAttributes<ElementType> {
|
|
10
|
+
forwardedRef: React.RefObject<ElementType>;
|
|
11
|
+
ref?: React.Ref<any>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const createReactComponent = <
|
|
15
|
+
PropType,
|
|
16
|
+
ElementType extends HTMLStencilElement,
|
|
17
|
+
ContextStateType = {},
|
|
18
|
+
ExpandedPropsTypes = {}
|
|
19
|
+
>(
|
|
20
|
+
tagName: string,
|
|
21
|
+
ReactComponentContext?: React.Context<ContextStateType>,
|
|
22
|
+
manipulatePropsFunction?: (
|
|
23
|
+
originalProps: StencilReactInternalProps<ElementType>,
|
|
24
|
+
propsToPass: any
|
|
25
|
+
) => ExpandedPropsTypes,
|
|
26
|
+
defineCustomElement?: () => void
|
|
27
|
+
) => {
|
|
28
|
+
if (defineCustomElement !== undefined) {
|
|
29
|
+
defineCustomElement();
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const displayName = dashToPascalCase(tagName);
|
|
33
|
+
const ReactComponent = class extends React.Component<StencilReactInternalProps<ElementType>> {
|
|
34
|
+
componentEl!: ElementType;
|
|
35
|
+
|
|
36
|
+
setComponentElRef = (element: ElementType) => {
|
|
37
|
+
this.componentEl = element;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
constructor(props: StencilReactInternalProps<ElementType>) {
|
|
41
|
+
super(props);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
componentDidMount() {
|
|
45
|
+
this.componentDidUpdate(this.props);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
componentDidUpdate(prevProps: StencilReactInternalProps<ElementType>) {
|
|
49
|
+
attachProps(this.componentEl, this.props, prevProps);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
render() {
|
|
53
|
+
const { children, forwardedRef, style, className, ref, ...cProps } = this.props;
|
|
54
|
+
|
|
55
|
+
let propsToPass = Object.keys(cProps).reduce((acc: any, name) => {
|
|
56
|
+
const value = (cProps as any)[name];
|
|
57
|
+
|
|
58
|
+
if (name.indexOf('on') === 0 && name[2] === name[2].toUpperCase()) {
|
|
59
|
+
const eventName = name.substring(2).toLowerCase();
|
|
60
|
+
if (typeof document !== 'undefined' && isCoveredByReact(eventName)) {
|
|
61
|
+
acc[name] = value;
|
|
62
|
+
}
|
|
63
|
+
} else {
|
|
64
|
+
// we should only render strings, booleans, and numbers as attrs in html.
|
|
65
|
+
// objects, functions, arrays etc get synced via properties on mount.
|
|
66
|
+
const type = typeof value;
|
|
67
|
+
|
|
68
|
+
if (type === 'string' || type === 'boolean' || type === 'number') {
|
|
69
|
+
acc[camelToDashCase(name)] = value;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return acc;
|
|
73
|
+
}, {} as ExpandedPropsTypes);
|
|
74
|
+
|
|
75
|
+
if (manipulatePropsFunction) {
|
|
76
|
+
propsToPass = manipulatePropsFunction(this.props, propsToPass);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const newProps: Omit<StencilReactInternalProps<ElementType>, 'forwardedRef'> = {
|
|
80
|
+
...propsToPass,
|
|
81
|
+
ref: mergeRefs(forwardedRef, this.setComponentElRef),
|
|
82
|
+
style,
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* We use createElement here instead of
|
|
87
|
+
* React.createElement to work around a
|
|
88
|
+
* bug in Vite (https://github.com/vitejs/vite/issues/6104).
|
|
89
|
+
* React.createElement causes all elements to be rendered
|
|
90
|
+
* as <tagname> instead of the actual Web Component.
|
|
91
|
+
*/
|
|
92
|
+
return createElement(tagName, newProps, children);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
static get displayName() {
|
|
96
|
+
return displayName;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
// If context was passed to createReactComponent then conditionally add it to the Component Class
|
|
101
|
+
if (ReactComponentContext) {
|
|
102
|
+
ReactComponent.contextType = ReactComponentContext;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return createForwardRef<PropType, ElementType>(ReactComponent, displayName);
|
|
106
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom';
|
|
3
|
+
|
|
4
|
+
import { OverlayEventDetail } from './interfaces';
|
|
5
|
+
import { StencilReactForwardedRef, attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils';
|
|
6
|
+
|
|
7
|
+
interface OverlayElement extends HTMLElement {
|
|
8
|
+
present: () => Promise<void>;
|
|
9
|
+
dismiss: (data?: any, role?: string | undefined) => Promise<boolean>;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ReactOverlayProps {
|
|
13
|
+
children?: React.ReactNode;
|
|
14
|
+
isOpen: boolean;
|
|
15
|
+
onDidDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
16
|
+
onDidPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
17
|
+
onWillDismiss?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
18
|
+
onWillPresent?: (event: CustomEvent<OverlayEventDetail>) => void;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export const createOverlayComponent = <OverlayComponent extends object, OverlayType extends OverlayElement>(
|
|
22
|
+
tagName: string,
|
|
23
|
+
controller: { create: (options: any) => Promise<OverlayType> },
|
|
24
|
+
customElement?: any
|
|
25
|
+
) => {
|
|
26
|
+
defineCustomElement(tagName, customElement);
|
|
27
|
+
|
|
28
|
+
const displayName = dashToPascalCase(tagName);
|
|
29
|
+
const didDismissEventName = `on${displayName}DidDismiss`;
|
|
30
|
+
const didPresentEventName = `on${displayName}DidPresent`;
|
|
31
|
+
const willDismissEventName = `on${displayName}WillDismiss`;
|
|
32
|
+
const willPresentEventName = `on${displayName}WillPresent`;
|
|
33
|
+
|
|
34
|
+
type Props = OverlayComponent &
|
|
35
|
+
ReactOverlayProps & {
|
|
36
|
+
forwardedRef?: StencilReactForwardedRef<OverlayType>;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
let isDismissing = false;
|
|
40
|
+
|
|
41
|
+
class Overlay extends React.Component<Props> {
|
|
42
|
+
overlay?: OverlayType;
|
|
43
|
+
el!: HTMLDivElement;
|
|
44
|
+
|
|
45
|
+
constructor(props: Props) {
|
|
46
|
+
super(props);
|
|
47
|
+
if (typeof document !== 'undefined') {
|
|
48
|
+
this.el = document.createElement('div');
|
|
49
|
+
}
|
|
50
|
+
this.handleDismiss = this.handleDismiss.bind(this);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
static get displayName() {
|
|
54
|
+
return displayName;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
componentDidMount() {
|
|
58
|
+
if (this.props.isOpen) {
|
|
59
|
+
this.present();
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
componentWillUnmount() {
|
|
64
|
+
if (this.overlay) {
|
|
65
|
+
this.overlay.dismiss();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
handleDismiss(event: CustomEvent<OverlayEventDetail<any>>) {
|
|
70
|
+
if (this.props.onDidDismiss) {
|
|
71
|
+
this.props.onDidDismiss(event);
|
|
72
|
+
}
|
|
73
|
+
setRef(this.props.forwardedRef, null);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
shouldComponentUpdate(nextProps: Props) {
|
|
77
|
+
// Check if the overlay component is about to dismiss
|
|
78
|
+
if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
|
|
79
|
+
isDismissing = true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return true;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async componentDidUpdate(prevProps: Props) {
|
|
86
|
+
if (this.overlay) {
|
|
87
|
+
attachProps(this.overlay, this.props, prevProps);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
|
|
91
|
+
this.present(prevProps);
|
|
92
|
+
}
|
|
93
|
+
if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
|
|
94
|
+
await this.overlay.dismiss();
|
|
95
|
+
isDismissing = false;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Now that the overlay is dismissed
|
|
99
|
+
* we need to render again so that any
|
|
100
|
+
* inner components will be unmounted
|
|
101
|
+
*/
|
|
102
|
+
this.forceUpdate();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async present(prevProps?: Props) {
|
|
107
|
+
const { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent, ...cProps } = this.props;
|
|
108
|
+
const elementProps = {
|
|
109
|
+
...cProps,
|
|
110
|
+
ref: this.props.forwardedRef,
|
|
111
|
+
[didDismissEventName]: this.handleDismiss,
|
|
112
|
+
[didPresentEventName]: (e: CustomEvent) => this.props.onDidPresent && this.props.onDidPresent(e),
|
|
113
|
+
[willDismissEventName]: (e: CustomEvent) => this.props.onWillDismiss && this.props.onWillDismiss(e),
|
|
114
|
+
[willPresentEventName]: (e: CustomEvent) => this.props.onWillPresent && this.props.onWillPresent(e),
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
this.overlay = await controller.create({
|
|
118
|
+
...elementProps,
|
|
119
|
+
component: this.el,
|
|
120
|
+
componentProps: {},
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
setRef(this.props.forwardedRef, this.overlay);
|
|
124
|
+
attachProps(this.overlay, elementProps, prevProps);
|
|
125
|
+
|
|
126
|
+
await this.overlay.present();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
render() {
|
|
130
|
+
/**
|
|
131
|
+
* Continue to render the component even when
|
|
132
|
+
* overlay is dismissing otherwise component
|
|
133
|
+
* will be hidden before animation is done.
|
|
134
|
+
*/
|
|
135
|
+
return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return React.forwardRef<OverlayType, Props>((props, ref) => {
|
|
140
|
+
return <Overlay {...props} forwardedRef={ref} />;
|
|
141
|
+
});
|
|
142
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export const isDevMode = () => {
|
|
2
|
+
return process && process.env && process.env.NODE_ENV === 'development';
|
|
3
|
+
};
|
|
4
|
+
|
|
5
|
+
const warnings: { [key: string]: boolean } = {};
|
|
6
|
+
|
|
7
|
+
export const deprecationWarning = (key: string, message: string) => {
|
|
8
|
+
if (isDevMode()) {
|
|
9
|
+
if (!warnings[key]) {
|
|
10
|
+
console.warn(message);
|
|
11
|
+
warnings[key] = true;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import type { StyleReactProps } from '../interfaces';
|
|
4
|
+
|
|
5
|
+
export type StencilReactExternalProps<PropType, ElementType> = PropType &
|
|
6
|
+
Omit<React.HTMLAttributes<ElementType>, 'style'> &
|
|
7
|
+
StyleReactProps;
|
|
8
|
+
|
|
9
|
+
// This will be replaced with React.ForwardedRef when react-output-target is upgraded to React v17
|
|
10
|
+
export type StencilReactForwardedRef<T> = ((instance: T | null) => void) | React.MutableRefObject<T | null> | null;
|
|
11
|
+
|
|
12
|
+
export const setRef = (ref: StencilReactForwardedRef<any> | React.Ref<any> | undefined, value: any) => {
|
|
13
|
+
if (typeof ref === 'function') {
|
|
14
|
+
ref(value);
|
|
15
|
+
} else if (ref != null) {
|
|
16
|
+
// Cast as a MutableRef so we can assign current
|
|
17
|
+
(ref as React.MutableRefObject<any>).current = value;
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const mergeRefs = (
|
|
22
|
+
...refs: (StencilReactForwardedRef<any> | React.Ref<any> | undefined)[]
|
|
23
|
+
): React.RefCallback<any> => {
|
|
24
|
+
return (value: any) => {
|
|
25
|
+
refs.forEach((ref) => {
|
|
26
|
+
setRef(ref, value);
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const createForwardRef = <PropType, ElementType>(ReactComponent: any, displayName: string) => {
|
|
32
|
+
const forwardRef = (
|
|
33
|
+
props: StencilReactExternalProps<PropType, ElementType>,
|
|
34
|
+
ref: StencilReactForwardedRef<ElementType>
|
|
35
|
+
) => {
|
|
36
|
+
return <ReactComponent {...props} forwardedRef={ref} />;
|
|
37
|
+
};
|
|
38
|
+
forwardRef.displayName = displayName;
|
|
39
|
+
|
|
40
|
+
return React.forwardRef(forwardRef);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export const defineCustomElement = (tagName: string, customElement: any) => {
|
|
44
|
+
if (customElement !== undefined && typeof customElements !== 'undefined' && !customElements.get(tagName)) {
|
|
45
|
+
customElements.define(tagName, customElement);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
export * from './attachProps';
|
|
50
|
+
export * from './case';
|