@getpara/react-components 1.2.0 → 1.3.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/dist/index.js CHANGED
@@ -1,3 +1,6 @@
1
- export * from './components/stencil-generated/index.js';
2
- export { defineCustomElements } from '@getpara/core-components';
3
- export { generateTheme } from '@getpara/core-components';
1
+ "use client";
2
+ import X,{createElement as P}from"react";import M from"react";var S=t=>t.toLowerCase().split("-").map(s=>s.charAt(0).toUpperCase()+s.slice(1)).join(""),m=t=>t.replace(/([A-Z])/g,s=>`-${s[0].toLowerCase()}`);var R=(t,s,p={})=>{if(t instanceof Element){let n=b(t.classList,s,p);n!==""&&(t.className=n),Object.keys(s).forEach(o=>{if(!(o==="children"||o==="style"||o==="ref"||o==="class"||o==="className"||o==="forwardedRef"))if(o.indexOf("on")===0&&o[2]===o[2].toUpperCase()){let l=o.substring(2),r=l[0].toLowerCase()+l.substring(1);x(r)||v(t,r,s[o])}else t[o]=s[o],typeof s[o]==="string"&&t.setAttribute(m(o),s[o])})}},b=(t,s,p)=>{let n=s.className||s.class,o=p.className||p.class,l=E(t),r=E(n?n.split(" "):[]),c=E(o?o.split(" "):[]),C=[];return l.forEach(a=>{r.has(a)?(C.push(a),r.delete(a)):c.has(a)||C.push(a)}),r.forEach(a=>C.push(a)),C.join(" ")},g=t=>{switch(t){case"doubleclick":return"dblclick"}return t};var x=t=>{if(typeof document>"u")return!0;{let s="on"+g(t),p=s in document;if(!p){let n=document.createElement("div");n.setAttribute(s,"return;"),p=typeof n[s]=="function"}return p}},v=(t,s,p)=>{let n=t.__events||(t.__events={}),o=n[s];o&&t.removeEventListener(s,o),t.addEventListener(s,n[s]=function(r){p&&p.call(this,r)})},E=t=>{let s=new Map;return t.forEach(p=>s.set(p,p)),s};var J=(t,s)=>{typeof t=="function"?t(s):t!=null&&(t.current=s)},L=(...t)=>s=>{t.forEach(p=>{J(p,s)})},H=(t,s)=>{let p=(n,o)=>M.createElement(t,{...n,forwardedRef:o});return p.displayName=s,M.forwardRef(p)};var e=(t,s,p,n)=>{n!==void 0&&n();let o=S(t),l=class extends X.Component{constructor(c){super(c);this.setComponentElRef=c=>{this.componentEl=c}}componentDidMount(){this.componentDidUpdate(this.props)}componentDidUpdate(c){R(this.componentEl,this.props,c)}render(){let{children:c,forwardedRef:C,style:a,className:I,ref:w,...y}=this.props,T=Object.keys(y).reduce((f,i)=>{let u=y[i];if(i.indexOf("on")===0&&i[2]===i[2].toUpperCase()){let d=i.substring(2).toLowerCase();typeof document<"u"&&x(d)&&(f[i]=u)}else{let d=typeof u;(d==="string"||d==="boolean"||d==="number")&&(f[m(i)]=u)}return f},{});p&&(T=p(this.props,T));let h={...T,ref:L(C,this.setComponentElRef),style:a};return P(t,h,c)}static get displayName(){return o}};return s&&(l.contextType=s),H(l,o)};var Z=e("cpsl-alert"),$=e("cpsl-app-bar"),z=e("cpsl-auth-modal"),K=e("cpsl-avatar"),W=e("cpsl-button"),Y=e("cpsl-button-group"),ee=e("cpsl-card"),te=e("cpsl-checkbox"),se=e("cpsl-code-input"),oe=e("cpsl-col"),pe=e("cpsl-divider"),ne=e("cpsl-drawer"),le=e("cpsl-dropdown"),re=e("cpsl-file-upload"),ce=e("cpsl-grid"),ae=e("cpsl-hero"),ie=e("cpsl-icon"),Ce=e("cpsl-icon-group"),de=e("cpsl-identicon"),me=e("cpsl-info-box"),Te=e("cpsl-input"),fe=e("cpsl-modal-v2"),ue=e("cpsl-nav-button"),Ee=e("cpsl-nav-button-group"),xe=e("cpsl-overlay"),ye=e("cpsl-pagination"),Se=e("cpsl-pill"),Re=e("cpsl-popover"),Me=e("cpsl-progress-indicator"),Le=e("cpsl-qr-code"),He=e("cpsl-radio"),he=e("cpsl-row"),be=e("cpsl-select"),ge=e("cpsl-select-item"),ve=e("cpsl-slide-button"),Je=e("cpsl-spinner"),Xe=e("cpsl-switch"),Pe=e("cpsl-tab"),Ie=e("cpsl-table"),we=e("cpsl-tabs"),Be=e("cpsl-text"),Ae=e("cpsl-tile-button");import{defineCustomElements as Ge}from"@getpara/core-components";import{generateTheme as Fe}from"@getpara/core-components";export{Z as CpslAlert,$ as CpslAppBar,z as CpslAuthModal,K as CpslAvatar,W as CpslButton,Y as CpslButtonGroup,ee as CpslCard,te as CpslCheckbox,se as CpslCodeInput,oe as CpslCol,pe as CpslDivider,ne as CpslDrawer,le as CpslDropdown,re as CpslFileUpload,ce as CpslGrid,ae as CpslHero,ie as CpslIcon,Ce as CpslIconGroup,de as CpslIdenticon,me as CpslInfoBox,Te as CpslInput,fe as CpslModalV2,ue as CpslNavButton,Ee as CpslNavButtonGroup,xe as CpslOverlay,ye as CpslPagination,Se as CpslPill,Re as CpslPopover,Me as CpslProgressIndicator,Le as CpslQrCode,He as CpslRadio,he as CpslRow,be as CpslSelect,ge as CpslSelectItem,ve as CpslSlideButton,Je as CpslSpinner,Xe as CpslSwitch,Pe as CpslTab,Ie as CpslTable,we as CpslTabs,Be as CpslText,Ae as CpslTileButton,Ge as defineCustomElements,Fe as generateTheme};
3
+ /**
4
+ * Checks if an event is supported in the current execution environment.
5
+ * @license Modernizr 3.0.0pre (Custom Build) | MIT
6
+ */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getpara/react-components",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Capsule Core React Components",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -23,22 +23,24 @@
23
23
  "css/"
