@korsolutions/ui 0.0.43 → 0.0.44

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.
@@ -26,7 +26,7 @@ export const useButtonVariantDefault = () => {
26
26
  opacity: 0.5
27
27
  },
28
28
  loading: {
29
- opacity: 0.8
29
+ opacity: 0.5
30
30
  },
31
31
  hovered: {
32
32
  backgroundColor: hslaSetRelativeLightness(colors.primary, -10)
@@ -38,23 +38,15 @@ export const useButtonVariantDefault = () => {
38
38
  fontSize,
39
39
  fontFamily
40
40
  },
41
- disabled: {
42
- color: colors.mutedForeground
43
- },
44
- loading: {
45
- color: colors.mutedForeground
46
- }
41
+ disabled: {},
42
+ loading: {}
47
43
  },
48
44
  spinner: {
49
45
  default: {
50
46
  color: colors.primaryForeground
51
47
  },
52
- disabled: {
53
- color: colors.mutedForeground
54
- },
55
- loading: {
56
- color: colors.mutedForeground
57
- }
48
+ disabled: {},
49
+ loading: {}
58
50
  }
59
51
  }));
60
52
  };
@@ -1 +1 @@
1
- {"version":3,"names":["hslaSetRelativeLightness","useThemedStyles","useButtonVariantDefault","colors","radius","fontFamily","fontSize","root","default","flexDirection","paddingVertical","paddingHorizontal","borderRadius","gap","alignItems","justifyContent","backgroundColor","primary","borderWidth","borderColor","border","disabled","opacity","loading","hovered","label","color","primaryForeground","mutedForeground","spinner"],"sourceRoot":"../../../../../src","sources":["components/button/variants/default.tsx"],"mappings":";;AACA,SAASA,wBAAwB;AACjC,SAASC,eAAe;AAExB,OAAO,MAAMC,uBAAuB,GAAGA,CAAA,KAAoB;EACzD,OAAOD,eAAe,CACpB,CAAC;IAAEE,MAAM;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAS,CAAC,MAAoB;IAC3DC,IAAI,EAAE;MACJC,OAAO,EAAE;QACPC,aAAa,EAAE,KAAK;QACpBC,eAAe,EAAE,EAAE;QACnBC,iBAAiB,EAAE,EAAE;QACrBC,YAAY,EAAER,MAAM;QACpBS,GAAG,EAAE,CAAC;QACNC,UAAU,EAAE,QAAQ;QACpBC,cAAc,EAAE,QAAQ;QACxBC,eAAe,EAAEb,MAAM,CAACc,OAAO;QAC/BC,WAAW,EAAE,CAAC;QACdC,WAAW,EAAEhB,MAAM,CAACiB;MACtB,CAAC;MACDC,QAAQ,EAAE;QACRC,OAAO,EAAE;MACX,CAAC;MACDC,OAAO,EAAE;QACPD,OAAO,EAAE;MACX,CAAC;MACDE,OAAO,EAAE;QACPR,eAAe,EAAEhB,wBAAwB,CAACG,MAAM,CAACc,OAAO,EAAE,CAAC,EAAE;MAC/D;IACF,CAAC;IACDQ,KAAK,EAAE;MACLjB,OAAO,EAAE;QACPkB,KAAK,EAAEvB,MAAM,CAACwB,iBAAiB;QAC/BrB,QAAQ;QACRD;MACF,CAAC;MACDgB,QAAQ,EAAE;QACRK,KAAK,EAAEvB,MAAM,CAACyB;MAChB,CAAC;MACDL,OAAO,EAAE;QACPG,KAAK,EAAEvB,MAAM,CAACyB;MAChB;IACF,CAAC;IACDC,OAAO,EAAE;MACPrB,OAAO,EAAE;QACPkB,KAAK,EAAEvB,MAAM,CAACwB;MAChB,CAAC;MACDN,QAAQ,EAAE;QACRK,KAAK,EAAEvB,MAAM,CAACyB;MAChB,CAAC;MACDL,OAAO,EAAE;QACPG,KAAK,EAAEvB,MAAM,CAACyB;MAChB;IACF;EACF,CAAC,CACH,CAAC;AACH,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["hslaSetRelativeLightness","useThemedStyles","useButtonVariantDefault","colors","radius","fontFamily","fontSize","root","default","flexDirection","paddingVertical","paddingHorizontal","borderRadius","gap","alignItems","justifyContent","backgroundColor","primary","borderWidth","borderColor","border","disabled","opacity","loading","hovered","label","color","primaryForeground","spinner"],"sourceRoot":"../../../../../src","sources":["components/button/variants/default.tsx"],"mappings":";;AACA,SAASA,wBAAwB;AACjC,SAASC,eAAe;AAExB,OAAO,MAAMC,uBAAuB,GAAGA,CAAA,KAAoB;EACzD,OAAOD,eAAe,CACpB,CAAC;IAAEE,MAAM;IAAEC,MAAM;IAAEC,UAAU;IAAEC;EAAS,CAAC,MAAoB;IAC3DC,IAAI,EAAE;MACJC,OAAO,EAAE;QACPC,aAAa,EAAE,KAAK;QACpBC,eAAe,EAAE,EAAE;QACnBC,iBAAiB,EAAE,EAAE;QACrBC,YAAY,EAAER,MAAM;QACpBS,GAAG,EAAE,CAAC;QACNC,UAAU,EAAE,QAAQ;QACpBC,cAAc,EAAE,QAAQ;QACxBC,eAAe,EAAEb,MAAM,CAACc,OAAO;QAC/BC,WAAW,EAAE,CAAC;QACdC,WAAW,EAAEhB,MAAM,CAACiB;MACtB,CAAC;MACDC,QAAQ,EAAE;QACRC,OAAO,EAAE;MACX,CAAC;MACDC,OAAO,EAAE;QACPD,OAAO,EAAE;MACX,CAAC;MACDE,OAAO,EAAE;QACPR,eAAe,EAAEhB,wBAAwB,CAACG,MAAM,CAACc,OAAO,EAAE,CAAC,EAAE;MAC/D;IACF,CAAC;IACDQ,KAAK,EAAE;MACLjB,OAAO,EAAE;QACPkB,KAAK,EAAEvB,MAAM,CAACwB,iBAAiB;QAC/BrB,QAAQ;QACRD;MACF,CAAC;MACDgB,QAAQ,EAAE,CAAC,CAAC;MACZE,OAAO,EAAE,CAAC;IACZ,CAAC;IACDK,OAAO,EAAE;MACPpB,OAAO,EAAE;QACPkB,KAAK,EAAEvB,MAAM,CAACwB;MAChB,CAAC;MACDN,QAAQ,EAAE,CAAC,CAAC;MACZE,OAAO,EAAE,CAAC;IACZ;EACF,CAAC,CACH,CAAC;AACH,CAAC","ignoreList":[]}
@@ -26,7 +26,7 @@ export const useButtonVariantSecondary = () => {
26
26
  opacity: 0.5
27
27
  },
28
28
  loading: {
29
- opacity: 0.8
29
+ opacity: 0.5
30
30
  },
31
31
  hovered: {
32
32
  backgroundColor: hslaSetRelativeLightness(colors.secondary, -1)
@@ -8,8 +8,9 @@ import { jsx as _jsx } from "react/jsx-runtime";
8
8
  export function ButtonLabel(props) {
9
9
  const button = useButtonPrimitive();
10
10
  const calculatedStyle = calculateComposedStyles(button.styles, button.state, "label", props.style);
11
- const Component = props.render ?? Text;
12
- return /*#__PURE__*/_jsx(Component, {
11
+ const isSelectable = button.state !== "disabled" && button.state !== "loading";
12
+ return /*#__PURE__*/_jsx(Text, {
13
+ selectable: isSelectable,
13
14
  style: calculatedStyle,
14
15
  children: props.children
15
16
  });
@@ -1 +1 @@
1
- {"version":3,"names":["calculateComposedStyles","React","Text","useButtonPrimitive","jsx","_jsx","ButtonLabel","props","button","calculatedStyle","styles","state","style","Component","render","children"],"sourceRoot":"../../../../src","sources":["primitives/button/button-label.tsx"],"mappings":";;AAAA,SAASA,uBAAuB;AAChC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAyBC,IAAI,QAAwB,cAAc;AACnE,SAASC,kBAAkB;AAA2B,SAAAC,GAAA,IAAAC,IAAA;AAUtD,OAAO,SAASC,WAAWA,CAACC,KAAgC,EAAE;EAC5D,MAAMC,MAAM,GAAGL,kBAAkB,CAAC,CAAC;EAEnC,MAAMM,eAAe,GAAGT,uBAAuB,CAACQ,MAAM,CAACE,MAAM,EAAEF,MAAM,CAACG,KAAK,EAAE,OAAO,EAAEJ,KAAK,CAACK,KAAK,CAAC;EAElG,MAAMC,SAAS,GAAGN,KAAK,CAACO,MAAM,IAAIZ,IAAI;EACtC,oBAAOG,IAAA,CAACQ,SAAS;IAACD,KAAK,EAAEH,eAAgB;IAAAM,QAAA,EAAER,KAAK,CAACQ;EAAQ,CAAY,CAAC;AACxE","ignoreList":[]}
1
+ {"version":3,"names":["calculateComposedStyles","React","Text","useButtonPrimitive","jsx","_jsx","ButtonLabel","props","button","calculatedStyle","styles","state","style","isSelectable","selectable","children"],"sourceRoot":"../../../../src","sources":["primitives/button/button-label.tsx"],"mappings":";;AAAA,SAASA,uBAAuB;AAChC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAAyBC,IAAI,QAAwB,cAAc;AACnE,SAASC,kBAAkB;AAA2B,SAAAC,GAAA,IAAAC,IAAA;AAQtD,OAAO,SAASC,WAAWA,CAACC,KAAgC,EAAE;EAC5D,MAAMC,MAAM,GAAGL,kBAAkB,CAAC,CAAC;EAEnC,MAAMM,eAAe,GAAGT,uBAAuB,CAACQ,MAAM,CAACE,MAAM,EAAEF,MAAM,CAACG,KAAK,EAAE,OAAO,EAAEJ,KAAK,CAACK,KAAK,CAAC;EAElG,MAAMC,YAAY,GAAGL,MAAM,CAACG,KAAK,KAAK,UAAU,IAAIH,MAAM,CAACG,KAAK,KAAK,SAAS;EAE9E,oBACEN,IAAA,CAACH,IAAI;IAACY,UAAU,EAAED,YAAa;IAACD,KAAK,EAAEH,eAAgB;IAAAM,QAAA,EACpDR,KAAK,CAACQ;EAAQ,CACX,CAAC;AAEX","ignoreList":[]}
@@ -16,22 +16,42 @@ const calculateState = (props, isHovered) => {
16
16
  }
17
17
  return "default";
18
18
  };
19
+ const cursorValue = state => {
20
+ switch (state) {
21
+ case "disabled":
22
+ return "not-allowed";
23
+ case "loading":
24
+ return "wait";
25
+ default:
26
+ return "pointer";
27
+ }
28
+ };
19
29
  export function ButtonRoot(props) {
20
30
  const [isHovered, setIsHovered] = useState(false);
21
31
  const state = calculateState(props, isHovered);
22
32
  const calculatedStyle = [props.styles?.root?.default, props.styles?.root?.[state], props.style];
23
- const Container = props.render ?? Pressable;
33
+ const handlePress = event => {
34
+ if (props.isDisabled || props.isLoading) {
35
+ event.preventDefault();
36
+ return;
37
+ }
38
+ props.onPress?.(event);
39
+ };
24
40
  return /*#__PURE__*/_jsx(ButtonPrimitiveContext.Provider, {
25
41
  value: {
26
42
  disabled: props.isDisabled,
27
43
  state,
28
44
  styles: props.styles
29
45
  },
30
- children: /*#__PURE__*/_jsx(Container, {
46
+ children: /*#__PURE__*/_jsx(Pressable, {
31
47
  ...props,
48
+ onPress: handlePress,
32
49
  onHoverIn: () => setIsHovered(true),
33
50
  onHoverOut: () => setIsHovered(false),
34
- style: calculatedStyle
51
+ disabled: props.isDisabled,
52
+ style: [calculatedStyle, {
53
+ cursor: cursorValue(state)
54
+ }]
35
55
  })
36
56
  });
37
57
  }
@@ -1 +1 @@
1
- {"version":3,"names":["React","useState","Pressable","ButtonPrimitiveContext","jsx","_jsx","calculateState","props","isHovered","isDisabled","isLoading","ButtonRoot","setIsHovered","state","calculatedStyle","styles","root","default","style","Container","render","Provider","value","disabled","children","onHoverIn","onHoverOut"],"sourceRoot":"../../../../src","sources":["primitives/button/button-root.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,SAAS,QAA6D,cAAc;AAC7F,SAASC,sBAAsB;AAA2B,SAAAC,GAAA,IAAAC,IAAA;AAe1D,MAAMC,cAAc,GAAGA,CAACC,KAA+B,EAAEC,SAAkB,KAAkB;EAC3F,IAAID,KAAK,CAACE,UAAU,EAAE;IACpB,OAAO,UAAU;EACnB;EACA,IAAIF,KAAK,CAACG,SAAS,EAAE;IACnB,OAAO,SAAS;EAClB;EACA,IAAIF,SAAS,EAAE;IACb,OAAO,SAAS;EAClB;EACA,OAAO,SAAS;AAClB,CAAC;AAED,OAAO,SAASG,UAAUA,CAACJ,KAA+B,EAAE;EAC1D,MAAM,CAACC,SAAS,EAAEI,YAAY,CAAC,GAAGX,QAAQ,CAAC,KAAK,CAAC;EAEjD,MAAMY,KAAK,GAAGP,cAAc,CAACC,KAAK,EAAEC,SAAS,CAAC;EAE9C,MAAMM,eAAe,GAAG,CAACP,KAAK,CAACQ,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEV,KAAK,CAACQ,MAAM,EAAEC,IAAI,GAAGH,KAAK,CAAC,EAAEN,KAAK,CAACW,KAAK,CAAC;EAE/F,MAAMC,SAAS,GAAGZ,KAAK,CAACa,MAAM,IAAIlB,SAAS;EAC3C,oBACEG,IAAA,CAACF,sBAAsB,CAACkB,QAAQ;IAACC,KAAK,EAAE;MAAEC,QAAQ,EAAEhB,KAAK,CAACE,UAAU;MAAEI,KAAK;MAAEE,MAAM,EAAER,KAAK,CAACQ;IAAO,CAAE;IAAAS,QAAA,eAClGnB,IAAA,CAACc,SAAS;MAAA,GAAKZ,KAAK;MAAEkB,SAAS,EAAEA,CAAA,KAAMb,YAAY,CAAC,IAAI,CAAE;MAACc,UAAU,EAAEA,CAAA,KAAMd,YAAY,CAAC,KAAK,CAAE;MAACM,KAAK,EAAEJ;IAAgB,CAAE;EAAC,CAC7F,CAAC;AAEtC","ignoreList":[]}
1
+ {"version":3,"names":["React","useState","Pressable","ButtonPrimitiveContext","jsx","_jsx","calculateState","props","isHovered","isDisabled","isLoading","cursorValue","state","ButtonRoot","setIsHovered","calculatedStyle","styles","root","default","style","handlePress","event","preventDefault","onPress","Provider","value","disabled","children","onHoverIn","onHoverOut","cursor"],"sourceRoot":"../../../../src","sources":["primitives/button/button-root.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,QAAQ,QAAQ,OAAO;AACvC,SAASC,SAAS,QAA+E,cAAc;AAC/G,SAASC,sBAAsB;AAA2B,SAAAC,GAAA,IAAAC,IAAA;AAa1D,MAAMC,cAAc,GAAGA,CAACC,KAA+B,EAAEC,SAAkB,KAAkB;EAC3F,IAAID,KAAK,CAACE,UAAU,EAAE;IACpB,OAAO,UAAU;EACnB;EACA,IAAIF,KAAK,CAACG,SAAS,EAAE;IACnB,OAAO,SAAS;EAClB;EACA,IAAIF,SAAS,EAAE;IACb,OAAO,SAAS;EAClB;EACA,OAAO,SAAS;AAClB,CAAC;AAED,MAAMG,WAAW,GAAIC,KAAkB,IAAkB;EACvD,QAAQA,KAAK;IACX,KAAK,UAAU;MACb,OAAO,aAAa;IACtB,KAAK,SAAS;MACZ,OAAO,MAAM;IACf;MACE,OAAO,SAAS;EACpB;AACF,CAAC;AAED,OAAO,SAASC,UAAUA,CAACN,KAA+B,EAAE;EAC1D,MAAM,CAACC,SAAS,EAAEM,YAAY,CAAC,GAAGb,QAAQ,CAAC,KAAK,CAAC;EAEjD,MAAMW,KAAK,GAAGN,cAAc,CAACC,KAAK,EAAEC,SAAS,CAAC;EAE9C,MAAMO,eAAe,GAAG,CAACR,KAAK,CAACS,MAAM,EAAEC,IAAI,EAAEC,OAAO,EAAEX,KAAK,CAACS,MAAM,EAAEC,IAAI,GAAGL,KAAK,CAAC,EAAEL,KAAK,CAACY,KAAK,CAAC;EAE/F,MAAMC,WAAsC,GAAIC,KAAK,IAAK;IACxD,IAAId,KAAK,CAACE,UAAU,IAAIF,KAAK,CAACG,SAAS,EAAE;MACvCW,KAAK,CAACC,cAAc,CAAC,CAAC;MACtB;IACF;IACAf,KAAK,CAACgB,OAAO,GAAGF,KAAK,CAAC;EACxB,CAAC;EAED,oBACEhB,IAAA,CAACF,sBAAsB,CAACqB,QAAQ;IAACC,KAAK,EAAE;MAAEC,QAAQ,EAAEnB,KAAK,CAACE,UAAU;MAAEG,KAAK;MAAEI,MAAM,EAAET,KAAK,CAACS;IAAO,CAAE;IAAAW,QAAA,eAClGtB,IAAA,CAACH,SAAS;MAAA,GACJK,KAAK;MACTgB,OAAO,EAAEH,WAAY;MACrBQ,SAAS,EAAEA,CAAA,KAAMd,YAAY,CAAC,IAAI,CAAE;MACpCe,UAAU,EAAEA,CAAA,KAAMf,YAAY,CAAC,KAAK,CAAE;MACtCY,QAAQ,EAAEnB,KAAK,CAACE,UAAW;MAC3BU,KAAK,EAAE,CACLJ,eAAe,EACf;QACEe,MAAM,EAAEnB,WAAW,CAACC,KAAK;MAC3B,CAAC;IACD,CACH;EAAC,CAC6B,CAAC;AAEtC","ignoreList":[]}
@@ -7,8 +7,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
7
7
  export function EmptyDescription(props) {
8
8
  const empty = useEmpty();
9
9
  const composedStyles = [empty.styles?.description, props.style];
10
- const Component = props.render ?? Text;
11
- return /*#__PURE__*/_jsx(Component, {
10
+ return /*#__PURE__*/_jsx(Text, {
12
11
  ...props,
13
12
  style: composedStyles
14
13
  });
@@ -1 +1 @@
1
- {"version":3,"names":["React","Text","useEmpty","jsx","_jsx","EmptyDescription","props","empty","composedStyles","styles","description","style","Component","render"],"sourceRoot":"../../../../src","sources":["primitives/empty/empty-description.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAyBC,IAAI,QAAwB,cAAc;AACnE,SAASC,QAAQ;AAAoB,SAAAC,GAAA,IAAAC,IAAA;AAQrC,OAAO,SAASC,gBAAgBA,CAACC,KAA4B,EAAE;EAC7D,MAAMC,KAAK,GAAGL,QAAQ,CAAC,CAAC;EACxB,MAAMM,cAAc,GAAG,CAACD,KAAK,CAACE,MAAM,EAAEC,WAAW,EAAEJ,KAAK,CAACK,KAAK,CAAC;EAC/D,MAAMC,SAAS,GAAGN,KAAK,CAACO,MAAM,IAAIZ,IAAI;EACtC,oBAAOG,IAAA,CAACQ,SAAS;IAAA,GAAKN,KAAK;IAAEK,KAAK,EAAEH;EAAe,CAAE,CAAC;AACxD","ignoreList":[]}
1
+ {"version":3,"names":["React","Text","useEmpty","jsx","_jsx","EmptyDescription","props","empty","composedStyles","styles","description","style"],"sourceRoot":"../../../../src","sources":["primitives/empty/empty-description.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAAyBC,IAAI,QAAwB,cAAc;AACnE,SAASC,QAAQ;AAAoB,SAAAC,GAAA,IAAAC,IAAA;AAQrC,OAAO,SAASC,gBAAgBA,CAACC,KAA4B,EAAE;EAC7D,MAAMC,KAAK,GAAGL,QAAQ,CAAC,CAAC;EACxB,MAAMM,cAAc,GAAG,CAACD,KAAK,CAACE,MAAM,EAAEC,WAAW,EAAEJ,KAAK,CAACK,KAAK,CAAC;EAE/D,oBAAOP,IAAA,CAACH,IAAI;IAAA,GAAKK,KAAK;IAAEK,KAAK,EAAEH;EAAe,CAAE,CAAC;AACnD","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../../src/components/button/variants/default.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,eAAO,MAAM,uBAAuB,QAAO,YAoD1C,CAAC"}
1
+ {"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../../../../../src/components/button/variants/default.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,eAAO,MAAM,uBAAuB,QAAO,YA4C1C,CAAC"}
@@ -2,7 +2,6 @@ import React from "react";
2
2
  import { type StyleProp, type TextStyle } from "react-native";
3
3
  export interface ButtonPrimitiveLabelProps {
4
4
  children?: string;
5
- render?: (props: this) => React.ReactElement;
6
5
  style?: StyleProp<TextStyle>;
7
6
  }
8
7
  export declare function ButtonLabel(props: ButtonPrimitiveLabelProps): React.JSX.Element;
@@ -1 +1 @@
1
- {"version":3,"file":"button-label.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/button/button-label.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,SAAS,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,KAAK,CAAC,YAAY,CAAC;IAE7C,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,yBAAyB,qBAO3D"}
1
+ {"version":3,"file":"button-label.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/button/button-label.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,KAAK,SAAS,EAAQ,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAGpE,MAAM,WAAW,yBAAyB;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;CAC9B;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,yBAAyB,qBAY3D"}
@@ -7,7 +7,6 @@ export interface ButtonPrimitiveRootProps extends PressableProps {
7
7
  isLoading?: boolean;
8
8
  style?: StyleProp<ViewStyle>;
9
9
  styles?: ButtonStyles;
10
- render?: (props: this) => React.ReactElement;
11
10
  }
12
11
  export declare function ButtonRoot(props: ButtonPrimitiveRootProps): React.JSX.Element;
13
12
  //# sourceMappingURL=button-root.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"button-root.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/button/button-root.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAAa,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9F,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,YAAY,CAAC;IAEtB,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,IAAI,KAAK,KAAK,CAAC,YAAY,CAAC;CAC9C;AAeD,wBAAgB,UAAU,CAAC,KAAK,EAAE,wBAAwB,qBAazD"}
1
+ {"version":3,"file":"button-root.d.ts","sourceRoot":"","sources":["../../../../../src/primitives/button/button-root.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAmB,MAAM,OAAO,CAAC;AACxC,OAAO,EAA+B,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAEhH,OAAO,KAAK,EAAe,YAAY,EAAE,MAAM,SAAS,CAAC;AAEzD,MAAM,WAAW,wBAAyB,SAAQ,cAAc;IAC9D,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IAE3B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,KAAK,CAAC,EAAE,SAAS,CAAC,SAAS,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,YAAY,CAAC;CACvB;AA0BD,wBAAgB,UAAU,CAAC,KAAK,EAAE,wBAAwB,qBAgCzD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@korsolutions/ui",
3
- "version": "0.0.43",
3
+ "version": "0.0.44",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -22,7 +22,7 @@ export const useButtonVariantDefault = (): ButtonStyles => {
22
22
  opacity: 0.5,
23
23
  },
24
24
  loading: {
25
- opacity: 0.8,
25
+ opacity: 0.5,
26
26
  },
27
27
  hovered: {
28
28
  backgroundColor: hslaSetRelativeLightness(colors.primary, -10),
@@ -34,23 +34,15 @@ export const useButtonVariantDefault = (): ButtonStyles => {
34
34
  fontSize,
35
35
  fontFamily,
36
36
  },
37
- disabled: {
38
- color: colors.mutedForeground,
39
- },
40
- loading: {
41
- color: colors.mutedForeground,
42
- },
37
+ disabled: {},
38
+ loading: {},
43
39
  },
44
40
  spinner: {
45
41
  default: {
46
42
  color: colors.primaryForeground,
47
43
  },
48
- disabled: {
49
- color: colors.mutedForeground,
50
- },
51
- loading: {
52
- color: colors.mutedForeground,
53
- },
44
+ disabled: {},
45
+ loading: {},
54
46
  },
55
47
  }),
56
48
  );
@@ -22,7 +22,7 @@ export const useButtonVariantSecondary = (): ButtonStyles => {
22
22
  opacity: 0.5,
23
23
  },
24
24
  loading: {
25
- opacity: 0.8,
25
+ opacity: 0.5,
26
26
  },
27
27
  hovered: {
28
28
  backgroundColor: hslaSetRelativeLightness(colors.secondary, -1),
@@ -6,8 +6,6 @@ import { useButtonPrimitive } from "./button-context";
6
6
  export interface ButtonPrimitiveLabelProps {
7
7
  children?: string;
8
8
 
9
- render?: (props: this) => React.ReactElement;
10
-
11
9
  style?: StyleProp<TextStyle>;
12
10
  }
13
11
 
@@ -16,6 +14,11 @@ export function ButtonLabel(props: ButtonPrimitiveLabelProps) {
16
14
 
17
15
  const calculatedStyle = calculateComposedStyles(button.styles, button.state, "label", props.style);
18
16
 
19
- const Component = props.render ?? Text;
20
- return <Component style={calculatedStyle}>{props.children}</Component>;
17
+ const isSelectable = button.state !== "disabled" && button.state !== "loading";
18
+
19
+ return (
20
+ <Text selectable={isSelectable} style={calculatedStyle}>
21
+ {props.children}
22
+ </Text>
23
+ );
21
24
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from "react";
2
- import { Pressable, type PressableProps, type StyleProp, type ViewStyle } from "react-native";
2
+ import { Pressable, type CursorValue, type PressableProps, type StyleProp, type ViewStyle } from "react-native";
3
3
  import { ButtonPrimitiveContext } from "./button-context";
4
4
  import type { ButtonState, ButtonStyles } from "./types";
5
5
 
@@ -11,8 +11,6 @@ export interface ButtonPrimitiveRootProps extends PressableProps {
11
11
 
12
12
  style?: StyleProp<ViewStyle>;
13
13
  styles?: ButtonStyles;
14
-
15
- render?: (props: this) => React.ReactElement;
16
14
  }
17
15
 
18
16
  const calculateState = (props: ButtonPrimitiveRootProps, isHovered: boolean): ButtonState => {
@@ -28,6 +26,17 @@ const calculateState = (props: ButtonPrimitiveRootProps, isHovered: boolean): Bu
28
26
  return "default";
29
27
  };
30
28
 
29
+ const cursorValue = (state: ButtonState): CursorValue => {
30
+ switch (state) {
31
+ case "disabled":
32
+ return "not-allowed" as CursorValue;
33
+ case "loading":
34
+ return "wait" as CursorValue;
35
+ default:
36
+ return "pointer";
37
+ }
38
+ };
39
+
31
40
  export function ButtonRoot(props: ButtonPrimitiveRootProps) {
32
41
  const [isHovered, setIsHovered] = useState(false);
33
42
 
@@ -35,10 +44,29 @@ export function ButtonRoot(props: ButtonPrimitiveRootProps) {
35
44
 
36
45
  const calculatedStyle = [props.styles?.root?.default, props.styles?.root?.[state], props.style];
37
46
 
38
- const Container = props.render ?? Pressable;
47
+ const handlePress: PressableProps["onPress"] = (event) => {
48
+ if (props.isDisabled || props.isLoading) {
49
+ event.preventDefault();
50
+ return;
51
+ }
52
+ props.onPress?.(event);
53
+ };
54
+
39
55
  return (
40
56
  <ButtonPrimitiveContext.Provider value={{ disabled: props.isDisabled, state, styles: props.styles }}>
41
- <Container {...props} onHoverIn={() => setIsHovered(true)} onHoverOut={() => setIsHovered(false)} style={calculatedStyle} />
57
+ <Pressable
58
+ {...props}
59
+ onPress={handlePress}
60
+ onHoverIn={() => setIsHovered(true)}
61
+ onHoverOut={() => setIsHovered(false)}
62
+ disabled={props.isDisabled}
63
+ style={[
64
+ calculatedStyle,
65
+ {
66
+ cursor: cursorValue(state),
67
+ },
68
+ ]}
69
+ />
42
70
  </ButtonPrimitiveContext.Provider>
43
71
  );
44
72
  }
@@ -11,6 +11,6 @@ export interface EmptyDescriptionProps {
11
11
  export function EmptyDescription(props: EmptyDescriptionProps) {
12
12
  const empty = useEmpty();
13
13
  const composedStyles = [empty.styles?.description, props.style];
14
- const Component = props.render ?? Text;
15
- return <Component {...props} style={composedStyles} />;
14
+
15
+ return <Text {...props} style={composedStyles} />;
16
16
  }