@veeqo/ui 13.13.3 → 13.14.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.
@@ -1,2 +1,3 @@
1
1
  export { withLabels } from './withLabels';
2
2
  export { withDeprecated } from './withDeprecated';
3
+ export { withClassNames } from './withClassNames';
@@ -0,0 +1 @@
1
+ export { withClassNames } from './withClassNames';
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var buildClassnames = require('../../utils/buildClassnames.cjs');
5
+
6
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
7
+
8
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
9
+
10
+ /**
11
+ * Creates a wrapper for a specified component that applies a given set of className's when rendered. Useful when
12
+ * you're rendering multiple components which need to have the same CSS module classnames applied, allowing us to use
13
+ * a similar approach to styled-components.
14
+ *
15
+ * Example usage:
16
+ *
17
+ * `styled.ts`:
18
+ * ```
19
+ * const StyledButton = withClassNames(Button, ['button', 'button--primary']);
20
+ * ```
21
+ *
22
+ * `component.tsx`:
23
+ * ```
24
+ * <StyledButton className="other-class">Click me</StyledButton>
25
+ * ```
26
+ *
27
+ * @param Component Component to render with styles applied.
28
+ * @param classNames An array of class names to apply to instances of the component.
29
+ */
30
+ const withClassNames = (Component, classNames) => {
31
+ const ComponentWithClassNames = React__default.default.forwardRef(({ className, ...props }, ref) => React__default.default.createElement(Component, {
32
+ ...props,
33
+ ref,
34
+ className: buildClassnames.buildClassnames([...classNames, className]),
35
+ }));
36
+ const componentName = typeof Component === 'string'
37
+ ? Component
38
+ : Component.displayName ||
39
+ Component.name ||
40
+ 'Component';
41
+ ComponentWithClassNames.displayName = `withClassNames(${componentName})`;
42
+ return ComponentWithClassNames;
43
+ };
44
+
45
+ exports.withClassNames = withClassNames;
46
+ //# sourceMappingURL=withClassNames.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withClassNames.cjs","sources":["../../../src/hoc/withClassNames/withClassNames.ts"],"sourcesContent":["import React from 'react';\nimport { AnyStyledComponent } from 'styled-components';\nimport { buildClassnames } from '../../utils/buildClassnames';\n\n/**\n * Creates a wrapper for a specified component that applies a given set of className's when rendered. Useful when\n * you're rendering multiple components which need to have the same CSS module classnames applied, allowing us to use\n * a similar approach to styled-components.\n *\n * Example usage:\n *\n * `styled.ts`:\n * ```\n * const StyledButton = withClassNames(Button, ['button', 'button--primary']);\n * ```\n *\n * `component.tsx`:\n * ```\n * <StyledButton className=\"other-class\">Click me</StyledButton>\n * ```\n *\n * @param Component Component to render with styles applied.\n * @param classNames An array of class names to apply to instances of the component.\n */\nexport const withClassNames = <P extends { className?: string }>(\n Component: React.ComponentType<P> | keyof JSX.IntrinsicElements | AnyStyledComponent,\n classNames: string[],\n) => {\n const ComponentWithClassNames = React.forwardRef<unknown, P>(({ className, ...props }, ref) =>\n React.createElement(Component, {\n ...(props as P),\n ref,\n className: buildClassnames([...classNames, className]),\n }),\n );\n\n const componentName =\n typeof Component === 'string'\n ? Component\n : (Component as React.ComponentType<P>).displayName ||\n (Component as React.ComponentType<P>).name ||\n 'Component';\n\n ComponentWithClassNames.displayName = `withClassNames(${componentName})`;\n\n return ComponentWithClassNames;\n};\n"],"names":["React","buildClassnames"],"mappings":";;;;;;;;;AAIA;;;;;;;;;;;;;;;;;;;AAmBG;MACU,cAAc,GAAG,CAC5B,SAAoF,EACpF,UAAoB,KAClB;IACF,MAAM,uBAAuB,GAAGA,sBAAK,CAAC,UAAU,CAAa,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KACxFA,sBAAK,CAAC,aAAa,CAAC,SAAS,EAAE;AAC7B,QAAA,GAAI,KAAW;QACf,GAAG;QACH,SAAS,EAAEC,+BAAe,CAAC,CAAC,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC;AACvD,KAAA,CAAC,CACH;AAED,IAAA,MAAM,aAAa,GACjB,OAAO,SAAS,KAAK;AACnB,UAAE;UACC,SAAoC,CAAC,WAAW;AAChD,YAAA,SAAoC,CAAC,IAAI;AAC1C,YAAA,WAAW;AAEjB,IAAA,uBAAuB,CAAC,WAAW,GAAG,CAAkB,eAAA,EAAA,aAAa,GAAG;AAExE,IAAA,OAAO,uBAAuB;AAChC;;;;"}
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { AnyStyledComponent } from 'styled-components';
3
+ /**
4
+ * Creates a wrapper for a specified component that applies a given set of className's when rendered. Useful when
5
+ * you're rendering multiple components which need to have the same CSS module classnames applied, allowing us to use
6
+ * a similar approach to styled-components.
7
+ *
8
+ * Example usage:
9
+ *
10
+ * `styled.ts`:
11
+ * ```
12
+ * const StyledButton = withClassNames(Button, ['button', 'button--primary']);
13
+ * ```
14
+ *
15
+ * `component.tsx`:
16
+ * ```
17
+ * <StyledButton className="other-class">Click me</StyledButton>
18
+ * ```
19
+ *
20
+ * @param Component Component to render with styles applied.
21
+ * @param classNames An array of class names to apply to instances of the component.
22
+ */
23
+ export declare const withClassNames: <P extends {
24
+ className?: string | undefined;
25
+ }>(Component: keyof JSX.IntrinsicElements | AnyStyledComponent | React.ComponentType<P>, classNames: string[]) => React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<unknown>>;
@@ -0,0 +1,40 @@
1
+ import React__default from 'react';
2
+ import { buildClassnames } from '../../utils/buildClassnames.js';
3
+
4
+ /**
5
+ * Creates a wrapper for a specified component that applies a given set of className's when rendered. Useful when
6
+ * you're rendering multiple components which need to have the same CSS module classnames applied, allowing us to use
7
+ * a similar approach to styled-components.
8
+ *
9
+ * Example usage:
10
+ *
11
+ * `styled.ts`:
12
+ * ```
13
+ * const StyledButton = withClassNames(Button, ['button', 'button--primary']);
14
+ * ```
15
+ *
16
+ * `component.tsx`:
17
+ * ```
18
+ * <StyledButton className="other-class">Click me</StyledButton>
19
+ * ```
20
+ *
21
+ * @param Component Component to render with styles applied.
22
+ * @param classNames An array of class names to apply to instances of the component.
23
+ */
24
+ const withClassNames = (Component, classNames) => {
25
+ const ComponentWithClassNames = React__default.forwardRef(({ className, ...props }, ref) => React__default.createElement(Component, {
26
+ ...props,
27
+ ref,
28
+ className: buildClassnames([...classNames, className]),
29
+ }));
30
+ const componentName = typeof Component === 'string'
31
+ ? Component
32
+ : Component.displayName ||
33
+ Component.name ||
34
+ 'Component';
35
+ ComponentWithClassNames.displayName = `withClassNames(${componentName})`;
36
+ return ComponentWithClassNames;
37
+ };
38
+
39
+ export { withClassNames };
40
+ //# sourceMappingURL=withClassNames.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withClassNames.js","sources":["../../../src/hoc/withClassNames/withClassNames.ts"],"sourcesContent":["import React from 'react';\nimport { AnyStyledComponent } from 'styled-components';\nimport { buildClassnames } from '../../utils/buildClassnames';\n\n/**\n * Creates a wrapper for a specified component that applies a given set of className's when rendered. Useful when\n * you're rendering multiple components which need to have the same CSS module classnames applied, allowing us to use\n * a similar approach to styled-components.\n *\n * Example usage:\n *\n * `styled.ts`:\n * ```\n * const StyledButton = withClassNames(Button, ['button', 'button--primary']);\n * ```\n *\n * `component.tsx`:\n * ```\n * <StyledButton className=\"other-class\">Click me</StyledButton>\n * ```\n *\n * @param Component Component to render with styles applied.\n * @param classNames An array of class names to apply to instances of the component.\n */\nexport const withClassNames = <P extends { className?: string }>(\n Component: React.ComponentType<P> | keyof JSX.IntrinsicElements | AnyStyledComponent,\n classNames: string[],\n) => {\n const ComponentWithClassNames = React.forwardRef<unknown, P>(({ className, ...props }, ref) =>\n React.createElement(Component, {\n ...(props as P),\n ref,\n className: buildClassnames([...classNames, className]),\n }),\n );\n\n const componentName =\n typeof Component === 'string'\n ? Component\n : (Component as React.ComponentType<P>).displayName ||\n (Component as React.ComponentType<P>).name ||\n 'Component';\n\n ComponentWithClassNames.displayName = `withClassNames(${componentName})`;\n\n return ComponentWithClassNames;\n};\n"],"names":["React"],"mappings":";;;AAIA;;;;;;;;;;;;;;;;;;;AAmBG;MACU,cAAc,GAAG,CAC5B,SAAoF,EACpF,UAAoB,KAClB;IACF,MAAM,uBAAuB,GAAGA,cAAK,CAAC,UAAU,CAAa,CAAC,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,EAAE,GAAG,KACxFA,cAAK,CAAC,aAAa,CAAC,SAAS,EAAE;AAC7B,QAAA,GAAI,KAAW;QACf,GAAG;QACH,SAAS,EAAE,eAAe,CAAC,CAAC,GAAG,UAAU,EAAE,SAAS,CAAC,CAAC;AACvD,KAAA,CAAC,CACH;AAED,IAAA,MAAM,aAAa,GACjB,OAAO,SAAS,KAAK;AACnB,UAAE;UACC,SAAoC,CAAC,WAAW;AAChD,YAAA,SAAoC,CAAC,IAAI;AAC1C,YAAA,WAAW;AAEjB,IAAA,uBAAuB,CAAC,WAAW,GAAG,CAAkB,eAAA,EAAA,aAAa,GAAG;AAExE,IAAA,OAAO,uBAAuB;AAChC;;;;"}
package/dist/index.cjs CHANGED
@@ -105,6 +105,7 @@ var useResizeObserver = require('./hooks/useResizeObserver.cjs');
105
105
  var useIntersectionObserver = require('./hooks/useIntersectionObserver.cjs');
