elseware-ui 3.0.13 → 3.0.14

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,5 +1,5 @@
1
1
  import { createContext, forwardRef, useContext, useState, useRef, useEffect } from 'react';
2
- import { Pressable, View, ActivityIndicator, Text, Animated, Easing, TextInput, Modal, ScrollView } from 'react-native';
2
+ import { View, ActivityIndicator, Text, Pressable, Animated, Easing, TextInput, Modal, ScrollView } from 'react-native';
3
3
  import { twMerge } from 'tailwind-merge';
4
4
  import { jsx as jsx$1 } from 'react/jsx-runtime';
5
5
  import { jsx, jsxs } from 'nativewind/jsx-runtime';
@@ -215,6 +215,7 @@ function useButton(props) {
215
215
  const {
216
216
  // Consumed by the shared model
217
217
  icon,
218
+ iconPosition = "leading",
218
219
  text,
219
220
  children,
220
221
  loading = false,
@@ -262,6 +263,7 @@ function useButton(props) {
262
263
  loading,
263
264
  iconSize: tokens.icon,
264
265
  icon: resolvedIcon,
266
+ iconPosition,
265
267
  label,
266
268
  hasTextLabel: typeof label === "string" || typeof label === "number",
267
269
  variantClassName,
@@ -288,6 +290,38 @@ var Button = forwardRef(
288
290
  testID
289
291
  } = props;
290
292
  const model = useButton(props);
293
+ const trailing = model.iconPosition === "trailing";
294
+ const iconSlot = model.loading || model.icon ? /* @__PURE__ */ jsx(
295
+ View,
296
+ {
297
+ className: cn(
298
+ "shrink-0 items-center justify-center",
299
+ model.tokens.slot
300
+ ),
301
+ children: model.loading ? /* @__PURE__ */ jsx(
302
+ ActivityIndicator,
303
+ {
304
+ className: model.labelColorClassName,
305
+ size: "small"
306
+ }
307
+ ) : model.icon
308
+ }
309
+ ) : null;
310
+ const labelNode = model.hasTextLabel ? /* @__PURE__ */ jsx(
311
+ Text,
312
+ {
313
+ className: cn(
314
+ "font-bold",
315
+ model.tokens.text,
316
+ model.tokens.leading,
317
+ model.labelColorClassName,
318
+ labelClassName
319
+ ),
320
+ numberOfLines: 1,
321
+ style: nativeLabelBaseStyle,
322
+ children: model.label
323
+ }
324
+ ) : model.label;
291
325
  return /* @__PURE__ */ jsx(
292
326
  Pressable,
293
327
  {
@@ -319,37 +353,8 @@ var Button = forwardRef(
319
353
  contentClassName
320
354
  ),
321
355
  children: [
322
- (model.loading || model.icon) && /* @__PURE__ */ jsx(
323
- View,
324
- {
325
- className: cn(
326
- "shrink-0 items-center justify-center",
327
- model.tokens.slot
328
- ),
329
- children: model.loading ? /* @__PURE__ */ jsx(
330
- ActivityIndicator,
331
- {
332
- className: model.labelColorClassName,
333
- size: "small"
334
- }
335
- ) : model.icon
336
- }
337
- ),
338
- model.hasTextLabel ? /* @__PURE__ */ jsx(
339
- Text,
340
- {
341
- className: cn(
342
- "font-bold",
343
- model.tokens.text,
344
- model.tokens.leading,
345
- model.labelColorClassName,
346
- labelClassName
347
- ),
348
- numberOfLines: 1,
349
- style: nativeLabelBaseStyle,
350
- children: model.label
351
- }
352
- ) : model.label
356
+ trailing ? labelNode : iconSlot,
357
+ trailing ? iconSlot : labelNode
353
358
  ]
354
359
  }
355
360
  )