@blockle/blocks-core 0.21.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.
Files changed (65) hide show
  1. package/README.md +2 -0
  2. package/dist/config/componentThemes.d.ts +137 -0
  3. package/dist/config/themeTokens.d.ts +33 -0
  4. package/dist/css/breakpoint/breakpoint.cjs +15 -0
  5. package/dist/css/breakpoint/breakpoint.d.ts +9 -0
  6. package/dist/css/breakpoint/breakpoint.js +15 -0
  7. package/dist/css/breakpoint/breakpoint.test.d.ts +1 -0
  8. package/dist/css/layers.css.cjs +8 -0
  9. package/dist/css/layers.css.d.ts +1 -0
  10. package/dist/css/layers.css.js +8 -0
  11. package/dist/css/rem.cjs +6 -0
  12. package/dist/css/rem.d.ts +1 -0
  13. package/dist/css/rem.js +6 -0
  14. package/dist/css/tokens.cjs +82 -0
  15. package/dist/css/tokens.d.ts +2 -0
  16. package/dist/css/tokens.js +82 -0
  17. package/dist/css/vars.css.cjs +10 -0
  18. package/dist/css/vars.css.d.ts +75 -0
  19. package/dist/css/vars.css.js +10 -0
  20. package/dist/index.cjs +37 -0
  21. package/dist/index.d.ts +21 -0
  22. package/dist/index.js +37 -0
  23. package/dist/sprinkles/atomTypes.d.ts +36 -0
  24. package/dist/sprinkles/atomicProperties.cjs +91 -0
  25. package/dist/sprinkles/atomicProperties.d.ts +286 -0
  26. package/dist/sprinkles/atomicProperties.js +91 -0
  27. package/dist/sprinkles/getAtomsAndProps.cjs +16 -0
  28. package/dist/sprinkles/getAtomsAndProps.d.ts +2 -0
  29. package/dist/sprinkles/getAtomsAndProps.js +16 -0
  30. package/dist/sprinkles/sprinkles.css.cjs +52 -0
  31. package/dist/sprinkles/sprinkles.css.d.ts +234 -0
  32. package/dist/sprinkles/sprinkles.css.js +52 -0
  33. package/dist/theme/makeComponentTheme.cjs +6 -0
  34. package/dist/theme/makeComponentTheme.d.ts +29 -0
  35. package/dist/theme/makeComponentTheme.js +6 -0
  36. package/dist/theme/makeTheme.cjs +13 -0
  37. package/dist/theme/makeTheme.d.ts +14 -0
  38. package/dist/theme/makeTheme.js +13 -0
  39. package/dist/theme/makeVanillaTheme.cjs +20 -0
  40. package/dist/theme/makeVanillaTheme.d.ts +16 -0
  41. package/dist/theme/makeVanillaTheme.js +20 -0
  42. package/dist/theme/theme.d.ts +3 -0
  43. package/dist/utils/classnames/classnames.cjs +7 -0
  44. package/dist/utils/classnames/classnames.d.ts +3 -0
  45. package/dist/utils/classnames/classnames.js +7 -0
  46. package/dist/utils/classnames/classnames.test.d.ts +1 -0
  47. package/dist/utils/dom/hasAnimationDuration.cjs +13 -0
  48. package/dist/utils/dom/hasAnimationDuration.d.ts +4 -0
  49. package/dist/utils/dom/hasAnimationDuration.js +13 -0
  50. package/dist/utils/flexbox/flexbox.cjs +17 -0
  51. package/dist/utils/flexbox/flexbox.d.ts +15 -0
  52. package/dist/utils/flexbox/flexbox.js +17 -0
  53. package/dist/utils/math/math.cjs +13 -0
  54. package/dist/utils/math/math.d.ts +2 -0
  55. package/dist/utils/math/math.js +13 -0
  56. package/dist/utils/react/mergeProps.cjs +43 -0
  57. package/dist/utils/react/mergeProps.d.ts +4 -0
  58. package/dist/utils/react/mergeProps.js +43 -0
  59. package/dist/utils/react/refs.cjs +17 -0
  60. package/dist/utils/react/refs.d.ts +3 -0
  61. package/dist/utils/react/refs.js +17 -0
  62. package/dist/utils/typing/helpers.cjs +6 -0
  63. package/dist/utils/typing/helpers.d.ts +12 -0
  64. package/dist/utils/typing/helpers.js +6 -0
  65. package/package.json +45 -0
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const classnames = require("../classnames/classnames.cjs");
4
+ const refs = require("./refs.cjs");
5
+ function mergeProps(slotProps, childProps) {
6
+ const overrideProps = {};
7
+ for (const propName in childProps) {
8
+ const slotPropValue = slotProps[propName];
9
+ const childPropValue = childProps[propName];
10
+ if (childPropValue === void 0) {
11
+ continue;
12
+ }
13
+ if (slotPropValue === void 0) {
14
+ overrideProps[propName] = childPropValue;
15
+ continue;
16
+ }
17
+ if (typeof slotPropValue === "function" && typeof childPropValue === "function") {
18
+ overrideProps[propName] = (...args) => {
19
+ childPropValue(...args);
20
+ slotPropValue(...args);
21
+ };
22
+ } else
23
+ switch (propName) {
24
+ case "style": {
25
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
26
+ break;
27
+ }
28
+ case "className": {
29
+ overrideProps[propName] = classnames.classnames(slotPropValue, childPropValue);
30
+ break;
31
+ }
32
+ case "ref": {
33
+ overrideProps[propName] = refs.composeRefs(slotPropValue, childPropValue);
34
+ break;
35
+ }
36
+ default: {
37
+ overrideProps[propName] = childPropValue;
38
+ }
39
+ }
40
+ }
41
+ return { ...slotProps, ...overrideProps };
42
+ }
43
+ exports.mergeProps = mergeProps;
@@ -0,0 +1,4 @@
1
+ export type UknownRecord = Record<string, unknown>;
2
+ export declare function mergeProps(slotProps: UknownRecord, childProps: UknownRecord): {
3
+ [x: string]: unknown;
4
+ };
@@ -0,0 +1,43 @@
1
+ import { classnames } from "../classnames/classnames.js";
2
+ import { composeRefs } from "./refs.js";
3
+ function mergeProps(slotProps, childProps) {
4
+ const overrideProps = {};
5
+ for (const propName in childProps) {
6
+ const slotPropValue = slotProps[propName];
7
+ const childPropValue = childProps[propName];
8
+ if (childPropValue === void 0) {
9
+ continue;
10
+ }
11
+ if (slotPropValue === void 0) {
12
+ overrideProps[propName] = childPropValue;
13
+ continue;
14
+ }
15
+ if (typeof slotPropValue === "function" && typeof childPropValue === "function") {
16
+ overrideProps[propName] = (...args) => {
17
+ childPropValue(...args);
18
+ slotPropValue(...args);
19
+ };
20
+ } else
21
+ switch (propName) {
22
+ case "style": {
23
+ overrideProps[propName] = { ...slotPropValue, ...childPropValue };
24
+ break;
25
+ }
26
+ case "className": {
27
+ overrideProps[propName] = classnames(slotPropValue, childPropValue);
28
+ break;
29
+ }
30
+ case "ref": {
31
+ overrideProps[propName] = composeRefs(slotPropValue, childPropValue);
32
+ break;
33
+ }
34
+ default: {
35
+ overrideProps[propName] = childPropValue;
36
+ }
37
+ }
38
+ }
39
+ return { ...slotProps, ...overrideProps };
40
+ }
41
+ export {
42
+ mergeProps
43
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function setRef(ref, value) {
4
+ if (typeof ref === "function") {
5
+ ref(value);
6
+ } else if (ref !== null && ref !== void 0) {
7
+ ref.current = value;
8
+ }
9
+ }
10
+ function composeRefs(...refs) {
11
+ return (node) => {
12
+ for (const ref of refs) {
13
+ setRef(ref, node);
14
+ }
15
+ };
16
+ }
17
+ exports.composeRefs = composeRefs;
@@ -0,0 +1,3 @@
1
+ type PossibleRef<T> = React.Ref<T> | undefined | unknown;
2
+ export declare function composeRefs<T>(...refs: PossibleRef<T>[]): (node: T) => void;
3
+ export {};
@@ -0,0 +1,17 @@
1
+ function setRef(ref, value) {
2
+ if (typeof ref === "function") {
3
+ ref(value);
4
+ } else if (ref !== null && ref !== void 0) {
5
+ ref.current = value;
6
+ }
7
+ }
8
+ function composeRefs(...refs) {
9
+ return (node) => {
10
+ for (const ref of refs) {
11
+ setRef(ref, node);
12
+ }
13
+ };
14
+ }
15
+ export {
16
+ composeRefs
17
+ };
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ function isObjectLike(value) {
4
+ return typeof value === "object" && value !== null;
5
+ }
6
+ exports.isObjectLike = isObjectLike;
@@ -0,0 +1,12 @@
1
+ import { Sprinkles } from '../../sprinkles/sprinkles.css';
2
+ export type AnyString = string & {};
3
+ /**
4
+ * Suggest a type for a string literal but also allow any string.
5
+ */
6
+ export type OptionalLiteral<T extends string> = T | AnyString;
7
+ export type RecordLike = Record<string | number, unknown>;
8
+ export declare function isObjectLike<T extends RecordLike>(value: T): value is T;
9
+ export type IsStringUnion<T> = T extends string ? string extends T ? false : true : false;
10
+ export type IsNumberUnion<T> = T extends number ? number extends T ? false : true : false;
11
+ export type IsUnion<T> = IsStringUnion<T> extends true ? true : IsNumberUnion<T> extends true ? true : false;
12
+ export type HTMLElementProps<E extends Element> = Omit<React.HTMLProps<E>, keyof Sprinkles | 'ref'>;
@@ -0,0 +1,6 @@
1
+ function isObjectLike(value) {
2
+ return typeof value === "object" && value !== null;
3
+ }
4
+ export {
5
+ isObjectLike
6
+ };
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@blockle/blocks-core",
3
+ "version": "0.21.0",
4
+ "description": "Core for Blocks",
5
+ "type": "module",
6
+ "exports": {
7
+ ".": {
8
+ "types": {
9
+ "import": "./dist/index.d.mts",
10
+ "require": "./dist/index.d.ts"
11
+ },
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist"
18
+ ],
19
+ "main": "./dist/index.cjs",
20
+ "module": "./dist/index.js",
21
+ "types": "./dist/index.d.ts",
22
+ "devDependencies": {
23
+ "@vanilla-extract/sprinkles": "^1.6.3"
24
+ },
25
+ "scripts": {
26
+ "build": "vite build",
27
+ "test": "vitest ",
28
+ "lint": "biome format ./src",
29
+ "format": "biome format --write ./src",
30
+ "ts": "tsc --noemit --project ./tsconfig.json"
31
+ },
32
+ "repository": {
33
+ "type": "git",
34
+ "url": "git+ssh://git@github.com/Blockle/blocks.git"
35
+ },
36
+ "author": "Niek Saarberg <n.saarberg@gmail.com>",
37
+ "license": "MIT",
38
+ "bugs": {
39
+ "url": "https://github.com/Blockle/blocks/issues"
40
+ },
41
+ "homepage": "https://github.com/Blockle/blocks#readme",
42
+ "peerDependencies": {
43
+ "react": ">=19.0.0"
44
+ }
45
+ }