106
106
  var withLabels = require('./hoc/withLabels/withLabels.cjs');
107
107
  var withDeprecated = require('./hoc/withDeprecated.cjs');
108
+ var withClassNames = require('./hoc/withClassNames/withClassNames.cjs');
108
109
  var buildClassnames = require('./utils/buildClassnames.cjs');
109
110
  var color = require('./utils/color.cjs');
110
111
  var generateId = require('./utils/generateId.cjs');
@@ -463,6 +464,7 @@ exports.useResizeObserver = useResizeObserver.useResizeObserver;
463
464
  exports.useIntersectionObserver = useIntersectionObserver.useIntersectionObserver;
464
465
  exports.withLabels = withLabels.withLabels;
465
466
  exports.withDeprecated = withDeprecated.withDeprecated;
467
+ exports.withClassNames = withClassNames.withClassNames;
466
468
  exports.buildClassnames = buildClassnames.buildClassnames;
467
469
  exports.getOpaqueHexColor = color.getOpaqueHexColor;
468
470
  exports.hexToRgb = color.hexToRgb;
@@ -1 +1 @@
1
- {"version":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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/dist/index.js CHANGED
@@ -103,6 +103,7 @@ export { useResizeObserver } from './hooks/useResizeObserver.js';
103
103
  export { useIntersectionObserver } from './hooks/useIntersectionObserver.js';
104
104
  export { withLabels } from './hoc/withLabels/withLabels.js';
105
105
  export { withDeprecated } from './hoc/withDeprecated.js';
106
+ export { withClassNames } from './hoc/withClassNames/withClassNames.js';
106
107
  export { buildClassnames } from './utils/buildClassnames.js';
107
108
  export { getOpaqueHexColor, hexToRgb } from './utils/color.js';
108
109
  export { generateId } from './utils/generateId.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veeqo/ui",
3
- "version": "13.13.3",
3
+ "version": "13.14.0",
4
4
  "description": "New optimised component library for Veeqo.",
5
5
  "author": "Robert Wealthall",
6
6
  "license": "ISC",