@nexdom/uimed-vue 2.0.0-beta.34 → 2.0.0-beta.35

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.
@@ -245,6 +245,10 @@ type TextFieldProps = {
245
245
  /**
246
246
  * Applies a distinct behavior to the field.
247
247
  * One of `text`, `phone`, `email`, `url`, `password` or `search`.
248
+ *
249
+ * With `password`, the field hides its value and shows a "Mostrar senha"
250
+ * button that toggles between showing and hiding it. The value hides again
251
+ * when the button is pressed again or the type changes.
248
252
  * @default "text"
249
253
  */
250
254
  type?: TextFieldType;
@@ -433,8 +437,8 @@ declare const __VLS_export$14: import("vue", { with: { "resolution-mode": "impor
433
437
  "onUpdate:modelValue"?: ((value: string) => any) | undefined;
434
438
  }>, {
435
439
  variant: TextFieldVariant;
436
- clearable: boolean;
437
440
  type: TextFieldType;
441
+ clearable: boolean;
438
442
  }, {}, {}, {}, string, import("vue", { with: { "resolution-mode": "import" } }).ComponentProvideOptions, false, {}, any>;
439
443
  //#endregion
440
444
  //#region src/components/inputs/checkbox/types.d.ts
@@ -1,5 +1,5 @@
1
1
  import { a as messages, n as owners$1, r as requests, s as useVuetifyColor } from "./use-dialog-Ck2_ZW7T.js";
2
- import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, isRef, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, onMounted, onScopeDispose, onUnmounted, openBlock, provide, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toValue, unref, useId, useModel, useSlots, useTemplateRef, watch, withCtx, withKeys, withModifiers } from "vue";
2
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, guardReactiveProps, inject, isRef, mergeModels, mergeProps, nextTick, normalizeClass, normalizeProps, onMounted, onScopeDispose, onUnmounted, openBlock, provide, readonly, ref, renderList, renderSlot, resolveDynamicComponent, shallowRef, toDisplayString, toValue, unref, useId, useModel, useSlots, useTemplateRef, watch, withCtx, withKeys, withModifiers } from "vue";
3
3
  import { pt } from "vuetify/locale";
4
4
  import { VApp, VAppBar, VAppBarNavIcon, VAppBarTitle, VAutocomplete, VAvatar, VBadge, VBtn, VCard, VCardActions, VCardText, VCheckboxBtn, VCol, VCombobox, VContainer, VDataIterator, VDatePicker, VDialog, VDivider, VEmptyState, VExpansionPanel, VExpansionPanelText, VExpansionPanelTitle, VExpansionPanels, VForm, VIcon, VIconBtn, VImg, VList, VListGroup, VListItem, VListItemAction, VListSubheader, VLocaleProvider, VMain, VMenu, VNavigationDrawer, VPagination, VProgressCircular, VProgressLinear, VRow, VSkeletonLoader, VSnackbarQueue, VTable, VTextField, VTimePicker } from "vuetify/components";
5
5
  import { formatDateTime, isEmail, isEmpty, isPhone, isUrl } from "@nexdom/shared/utils";
@@ -401,12 +401,39 @@ const textFieldTypeToVuetifyRule = {
401
401
  email,
402
402
  url
403
403
  };
404
- function useTextFieldType(type) {
404
+ /**
405
+ * Maps the field type to the input type, showing as plain text a password
406
+ * the user chose to make visible.
407
+ */
408
+ function useTextFieldType(type, isPasswordVisible) {
405
409
  return computed(() => {
406
410
  const typeValue = toValue(type);
411
+ if (typeValue === "password" && toValue(isPasswordVisible)) return "text";
407
412
  return textFieldTypeToVuetifyType[typeValue];
408
413
  });
409
414
  }
415
+ /**
416
+ * Controls the button that shows or hides a password field's value. The
417
+ * password starts hidden and hides again whenever the type stops being
418
+ * `password`.
419
+ */
420
+ function useTextFieldPasswordToggle(type) {
421
+ const isPasswordField = computed(() => toValue(type) === "password");
422
+ const isPasswordVisible = ref(false);
423
+ const icon = computed(() => isPasswordVisible.value ? "mdi-eye-off" : "mdi-eye");
424
+ watch(isPasswordField, () => {
425
+ isPasswordVisible.value = false;
426
+ });
427
+ function toggle() {
428
+ isPasswordVisible.value = !isPasswordVisible.value;
429
+ }
430
+ return {
431
+ isPasswordField,
432
+ isPasswordVisible: readonly(isPasswordVisible),
433
+ icon,
434
+ toggle
435
+ };
436
+ }
410
437
  function useTextFieldRules(props) {
411
438
  const defaultRules = useRules(props);
412
439
  return computed(() => {
@@ -512,7 +539,8 @@ var text_field_default = /* @__PURE__ */ defineComponent({
512
539
  const modelValue = useModel(__props, "modelValue");
513
540
  const props = __props;
514
541
  const vuetifyVariant = useTextFieldVariant(() => props.variant);
515
- const vuetifyType = useTextFieldType(() => props.type);
542
+ const { isPasswordField, isPasswordVisible, icon: passwordToggleIcon, toggle: togglePassword } = useTextFieldPasswordToggle(() => props.type);
543
+ const vuetifyType = useTextFieldType(() => props.type, isPasswordVisible);
516
544
  const rules = useTextFieldRules(props);
517
545
  const isSearchField = computed(() => props.type === "search");
518
546
  const computedClearable = computed(() => props.clearable ?? isSearchField.value);
@@ -538,10 +566,27 @@ var text_field_default = /* @__PURE__ */ defineComponent({
538
566
  hint: props.hint,
539
567
  clearable: computedClearable.value,
540
568
  "onClick:clear": clear
541
- }, {
569
+ }, createSlots({
542
570
  loader: withCtx((loader) => [createVNode(field_loader_default, normalizeProps(guardReactiveProps(loader)), null, 16)]),
543
- _: 1
544
- }, 8, [
571
+ _: 2
572
+ }, [unref(isPasswordField) ? {
573
+ name: "append-inner",
574
+ fn: withCtx(() => [createVNode(unref(VBtn), {
575
+ icon: unref(passwordToggleIcon),
576
+ "aria-label": "Mostrar senha",
577
+ "aria-pressed": unref(isPasswordVisible),
578
+ disabled: props.disabled,
579
+ size: "small",
580
+ variant: "text",
581
+ onClick: unref(togglePassword)
582
+ }, null, 8, [
583
+ "icon",
584
+ "aria-pressed",
585
+ "disabled",
586
+ "onClick"
587
+ ])]),
588
+ key: "0"
589
+ } : void 0]), 1032, [
545
590
  "modelValue",
546
591
  "variant",
547
592
  "type",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nexdom/uimed-vue",
3
- "version": "2.0.0-beta.34",
3
+ "version": "2.0.0-beta.35",
4
4
  "description": "A ui framework for NEXDOM applications.",
5
5
  "keywords": [
6
6
  "lib",