elseware-ui 3.0.13 → 3.0.15

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,
@@ -242,7 +243,19 @@ function useButton(props) {
242
243
  onMouseMove: _onMouseMove,
243
244
  ...rootRest
244
245
  } = props;
245
- const { shape: resolvedShape, size: resolvedSize, variant: resolvedVariant, appearance: resolvedAppearance } = useResolvedButtonConfig({ compact, mode, variant, appearance, shape, size });
246
+ const {
247
+ shape: resolvedShape,
248
+ size: resolvedSize,
249
+ variant: resolvedVariant,
250
+ appearance: resolvedAppearance
251
+ } = useResolvedButtonConfig({
252
+ compact,
253
+ mode,
254
+ variant,
255
+ appearance,
256
+ shape,
257
+ size
258
+ });
246
259
  const tokens = buttonSizeTokens[resolvedSize];
247
260
  const variantClassName = resolveButtonVariantStyles({
248
261
  appearance: resolvedAppearance,
@@ -262,6 +275,7 @@ function useButton(props) {
262
275
  loading,
263
276
  iconSize: tokens.icon,
264
277
  icon: resolvedIcon,
278
+ iconPosition,
265
279
  label,
266
280
  hasTextLabel: typeof label === "string" || typeof label === "number",
267
281
  variantClassName,
@@ -288,6 +302,38 @@ var Button = forwardRef(
288
302
  testID
289
303
  } = props;
290
304
  const model = useButton(props);
305
+ const trailing = model.iconPosition === "trailing";
306
+ const iconSlot = model.loading || model.icon ? /* @__PURE__ */ jsx(
307
+ View,
308
+ {
309
+ className: cn(
310
+ "shrink-0 items-center justify-center",
311
+ model.tokens.slot
312
+ ),
313
+ children: model.loading ? /* @__PURE__ */ jsx(
314
+ ActivityIndicator,
315
+ {
316
+ className: model.labelColorClassName,
317
+ size: "small"
318
+ }
319
+ ) : model.icon
320
+ }
321
+ ) : null;
322
+ const labelNode = model.hasTextLabel ? /* @__PURE__ */ jsx(
323
+ Text,
324
+ {
325
+ className: cn(
326
+ "font-bold",
327
+ model.tokens.text,
328
+ model.tokens.leading,
329
+ model.labelColorClassName,
330
+ labelClassName
331
+ ),
332
+ numberOfLines: 1,
333
+ style: nativeLabelBaseStyle,
334
+ children: model.label
335
+ }
336
+ ) : model.label;
291
337
  return /* @__PURE__ */ jsx(
292
338
  Pressable,
293
339
  {
@@ -295,7 +341,10 @@ var Button = forwardRef(
295
341
  ref,
296
342
  accessibilityLabel,
297
343
  accessibilityRole,
298
- accessibilityState: { disabled: model.isBusy, selected: model.selected },
344
+ accessibilityState: {
345
+ disabled: model.isBusy,
346
+ selected: model.selected
347
+ },
299
348
  testID,
300
349
  disabled: model.isBusy,
301
350
  onPress: model.onPress,
@@ -319,37 +368,8 @@ var Button = forwardRef(
319
368
  contentClassName
320
369
  ),
321
370
  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
371
+ trailing ? labelNode : iconSlot,
372
+ trailing ? iconSlot : labelNode
353
373
  ]
354
374
  }
355
375
  )