@impulse-ui-native/select 7.0.1 → 8.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.
@@ -1,6 +1,11 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { memo } from "react";
3
+ import { Icon } from "@impulse-ui-native/icon";
3
4
  import { Control, Pressable } from "@impulse-ui-native/primitives";
5
+ import {
6
+ getFieldStateTokens,
7
+ useComponentsTokens
8
+ } from "@impulse-ui-native/theme";
4
9
  function SelectControlComponent(props) {
5
10
  const {
6
11
  size = "medium",
@@ -18,6 +23,12 @@ function SelectControlComponent(props) {
18
23
  onPress,
19
24
  children
20
25
  } = props;
26
+ const addonTokens = useComponentsTokens().controlAddon;
27
+ const addonColor = getFieldStateTokens(addonTokens.variants[variant], {
28
+ disabled,
29
+ error: Boolean(error)
30
+ }).iconColor;
31
+ const SuffixContent = loading ? Control.Loader : Suffix;
21
32
  return /* @__PURE__ */ jsx(
22
33
  Control.Provider,
23
34
  {
@@ -28,25 +39,17 @@ function SelectControlComponent(props) {
28
39
  children: /* @__PURE__ */ jsxs(Control.Root, { children: [
29
40
  /* @__PURE__ */ jsx(Control.Label, { children: label }),
30
41
  /* @__PURE__ */ jsx(Pressable, { onPress, children: /* @__PURE__ */ jsxs(Control.Container, { children: [
31
- /* @__PURE__ */ jsx(
32
- Control.Addon,
33
- {
34
- icon: PrefixIcon,
35
- Content: Prefix,
36
- onPress: onPressPrefix
37
- }
38
- ),
42
+ Prefix || PrefixIcon ? /* @__PURE__ */ jsxs(Control.Addon, { onPress: onPressPrefix, children: [
43
+ Prefix ? /* @__PURE__ */ jsx(Prefix, {}) : null,
44
+ !Prefix && PrefixIcon ? /* @__PURE__ */ jsx(Icon, { color: addonColor, icon: PrefixIcon }) : null
45
+ ] }) : null,
39
46
  children,
40
- /* @__PURE__ */ jsx(
41
- Control.Addon,
42
- {
43
- icon: SuffixIcon,
44
- Content: loading ? Control.Loader : Suffix,
45
- onPress: onPressSuffix
46
- }
47
- )
47
+ SuffixContent || SuffixIcon ? /* @__PURE__ */ jsxs(Control.Addon, { onPress: onPressSuffix, children: [
48
+ SuffixContent ? /* @__PURE__ */ jsx(SuffixContent, {}) : null,
49
+ !SuffixContent && SuffixIcon ? /* @__PURE__ */ jsx(Icon, { color: addonColor, icon: SuffixIcon }) : null
50
+ ] }) : null
48
51
  ] }) }),
49
- /* @__PURE__ */ jsx(Control.Error, {})
52
+ error ? /* @__PURE__ */ jsx(Control.Error, { children: error }) : null
50
53
  ] })
51
54
  }
52
55
  );
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/components/select-control.tsx"],"sourcesContent":["import { memo, PropsWithChildren, ReactElement } from \"react\";\n\nimport { Control, Pressable } from \"@impulse-ui-native/primitives\";\n\nimport { PrimitiveValue, SelectControlProps } from \"../types\";\n\nfunction SelectControlComponent<Value extends PrimitiveValue>(\n props: PropsWithChildren<SelectControlProps<Value>>,\n) {\n const {\n size = \"medium\",\n variant = \"outlined\",\n label,\n error,\n disabled,\n loading,\n PrefixIcon,\n Prefix,\n onPressPrefix,\n SuffixIcon,\n Suffix,\n onPressSuffix,\n onPress,\n children,\n } = props;\n\n return (\n <Control.Provider\n size={size}\n variant={variant}\n error={error}\n disabled={disabled}\n >\n <Control.Root>\n <Control.Label>{label}</Control.Label>\n <Pressable onPress={onPress}>\n <Control.Container>\n <Control.Addon\n icon={PrefixIcon}\n Content={Prefix}\n onPress={onPressPrefix}\n />\n {children}\n <Control.Addon\n icon={SuffixIcon}\n Content={loading ? Control.Loader : Suffix}\n onPress={onPressSuffix}\n />\n </Control.Container>\n </Pressable>\n <Control.Error />\n </Control.Root>\n </Control.Provider>\n );\n}\n\nexport const SelectControl = memo(SelectControlComponent) as <\n Value extends PrimitiveValue,\n>(\n props: PropsWithChildren<SelectControlProps<Value>>,\n) => ReactElement | null;\n"],"mappings":"AAkCQ,cAEE,YAFF;AAlCR,SAAS,YAA6C;AAEtD,SAAS,SAAS,iBAAiB;AAInC,SAAS,uBACP,OACA;AACA,QAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,SACE;AAAA,IAAC,QAAQ;AAAA,IAAR;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA,+BAAC,QAAQ,MAAR,EACC;AAAA,4BAAC,QAAQ,OAAR,EAAe,iBAAM;AAAA,QACtB,oBAAC,aAAU,SACT,+BAAC,QAAQ,WAAR,EACC;AAAA;AAAA,YAAC,QAAQ;AAAA,YAAR;AAAA,cACC,MAAM;AAAA,cACN,SAAS;AAAA,cACT,SAAS;AAAA;AAAA,UACX;AAAA,UACC;AAAA,UACD;AAAA,YAAC,QAAQ;AAAA,YAAR;AAAA,cACC,MAAM;AAAA,cACN,SAAS,UAAU,QAAQ,SAAS;AAAA,cACpC,SAAS;AAAA;AAAA,UACX;AAAA,WACF,GACF;AAAA,QACA,oBAAC,QAAQ,OAAR,EAAc;AAAA,SACjB;AAAA;AAAA,EACF;AAEJ;AAEO,MAAM,gBAAgB,KAAK,sBAAsB;","names":[]}
1
+ {"version":3,"sources":["../../src/components/select-control.tsx"],"sourcesContent":["import type { PropsWithChildren, ReactElement } from \"react\";\nimport { memo } from \"react\";\n\nimport { Icon } from \"@impulse-ui-native/icon\";\nimport { Control, Pressable } from \"@impulse-ui-native/primitives\";\nimport {\n getFieldStateTokens,\n useComponentsTokens,\n} from \"@impulse-ui-native/theme\";\n\nimport type { PrimitiveValue, SelectControlProps } from \"../types\";\n\nfunction SelectControlComponent<Value extends PrimitiveValue>(\n props: PropsWithChildren<SelectControlProps<Value>>,\n) {\n const {\n size = \"medium\",\n variant = \"outlined\",\n label,\n error,\n disabled,\n loading,\n PrefixIcon,\n Prefix,\n onPressPrefix,\n SuffixIcon,\n Suffix,\n onPressSuffix,\n onPress,\n children,\n } = props;\n\n const addonTokens = useComponentsTokens().controlAddon;\n const addonColor = getFieldStateTokens(addonTokens.variants[variant], {\n disabled,\n error: Boolean(error),\n }).iconColor;\n\n const SuffixContent = loading ? Control.Loader : Suffix;\n\n return (\n <Control.Provider\n size={size}\n variant={variant}\n error={error}\n disabled={disabled}\n >\n <Control.Root>\n <Control.Label>{label}</Control.Label>\n <Pressable onPress={onPress}>\n <Control.Container>\n {Prefix || PrefixIcon ? (\n <Control.Addon onPress={onPressPrefix}>\n {Prefix ? <Prefix /> : null}\n {!Prefix && PrefixIcon ? (\n <Icon color={addonColor} icon={PrefixIcon} />\n ) : null}\n </Control.Addon>\n ) : null}\n {children}\n {SuffixContent || SuffixIcon ? (\n <Control.Addon onPress={onPressSuffix}>\n {SuffixContent ? <SuffixContent /> : null}\n {!SuffixContent && SuffixIcon ? (\n <Icon color={addonColor} icon={SuffixIcon} />\n ) : null}\n </Control.Addon>\n ) : null}\n </Control.Container>\n </Pressable>\n {error ? <Control.Error>{error}</Control.Error> : null}\n </Control.Root>\n </Control.Provider>\n );\n}\n\nexport const SelectControl = memo(SelectControlComponent) as <\n Value extends PrimitiveValue,\n>(\n props: PropsWithChildren<SelectControlProps<Value>>,\n) => ReactElement | null;\n"],"mappings":"AAgDQ,cAIM,YAJN;AA/CR,SAAS,YAAY;AAErB,SAAS,YAAY;AACrB,SAAS,SAAS,iBAAiB;AACnC;AAAA,EACE;AAAA,EACA;AAAA,OACK;AAIP,SAAS,uBACP,OACA;AACA,QAAM;AAAA,IACJ,OAAO;AAAA,IACP,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF,IAAI;AAEJ,QAAM,cAAc,oBAAoB,EAAE;AAC1C,QAAM,aAAa,oBAAoB,YAAY,SAAS,OAAO,GAAG;AAAA,IACpE;AAAA,IACA,OAAO,QAAQ,KAAK;AAAA,EACtB,CAAC,EAAE;AAEH,QAAM,gBAAgB,UAAU,QAAQ,SAAS;AAEjD,SACE;AAAA,IAAC,QAAQ;AAAA,IAAR;AAAA,MACC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MAEA,+BAAC,QAAQ,MAAR,EACC;AAAA,4BAAC,QAAQ,OAAR,EAAe,iBAAM;AAAA,QACtB,oBAAC,aAAU,SACT,+BAAC,QAAQ,WAAR,EACE;AAAA,oBAAU,aACT,qBAAC,QAAQ,OAAR,EAAc,SAAS,eACrB;AAAA,qBAAS,oBAAC,UAAO,IAAK;AAAA,YACtB,CAAC,UAAU,aACV,oBAAC,QAAK,OAAO,YAAY,MAAM,YAAY,IACzC;AAAA,aACN,IACE;AAAA,UACH;AAAA,UACA,iBAAiB,aAChB,qBAAC,QAAQ,OAAR,EAAc,SAAS,eACrB;AAAA,4BAAgB,oBAAC,iBAAc,IAAK;AAAA,YACpC,CAAC,iBAAiB,aACjB,oBAAC,QAAK,OAAO,YAAY,MAAM,YAAY,IACzC;AAAA,aACN,IACE;AAAA,WACN,GACF;AAAA,QACC,QAAQ,oBAAC,QAAQ,OAAR,EAAe,iBAAM,IAAmB;AAAA,SACpD;AAAA;AAAA,EACF;AAEJ;AAEO,MAAM,gBAAgB,KAAK,sBAAsB;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@impulse-ui-native/select",
3
- "version": "7.0.1",
3
+ "version": "8.0.0",
4
4
  "description": "Select and option picker components for ImpulseUI Native applications.",
5
5
  "keywords": [
6
6
  "react-native",
@@ -28,13 +28,13 @@
28
28
  ],
29
29
  "sideEffects": false,
30
30
  "dependencies": {
31
- "@impulse-ui-native/theme": "7.0.1",
32
- "@impulse-ui-native/icon": "7.0.1",
33
- "@impulse-ui-native/core": "7.0.1",
34
- "@impulse-ui-native/primitives": "7.0.1",
35
- "@impulse-ui-native/input": "7.0.1",
36
- "@impulse-ui-native/portal": "7.0.1",
37
- "@impulse-ui-native/flyout": "7.0.1"
31
+ "@impulse-ui-native/theme": "8.0.0",
32
+ "@impulse-ui-native/input": "8.0.0",
33
+ "@impulse-ui-native/icon": "8.0.0",
34
+ "@impulse-ui-native/core": "8.0.0",
35
+ "@impulse-ui-native/flyout": "8.0.0",
36
+ "@impulse-ui-native/primitives": "8.0.0",
37
+ "@impulse-ui-native/portal": "8.0.0"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@shopify/flash-list": "2.0.2",