24
24
  ],
25
25
  "scripts": {
26
- "build": "node scripts/fixExtensions.js && yarn copy && yarn tsc",
26
+ "old-build": "node scripts/fixExtensions.js && yarn copy && yarn tsc",
27
+ "build": "node scripts/fixExtensions.js && yarn copy && rm -rf dist && node ./scripts/build.mjs && yarn typegen",
28
+ "typegen": "tsc --emitDeclarationOnly",
27
29
  "tsc": "tsc -p . --outDir ./dist",
28
30
  "copy": "node scripts/copy.cjs"
29
31
  },
30
32
  "dependencies": {
31
- "@getpara/core-components": "1.2.0"
33
+ "@getpara/core-components": "1.3.0"
32
34
  },
33
35
  "devDependencies": {
34
36
  "@types/react": "^18.2.64",
35
37
  "glob": "^11.0.0",
36
- "react": "^18.2.0",
37
- "react-dom": "^18.2.0",
38
+ "react": "18.2.0",
39
+ "react-dom": "18.2.0",
38
40
  "typescript": "^5.4.2"
39
41
  },
40
42
  "publishConfig": {
41
43
  "access": "public"
42
44
  },
43
- "gitHead": "a9162c59be1456292d46c56787c1d5bf313bf24b"
45
+ "gitHead": "2d421556a0a1497abd08e18dca94f08ec3ad640b"
44
46
  }
