@ed.yakovich/example-component-library-button 1.0.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.
@@ -0,0 +1,7 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { createContext as r, useContext as x } from "react";
3
+ const o = r({}), s = () => x(o), C = ({ model: t, children: e }) => /* @__PURE__ */ n(o.Provider, { value: { ...t }, children: e });
4
+ export {
5
+ C as ButtonContextProvider,
6
+ s as useButtonContext
7
+ };
@@ -0,0 +1,37 @@
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { useButtonContext as H } from "./context/index.js";
3
+ const z = (r) => {
4
+ const { isHidden: d, componentId: s = "", actionType: c = "anchor", attributes: i = {}, children: l, display: u = "solid", size: a = "md" } = r, o = H(), p = o == null ? void 0 : o.isHidden, x = () => ({
5
+ isHiddenVal: p || d
6
+ }), { isHiddenVal: y } = x(), h = (t) => {
7
+ const g = t.actionType, k = (e) => g === "button" ? /* @__PURE__ */ n("button", { ...e, children: e.children }) : /* @__PURE__ */ n("a", { ...e, children: e.children });
8
+ return delete t.actionType, /* @__PURE__ */ n(k, { ...t, children: t.children });
9
+ }, b = () => {
10
+ switch (u) {
11
+ case "link":
12
+ return "hover:underline text-sky-500";
13
+ case "outline":
14
+ return "text-sky-500 font-bold uppercase rounded-full border-solid border-4 border-sky-500 py-1 px-4";
15
+ default:
16
+ return "text-white font-bold uppercase rounded-full bg-sky-500 py-1 px-4";
17
+ }
18
+ }, m = () => {
19
+ switch (a) {
20
+ case "lg":
21
+ return "text-3xl";
22
+ case "sm":
23
+ return "text-xs";
24
+ default:
25
+ return "text-base";
26
+ }
27
+ }, f = {
28
+ ...i,
29
+ actionType: c,
30
+ "data-component-id": s || "",
31
+ className: `${b()} ${m()}`
32
+ };
33
+ return y ? null : /* @__PURE__ */ n(h, { ...f, children: l });
34
+ };
35
+ export {
36
+ z as Button
37
+ };
@@ -0,0 +1 @@
1
+
@@ -0,0 +1,10 @@
1
+ import { ReactNode } from 'react';
2
+ import { ButtonType } from '../types';
3
+ type ButtonContextData = ButtonType;
4
+ type ButtonContextProviderProps = {
5
+ model: ButtonContextData;
6
+ children: ReactNode;
7
+ };
8
+ export declare const useButtonContext: () => ButtonType;
9
+ export declare const ButtonContextProvider: ({ model, children }: ButtonContextProviderProps) => import("react/jsx-runtime").JSX.Element;
10
+ export {};
@@ -0,0 +1,2 @@
1
+ import { ButtonType } from './types';
2
+ export declare const Button: (props: ButtonType) => import("react/jsx-runtime").JSX.Element | null;
@@ -0,0 +1,12 @@
1
+ import { ReactNode } from 'react';
2
+ export type ButtonType = {
3
+ isHidden?: boolean;
4
+ componentId?: string;
5
+ actionType?: 'anchor' | 'button';
6
+ attributes?: {
7
+ [key: string]: string;
8
+ };
9
+ display?: 'solid' | 'outline' | 'link';
10
+ size?: 'sm' | 'md' | 'lg';
11
+ children?: ReactNode;
12
+ };
@@ -0,0 +1,3 @@
1
+ export { Button } from './component';
2
+ export { ButtonContextProvider } from './component/context';
3
+ export type { ButtonType } from './component/types';
package/dist/main.js ADDED
@@ -0,0 +1,6 @@
1
+ import { Button as r } from "./component/index.js";
2
+ import { ButtonContextProvider as n } from "./component/context/index.js";
3
+ export {
4
+ r as Button,
5
+ n as ButtonContextProvider
6
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "@ed.yakovich/example-component-library-button",
3
+ "author": "Ed Yakovich",
4
+ "private": false,
5
+ "version": "1.0.0",
6
+ "type": "module",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/lib/main.d.ts",
10
+ "default": "./dist/main.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist"
15
+ ],
16
+ "sideEffects": [
17
+ "**/*.css"
18
+ ],
19
+ "scripts": {
20
+ "dev": "vite",
21
+ "build": "tsc -b ./tsconfig.lib.json && vite build",
22
+ "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
23
+ "preview": "vite preview"
24
+ },
25
+ "peerDependencies": {
26
+ "react": "^18.0.0 || ^19.0.0",
27
+ "react-dom": "^18.0.0 || ^19.0.0"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^22.5.4",
31
+ "@types/react": "^18.3.5",
32
+ "@types/react-dom": "^18.3.0",
33
+ "@typescript-eslint/eslint-plugin": "^7.18.0",
34
+ "@typescript-eslint/parser": "^7.18.0",
35
+ "@vitejs/plugin-react": "^4.3.1",
36
+ "ajv": "^8.17.1",
37
+ "eslint": "^8.57.0",
38
+ "eslint-plugin-react-hooks": "^4.6.2",
39
+ "eslint-plugin-react-refresh": "^0.4.11",
40
+ "glob": "^11.0.0",
41
+ "react": "^18.3.1",
42
+ "react-dom": "^18.3.1",
43
+ "typescript": "^5.6.2",
44
+ "vite": "^5.4.4",
45
+ "vite-plugin-dts": "^4.2.1",
46
+ "vite-plugin-lib-inject-css": "^2.1.1"
47
+ }
48
+ }