@shiflo/ui 0.0.0 → 0.0.1

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,3 +1,3 @@
1
- import { BoxProps } from './Box.typing';
2
- declare function Box(props: BoxProps): import("react").JSX.Element;
1
+ import { BoxComponent } from './Box.typing';
2
+ declare const Box: BoxComponent;
3
3
  export default Box;
@@ -1,8 +1,8 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
2
  import d from "basic-styled";
3
3
  import a from "../../utils/getUtilityProps.mjs";
4
- import t from "../../utils/getValueByPath.mjs";
5
- const f = d.div`
4
+ import s from "../../utils/getValueByPath.mjs";
5
+ const m = d.div`
6
6
  transition:
7
7
  background-color 0.2s,
8
8
  border-width 0.2s,
@@ -10,20 +10,17 @@ const f = d.div`
10
10
  border-color 0.2s,
11
11
  color 0.2s;
12
12
 
13
- ${({ theme: { palette: o }, backgroundColor: s, borderColor: i, color: e, ...n }) => {
13
+ ${({ theme: { palette: o }, backgroundColor: t, borderColor: i, color: e, ...n }) => {
14
14
  const r = {};
15
- return Object.assign(r, a(n)), s && Object.assign(r, {
16
- backgroundColor: t(o, s)
15
+ return Object.assign(r, a(n)), t && Object.assign(r, {
16
+ backgroundColor: s(o, t)
17
17
  }), i && Object.assign(r, {
18
- borderColor: t(o, i)
18
+ borderColor: s(o, i)
19
19
  }), e && Object.assign(r, {
20
- color: t(o, e)
20
+ color: s(o, e)
21
21
  }), r;
22
22
  }}
23
- `;
24
- function u(o) {
25
- return /* @__PURE__ */ c(f, { ...o });
26
- }
23
+ `, u = (o) => /* @__PURE__ */ c(m, { ...o });
27
24
  export {
28
25
  u as default
29
26
  };
@@ -1,8 +1,11 @@
1
- import { ComponentPropsWithRef } from 'react';
1
+ import { ElementType, ReactNode } from 'react';
2
+ import { PolymorphicComponentProps } from '../../typings/component';
2
3
  import { RecursionPath, UtilityProps } from '../../typings/utility';
3
4
  import { BasicTheme } from 'basic-styled';
4
- export interface BoxProps extends ComponentPropsWithRef<"div">, UtilityProps {
5
+ export interface BaseBoxProps extends UtilityProps {
5
6
  backgroundColor?: RecursionPath<BasicTheme["palette"]>;
6
7
  color?: RecursionPath<BasicTheme["palette"]> | "inherit";
7
8
  borderColor?: RecursionPath<BasicTheme["palette"]>;
8
9
  }
10
+ export type BoxProps<T extends ElementType> = BaseBoxProps & PolymorphicComponentProps<T>;
11
+ export type BoxComponent<DT extends ElementType = "div"> = <T extends ElementType = DT>(props: BoxProps<T>) => ReactNode;
@@ -1,4 +1,4 @@
1
1
  import { default as Box } from './Box';
2
- import { BoxProps } from './Box.typing';
3
- export type { BoxProps };
2
+ import { BaseBoxProps } from './Box.typing';
3
+ export type { BaseBoxProps };
4
4
  export default Box;
@@ -1,3 +1,3 @@
1
- import { TypographyProps } from './Typography.typing';
2
- declare function Typography({ ref, variant, fontWeight, ...props }: TypographyProps): import("react").JSX.Element;
1
+ import { TypographyComponent } from './Typography.typing';
2
+ declare const Typography: TypographyComponent;
3
3
  export default Typography;
@@ -1,8 +1,8 @@
1
- import { jsx as c } from "react/jsx-runtime";
2
- import p from "basic-styled";
1
+ import { jsx as p } from "react/jsx-runtime";
2
+ import b from "basic-styled";
3
3
  import f from "../../utils/getUtilityProps.mjs";
4
- import n from "../../utils/getValueByPath.mjs";
5
- const y = p.div`
4
+ import i from "../../utils/getValueByPath.mjs";
5
+ const h = b.div`
6
6
  transition:
7
7
  font-size 0.2s,
8
8
  line-height 0.2s,
@@ -11,17 +11,17 @@ const y = p.div`
11
11
  border-color 0.2s,