@@ -1,46 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
- /* auto-generated react proxies */
4
- import { createReactComponent } from './react-component-lib/index.js';
5
- export const CpslAlert = /*@__PURE__*/ createReactComponent('cpsl-alert');
6
- export const CpslAppBar = /*@__PURE__*/ createReactComponent('cpsl-app-bar');
7
- export const CpslAuthModal = /*@__PURE__*/ createReactComponent('cpsl-auth-modal');
8
- export const CpslAvatar = /*@__PURE__*/ createReactComponent('cpsl-avatar');
9
- export const CpslButton = /*@__PURE__*/ createReactComponent('cpsl-button');
10
- export const CpslButtonGroup = /*@__PURE__*/ createReactComponent('cpsl-button-group');
11
- export const CpslCard = /*@__PURE__*/ createReactComponent('cpsl-card');
12
- export const CpslCheckbox = /*@__PURE__*/ createReactComponent('cpsl-checkbox');
13
- export const CpslCodeInput = /*@__PURE__*/ createReactComponent('cpsl-code-input');
14
- export const CpslCol = /*@__PURE__*/ createReactComponent('cpsl-col');
15
- export const CpslDivider = /*@__PURE__*/ createReactComponent('cpsl-divider');
16
- export const CpslDrawer = /*@__PURE__*/ createReactComponent('cpsl-drawer');
17
- export const CpslDropdown = /*@__PURE__*/ createReactComponent('cpsl-dropdown');
18
- export const CpslFileUpload = /*@__PURE__*/ createReactComponent('cpsl-file-upload');
19
- export const CpslGrid = /*@__PURE__*/ createReactComponent('cpsl-grid');
20
- export const CpslHero = /*@__PURE__*/ createReactComponent('cpsl-hero');
21
- export const CpslIcon = /*@__PURE__*/ createReactComponent('cpsl-icon');
22
- export const CpslIconGroup = /*@__PURE__*/ createReactComponent('cpsl-icon-group');
23
- export const CpslIdenticon = /*@__PURE__*/ createReactComponent('cpsl-identicon');
24
- export const CpslInfoBox = /*@__PURE__*/ createReactComponent('cpsl-info-box');
25
- export const CpslInput = /*@__PURE__*/ createReactComponent('cpsl-input');
26
- export const CpslModalV2 = /*@__PURE__*/ createReactComponent('cpsl-modal-v2');
27
- export const CpslNavButton = /*@__PURE__*/ createReactComponent('cpsl-nav-button');
28
- export const CpslNavButtonGroup = /*@__PURE__*/ createReactComponent('cpsl-nav-button-group');
29
- export const CpslOverlay = /*@__PURE__*/ createReactComponent('cpsl-overlay');
30
- export const CpslPagination = /*@__PURE__*/ createReactComponent('cpsl-pagination');
31
- export const CpslPill = /*@__PURE__*/ createReactComponent('cpsl-pill');
32
- export const CpslPopover = /*@__PURE__*/ createReactComponent('cpsl-popover');
33
- export const CpslProgressIndicator = /*@__PURE__*/ createReactComponent('cpsl-progress-indicator');
34
- export const CpslQrCode = /*@__PURE__*/ createReactComponent('cpsl-qr-code');
35
- export const CpslRadio = /*@__PURE__*/ createReactComponent('cpsl-radio');
36
- export const CpslRow = /*@__PURE__*/ createReactComponent('cpsl-row');
37
- export const CpslSelect = /*@__PURE__*/ createReactComponent('cpsl-select');
38
- export const CpslSelectItem = /*@__PURE__*/ createReactComponent('cpsl-select-item');
39
- export const CpslSlideButton = /*@__PURE__*/ createReactComponent('cpsl-slide-button');
40
- export const CpslSpinner = /*@__PURE__*/ createReactComponent('cpsl-spinner');
41
- export const CpslSwitch = /*@__PURE__*/ createReactComponent('cpsl-switch');
42
- export const CpslTab = /*@__PURE__*/ createReactComponent('cpsl-tab');
43
- export const CpslTable = /*@__PURE__*/ createReactComponent('cpsl-table');
44
- export const CpslTabs = /*@__PURE__*/ createReactComponent('cpsl-tabs');
45
- export const CpslText = /*@__PURE__*/ createReactComponent('cpsl-text');
46
- export const CpslTileButton = /*@__PURE__*/ createReactComponent('cpsl-tile-button');
@@ -1,74 +0,0 @@
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/index.js';
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
- };
@@ -1,108 +0,0 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
- var __rest = (this && this.__rest) || function (s, e) {
11
- var t = {};
12
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
13
- t[p] = s[p];
14
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
15
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
16
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
17
- t[p[i]] = s[p[i]];
18
- }
19
- return t;
20
- };
21
- import React from 'react';
22
- import ReactDOM from 'react-dom';
23
- import { attachProps, dashToPascalCase, defineCustomElement, setRef } from './utils/index.js';
24
- export const createOverlayComponent = (tagName, controller, customElement) => {
25
- defineCustomElement(tagName, customElement);
26
- const displayName = dashToPascalCase(tagName);
27
- const didDismissEventName = `on${displayName}DidDismiss`;
28
- const didPresentEventName = `on${displayName}DidPresent`;
29
- const willDismissEventName = `on${displayName}WillDismiss`;
30
- const willPresentEventName = `on${displayName}WillPresent`;
31
- let isDismissing = false;
32
- class Overlay extends React.Component {
33
- constructor(props) {
34
- super(props);
35
- if (typeof document !== 'undefined') {
36
- this.el = document.createElement('div');
37
- }
38
- this.handleDismiss = this.handleDismiss.bind(this);
39
- }
40
- static get displayName() {
41
- return displayName;
42
- }
43
- componentDidMount() {
44
- if (this.props.isOpen) {
45
- this.present();
46
- }
47
- }
48
- componentWillUnmount() {
49
- if (this.overlay) {
50
- this.overlay.dismiss();
51
- }
52
- }
53
- handleDismiss(event) {
54
- if (this.props.onDidDismiss) {
55
- this.props.onDidDismiss(event);
56
- }
57
- setRef(this.props.forwardedRef, null);
58
- }
59
- shouldComponentUpdate(nextProps) {
60
- // Check if the overlay component is about to dismiss
61
- if (this.overlay && nextProps.isOpen !== this.props.isOpen && nextProps.isOpen === false) {
62
- isDismissing = true;
63
- }
64
- return true;
65
- }
66
- componentDidUpdate(prevProps) {
67
- return __awaiter(this, void 0, void 0, function* () {
68
- if (this.overlay) {
69
- attachProps(this.overlay, this.props, prevProps);
70
- }
71
- if (prevProps.isOpen !== this.props.isOpen && this.props.isOpen === true) {
72
- this.present(prevProps);
73
- }
74
- if (this.overlay && prevProps.isOpen !== this.props.isOpen && this.props.isOpen === false) {
75
- yield this.overlay.dismiss();
76
- isDismissing = false;
77
- /**
78
- * Now that the overlay is dismissed
79
- * we need to render again so that any
80
- * inner components will be unmounted
81
- */
82
- this.forceUpdate();
83
- }
84
- });
85
- }
86
- present(prevProps) {
87
- return __awaiter(this, void 0, void 0, function* () {
88
- const _a = this.props, { children, isOpen, onDidDismiss, onDidPresent, onWillDismiss, onWillPresent } = _a, cProps = __rest(_a, ["children", "isOpen", "onDidDismiss", "onDidPresent", "onWillDismiss", "onWillPresent"]);
89
- 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) });
90
- this.overlay = yield controller.create(Object.assign(Object.assign({}, elementProps), { component: this.el, componentProps: {} }));
91
- setRef(this.props.forwardedRef, this.overlay);
92
- attachProps(this.overlay, elementProps, prevProps);
93
- yield this.overlay.present();
94
- });
95
- }
96
- render() {
97
- /**
98
- * Continue to render the component even when
99
- * overlay is dismissing otherwise component
100
- * will be hidden before animation is done.
101
- */
102
- return ReactDOM.createPortal(this.props.isOpen || isDismissing ? this.props.children : null, this.el);
103
- }
104
- }
105
- return React.forwardRef((props, ref) => {
106
- return React.createElement(Overlay, Object.assign({}, props, { forwardedRef: ref }));
107
- });
108
- };
@@ -1,2 +0,0 @@
1
- export { createReactComponent } from './createComponent.js';
2
- export { createOverlayComponent } from './createOverlayComponent.js';
@@ -1,107 +0,0 @@
1
- import { camelToDashCase } from './case.js';
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
- };
@@ -1,6 +0,0 @@
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()}`);
@@ -1,12 +0,0 @@
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
- };
@@ -1,31 +0,0 @@
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.js';
31
- export * from './case.js';