@react-foundry/component-helpers 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.classBuilder = exports.id = void 0;
4
+ // Define a pointless component to coax react-docgen-typescript-loader
5
+ const StandardComponent = (props) => null;
6
+ const id = (v) => v;
7
+ exports.id = id;
8
+ const concatClasses = (...classes) => (
9
+ // @ts-ignore
10
+ classes
11
+ .flat(Infinity)
12
+ .filter(exports.id)
13
+ .join(' ') || undefined);
14
+ const toArray = (v) => (Array.isArray(v)
15
+ ? v
16
+ : v && [v]);
17
+ const classBuilder = (blockDefault, blockOverride, blockModifiers, extra) => {
18
+ const block = blockOverride || blockDefault;
19
+ const bModifiers = toArray(blockModifiers);
20
+ return (element, elementModifiers, extra2) => {
21
+ const eModifiers = toArray(elementModifiers);
22
+ return (element
23
+ ? concatClasses(`${block}__${element}`, eModifiers?.filter(exports.id).map(modifier => `${block}__${element}--${modifier}`), extra2)
24
+ : concatClasses(`${block}`, bModifiers?.filter(exports.id).map(modifier => `${block}--${modifier}`), extra));
25
+ };
26
+ };
27
+ exports.classBuilder = classBuilder;
package/dist/index.cjs ADDED
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./classes"), exports);
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "@react-foundry/component-helpers",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Helper functions for writing components.",
5
5
  "type": "module",
6
- "main": "dist/index.js",
6
+ "main": "dist/index.cjs",
7
7
  "exports": {
8
8
  ".": {
9
9
  "types": "./dist/index.d.ts",
10
10
  "import": "./dist/index.js",
11
+ "require": "./dist/index.cjs",
11
12
  "default": "./dist/index.js"
12
13
  }
13
14
  },
@@ -21,7 +22,9 @@
21
22
  },
22
23
  "scripts": {
23
24
  "test": "echo \"Error: no test specified\" && exit 1",
24
- "build": "tsc",
25
+ "build": "npm run build:cjs && npm run build:esm",
26
+ "build:cjs": "tsc -m commonjs --moduleResolution node && find dist -name '*.js' -exec sh -c 'mv \"$0\" \"${0%.js}.cjs\"' {} \\;",
27
+ "build:esm": "tsc",
25
28
  "clean": "rm -rf dist tsconfig.tsbuildinfo"
26
29
  },
27
30
  "module": "dist/index.js",