From 55ea48b976746ccc1e6e5ea06497b45b6a15ecd0 Mon Sep 17 00:00:00 2001 From: Rohan Date: Thu, 26 Oct 2023 02:56:37 +0530 Subject: [PATCH] Added utils package --- packages/lucide-figma/package.json | 1 + packages/lucide-figma/src/helpers/createIconComponent.ts | 2 +- packages/lucide-preact/package.json | 1 + packages/lucide-preact/src/createLucideIcon.ts | 2 +- packages/lucide-react/package.json | 1 + packages/lucide-react/src/createLucideIcon.ts | 2 +- packages/lucide-solid/package.json | 1 + packages/lucide-solid/src/Icon.tsx | 2 +- packages/lucide-vue-next/package.json | 1 + packages/lucide-vue-next/src/createLucideIcon.ts | 2 +- packages/lucide-vue/package.json | 1 + packages/lucide-vue/src/createVueComponent.ts | 2 +- packages/utils/package.json | 9 +++++++++ packages/utils/utils.js | 8 ++++++++ 14 files changed, 29 insertions(+), 6 deletions(-) create mode 100644 packages/utils/package.json create mode 100644 packages/utils/utils.js diff --git a/packages/lucide-figma/package.json b/packages/lucide-figma/package.json index 0dab47a4108..1c47c42c600 100644 --- a/packages/lucide-figma/package.json +++ b/packages/lucide-figma/package.json @@ -19,6 +19,7 @@ }, "devDependencies": { "@figma/plugin-typings": "^1.36.0", + "@lucide/utils": "workspace:*", "@types/react": "^17.0.0", "@types/react-dom": "^17.0.0", "@vitejs/plugin-react": "^1.0.0", diff --git a/packages/lucide-figma/src/helpers/createIconComponent.ts b/packages/lucide-figma/src/helpers/createIconComponent.ts index e9e2d1c9b70..2db6d0e8cca 100644 --- a/packages/lucide-figma/src/helpers/createIconComponent.ts +++ b/packages/lucide-figma/src/helpers/createIconComponent.ts @@ -1,6 +1,6 @@ import { forwardRef, createElement, SVGProps } from 'react'; import { IconNode } from '../api/fetchIcons'; -import { toKebabCase} from '../../../../scripts/helpers.mjs'; +import { toKebabCase} from '@lucide/utils'; const defaultAttributes = { xmlns: 'http://www.w3.org/2000/svg', diff --git a/packages/lucide-preact/package.json b/packages/lucide-preact/package.json index 71aa6d76229..77d965fc43d 100644 --- a/packages/lucide-preact/package.json +++ b/packages/lucide-preact/package.json @@ -45,6 +45,7 @@ "devDependencies": { "@lucide/rollup-plugins": "workspace:*", "@lucide/build-icons": "workspace:*", + "@lucide/utils": "workspace:*", "@preact/preset-vite": "^2.4.0", "@testing-library/jest-dom": "^5.16.5", "@testing-library/preact": "^2.0.1", diff --git a/packages/lucide-preact/src/createLucideIcon.ts b/packages/lucide-preact/src/createLucideIcon.ts index 9db065878b2..a15e66788f4 100644 --- a/packages/lucide-preact/src/createLucideIcon.ts +++ b/packages/lucide-preact/src/createLucideIcon.ts @@ -1,6 +1,6 @@ import { ComponentType, FunctionComponent, h, JSX, RefObject, toChildArray } from 'preact'; import defaultAttributes from './defaultAttributes'; -import { toKebabCase} from '../../../scripts/helpers.mjs'; +import { toKebabCase} from '@lucide/utils'; type IconNode = [elementName: keyof JSX.IntrinsicElements, attrs: Record][] diff --git a/packages/lucide-react/package.json b/packages/lucide-react/package.json index 65c9bb17d66..16f9cba1ec1 100644 --- a/packages/lucide-react/package.json +++ b/packages/lucide-react/package.json @@ -50,6 +50,7 @@ "devDependencies": { "@lucide/build-icons": "workspace:*", "@lucide/rollup-plugins": "workspace:*", + "@lucide/utils": "workspace:*", "@testing-library/jest-dom": "^5.16.5", "@testing-library/react": "^11.2.6", "@types/prop-types": "^15.7.5", diff --git a/packages/lucide-react/src/createLucideIcon.ts b/packages/lucide-react/src/createLucideIcon.ts index 27bb11b8ce5..4bd76d978b4 100644 --- a/packages/lucide-react/src/createLucideIcon.ts +++ b/packages/lucide-react/src/createLucideIcon.ts @@ -1,6 +1,6 @@ import { forwardRef, createElement, ReactSVG, SVGProps, ForwardRefExoticComponent, RefAttributes } from 'react'; import defaultAttributes from './defaultAttributes'; -import { toKebabCase} from '../../../scripts/helpers.mjs'; +import { toKebabCase} from '@lucide/utils'; export type IconNode = [elementName: keyof ReactSVG, attrs: Record][] diff --git a/packages/lucide-solid/package.json b/packages/lucide-solid/package.json index a2322c56a76..987eb737684 100644 --- a/packages/lucide-solid/package.json +++ b/packages/lucide-solid/package.json @@ -51,6 +51,7 @@ }, "devDependencies": { "@lucide/build-icons": "workspace:*", + "@lucide/utils": "workspace:*", "@atomico/rollup-plugin-sizes": "^1.1.4", "@testing-library/jest-dom": "^5.16.5", "rollup-plugin-license": "^3.0.1", diff --git a/packages/lucide-solid/src/Icon.tsx b/packages/lucide-solid/src/Icon.tsx index 6f87bd2cbbb..311d32fdd4c 100644 --- a/packages/lucide-solid/src/Icon.tsx +++ b/packages/lucide-solid/src/Icon.tsx @@ -2,7 +2,7 @@ import { For, JSX, splitProps } from 'solid-js'; import { Dynamic } from 'solid-js/web'; import defaultAttributes from './defaultAttributes'; import { IconNode, LucideProps } from './types'; -import { toKebabCase} from '../../../scripts/helpers.mjs'; +import { toKebabCase} from '@lucide/utils'; interface IconProps { name: string diff --git a/packages/lucide-vue-next/package.json b/packages/lucide-vue-next/package.json index ea2e703a294..53dbb657bd5 100644 --- a/packages/lucide-vue-next/package.json +++ b/packages/lucide-vue-next/package.json @@ -47,6 +47,7 @@ "devDependencies": { "@lucide/rollup-plugins": "workspace:*", "@lucide/build-icons": "workspace:*", + "@lucide/utils": "workspace:*", "@testing-library/jest-dom": "^5.16.5", "@testing-library/vue": "^6.6.1", "@vue/compiler-sfc": "3.2.45", diff --git a/packages/lucide-vue-next/src/createLucideIcon.ts b/packages/lucide-vue-next/src/createLucideIcon.ts index e1662f0d017..2d5c56c0f5a 100644 --- a/packages/lucide-vue-next/src/createLucideIcon.ts +++ b/packages/lucide-vue-next/src/createLucideIcon.ts @@ -1,7 +1,7 @@ import { h } from 'vue'; import type { SVGAttributes, FunctionalComponent } from 'vue'; import defaultAttributes from './defaultAttributes'; -import { toKebabCase} from '../../../scripts/helpers.mjs'; +import { toKebabCase} from '@lucide/utils'; // Create interface extending SVGAttributes export interface SVGProps extends Partial { diff --git a/packages/lucide-vue/package.json b/packages/lucide-vue/package.json index 931428c2fd6..e6fcc322100 100644 --- a/packages/lucide-vue/package.json +++ b/packages/lucide-vue/package.json @@ -45,6 +45,7 @@ "devDependencies": { "@lucide/build-icons": "workspace:*", "@lucide/rollup-plugins": "workspace:*", + "@lucide/utils": "workspace:*", "@testing-library/jest-dom": "^5.16.5", "@testing-library/vue": "^5.9.0", "@vitejs/plugin-vue2": "2.2.0", diff --git a/packages/lucide-vue/src/createVueComponent.ts b/packages/lucide-vue/src/createVueComponent.ts index c5238a9f397..20cd1af22a1 100644 --- a/packages/lucide-vue/src/createVueComponent.ts +++ b/packages/lucide-vue/src/createVueComponent.ts @@ -1,7 +1,7 @@ import { Component } from 'vue'; import { Vue, VueConfiguration } from 'vue/types/vue'; import defaultAttributes from './defaultAttributes'; -import { toKebabCase} from '../../../scripts/helpers.mjs'; +import { toKebabCase} from '@lucide/utils'; type IconNode = [elementName: string, attrs: Record][] diff --git a/packages/utils/package.json b/packages/utils/package.json new file mode 100644 index 00000000000..0d9ddfd5795 --- /dev/null +++ b/packages/utils/package.json @@ -0,0 +1,9 @@ +{ + "name": "@lucide/utils", + "version": "1.0.0", + "private": true, + "description": "", + "main": "utils.js", + "author": "", + "license": "ISC" +} diff --git a/packages/utils/utils.js b/packages/utils/utils.js new file mode 100644 index 00000000000..1d379c89687 --- /dev/null +++ b/packages/utils/utils.js @@ -0,0 +1,8 @@ +/** + * Converts string to KebabCase + * + * @param {string} string + * @returns {string} A kebabized string + */ +export const toKebabCase = (string) => string.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase(); +