12
12
  color 0.2s;
13
13
 
14
- ${({ theme: { typography: o, palette: t }, variant: i, color: r, fontWeight: l, borderColor: s, ...d }) => {
15
- const { fontSize: a, lineHeight: b } = o[i || "body2"], e = {
14
+ ${({ theme: { typography: o, palette: e }, variant: s, color: n, fontWeight: l, borderColor: r, ...d }) => {
15
+ const { fontSize: a, lineHeight: c } = o[s || "body2"], t = {
16
16
  fontSize: a,
17
- lineHeight: b,
17
+ lineHeight: c,
18
18
  fontWeight: l
19
19
  };
20
- return Object.assign(e, f(d)), s && Object.assign(e, {
21
- borderColor: n(t, s)
22
- }), Object.assign(e, {
23
- color: n(t, r)
24
- }), e;
20
+ return Object.assign(t, f(d)), r && Object.assign(t, {
21
+ borderColor: i(e, r)
22
+ }), Object.assign(t, {
23
+ color: i(e, n)
24
+ }), t;
25
25
  }};
26
26
 
27
27
  ${({ noWrap: o }) => o ? {
@@ -36,10 +36,7 @@ const y = p.div`
36
36
  "-webkit-line-clamp": o,
37
37
  "-webkit-box-orient": "vertical"
38
38
  } : {}};
39
- `;
40
- function u({ ref: o, variant: t = "body2", fontWeight: i = 400, ...r }) {
41
- return /* @__PURE__ */ c(y, { ref: o, variant: t, fontWeight: i, ...r });
42
- }
39
+ `, u = (o) => /* @__PURE__ */ p(h, { ...o });
43
40
  export {
44
41
  u as default
45
42
  };
@@ -1,7 +1,8 @@
1
- import { ComponentPropsWithRef } from 'react';
1
+ import { ComponentPropsWithRef, ReactNode, ElementType } from 'react';
2
+ import { PolymorphicComponentProps } from '../../typings/component';
2
3
  import { UtilityProps, RecursionPath } from '../../typings/utility';
3
4
  import { BasicTheme } from 'basic-styled';
4
- export interface TypographyProps extends ComponentPropsWithRef<"div">, UtilityProps {
5
+ export interface BaseTypographyProps extends ComponentPropsWithRef<"div">, UtilityProps {
5
6
  variant?: keyof BasicTheme["typography"];
6
7
  fontWeight?: 400 | 500 | 700;
7
8
  color?: RecursionPath<BasicTheme["palette"]> | "inherit";
@@ -10,3 +11,5 @@ export interface TypographyProps extends ComponentPropsWithRef<"div">, UtilityPr
10
11
  noWrap?: boolean;
11
12
  lineClamp?: number;
12
13
  }
14
+ export type TypographyProps<T extends ElementType> = BaseTypographyProps & PolymorphicComponentProps<T>;
15
+ export type TypographyComponent<DT extends ElementType = "div"> = <T extends ElementType = DT>(props: TypographyProps<T>) => ReactNode;
@@ -1,4 +1,4 @@
1
1
  import { default as Typography } from './Typography';
2
- import { TypographyProps } from './Typography.typing';
3
- export type { TypographyProps };
2
+ import { BaseTypographyProps } from './Typography.typing';
3
+ export type { BaseTypographyProps };
4
4
  export default Typography;
@@ -0,0 +1,7 @@
1
+ import { ComponentPropsWithRef, ComponentPropsWithoutRef, ElementType } from 'react';
2
+ export type PolymorphicComponentProps<T extends ElementType> = {
3
+ as?: T | ElementType;
4
+ } & ComponentPropsWithoutRef<T> & {
5
+ ref?: PolymorphicRef<T>;
6
+ };
7
+ export type PolymorphicRef<T extends ElementType> = ComponentPropsWithRef<T>["ref"];
@@ -0,0 +1 @@
1
+
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shiflo/ui",
3
3
  "description": "Shiflo React UI Components",
4
- "version": "0.0.0",
4
+ "version": "0.0.1",
5
5
  "type": "module",
6
6
  "files": [
7
7
  "dist"