Skip to content

Commit b8cf42d

Browse files
committed
fix: phone as date on table
1 parent dd344a9 commit b8cf42d

File tree

11 files changed

+66
-23
lines changed

11 files changed

+66
-23
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
# Xamu UI
22

33
Shared assets, styles, types, componets & scripts from xamu.
4+
5+
WIP

packages/components-vue/src/components/base/ErrorBoundary.vue

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<slot v-if="errors !== undefined" name="fallback" v-bind="{ errors }">
3-
<BoxMessage :theme="[eColors.DANGER, themeValues[0]]">
3+
<BoxMessage :theme="dangerThemeValues">
44
<div class="flx --flxRow --flx-center">
55
<span>{{ errorMessage || t("render_error") }}</span>
66
</div>
@@ -12,7 +12,6 @@
1212
import { ref, onErrorCaptured } from "vue";
1313
1414
import { useI18n } from "@open-xamu-co/ui-common-helpers";
15-
import { eColors } from "@open-xamu-co/ui-common-enums";
1615
1716
import BoxMessage from "../box/Message.vue";
1817
@@ -37,7 +36,7 @@
3736
const props = defineProps<iLoaderContentProps>();
3837
3938
const { t } = useHelpers(useI18n);
40-
const { themeValues } = useTheme(props);
39+
const { dangerThemeValues } = useTheme(props);
4140
4241
const errors = ref();
4342

packages/components-vue/src/components/form/Stages.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@
124124
</template>
125125

126126
<script setup lang="ts">
127-
import { ref, watch } from "vue";
127+
import { onBeforeUnmount, ref, watch } from "vue";
128128
import _ from "lodash";
129129
130130
import type { iInvalidInput, tProps } from "@open-xamu-co/ui-common-types";
@@ -293,4 +293,6 @@
293293
(newStages) => resetStages(newStages),
294294
{ immediate: true }
295295
);
296+
297+
onBeforeUnmount(fullReset);
296298
</script>

packages/components-vue/src/components/input/File.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,14 @@
199199
const { t } = useHelpers(useI18n);
200200
const { isBrowser } = useHelpers(useUtils);
201201
const Swal = useHelpers(useSwal);
202-
const validTheme = useTheme(props);
203-
const invalidTheme = useTheme({ theme: eColors.DANGER });
202+
const { themeClasses, dangerThemeClasses, themeValues, dangerThemeValues } = useTheme(props);
204203
205204
const fileInputTheme = computed(() => {
206205
const invalid = props.invalid;
207206
208207
return {
209-
themeClasses: invalid ? invalidTheme.themeClasses.value : validTheme.themeClasses.value,
210-
themeValues: invalid ? invalidTheme.themeValues.value : validTheme.themeValues.value,
208+
themeClasses: invalid ? dangerThemeClasses.value : themeClasses.value,
209+
themeValues: invalid ? dangerThemeValues.value : themeValues.value,
211210
};
212211
});
213212

packages/components-vue/src/components/input/Text.vue

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<ActionButtonToggle
2424
:disabled="disabled || Number(model) <= minValue"
2525
:size="size"
26-
:theme="invalid ? eColors.DANGER : theme"
26+
:theme="textInputTheme"
2727
:aria-label="t('decrease')"
2828
:tooltip="t('decrease')"
2929
tooltip-position="left"
@@ -37,7 +37,7 @@
3737
<ActionButtonToggle
3838
:disabled="disabled || Number(model) >= maxValue"
3939
:size="size"
40-
:theme="invalid ? eColors.DANGER : theme"
40+
:theme="textInputTheme"
4141
:tooltip="t('increase')"
4242
tooltip-position="left"
4343
round
@@ -73,7 +73,6 @@
7373
import useState from "../../composables/state";
7474
import useTheme from "../../composables/theme";
7575
import { useHelpers } from "../../composables/utils";
76-
import { eColors } from "@open-xamu-co/ui-common-enums";
7776
7877
interface iInputTextProps
7978
extends iInputProps,
@@ -116,7 +115,7 @@
116115
const { t } = useHelpers(useI18n);
117116
const { modifiersClasses } = useModifiers(props);
118117
const { stateClasses } = useState(props);
119-
const { themeClasses } = useTheme(props);
118+
const { themeClasses, themeValues, dangerThemeValues } = useTheme(props);
120119
121120
const inputType = computed(() => props.type ?? "text");
122121
const minValue = computed(() => Number(props.min) || 0);
@@ -140,6 +139,9 @@
140139
const inputClasses = computed(() => {
141140
return [modifiersClasses.value, stateClasses.value, themeClasses.value, "iTxt"];
142141
});
142+
const textInputTheme = computed(() => {
143+
return props.invalid ? dangerThemeValues.value : themeValues.value;
144+
});
143145
144146
/**
145147
* increase number

packages/components-vue/src/components/modal/Simple.vue

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@
194194
emit("close");
195195
}
196196
function clickOutside(e: Event) {
197-
if (modalRef.value !== e.target) return;
197+
if (props.disabled || modalRef.value !== e.target) return;
198198
199199
closeModal();
200200
}
@@ -251,7 +251,15 @@
251251
if (!router?.currentRoute) return;
252252
253253
// close on route change
254-
watch(router.currentRoute, () => closeModal(), { immediate: false });
254+
watch(
255+
router.currentRoute,
256+
() => {
257+
if (props.disabled) return;
258+
259+
closeModal();
260+
},
261+
{ immediate: false }
262+
);
255263
});
256264
onBeforeUnmount(closeModal);
257265
</script>

packages/components-vue/src/components/table/Simple.stories.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ const nodes = [
1111
1212
cellphoneNumber: "1234567890",
1313
cellphoneIndicative: "CO+57",
14+
locationCountry: "CO",
15+
locationState: "VAC",
1416
locationCity: "Cali",
15-
locationDepartment: "VAC",
1617
address: "No address",
1718
zipCode: "124876",
1819
pathPhoto: "https://picsum.photos/seed/45465/100/100",

packages/components-vue/src/components/table/Simple.vue

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
:tooltip="t('table_delete')"
2323
tooltip-as-text
2424
tooltip-position="bottom"
25-
:theme="[eColors.DANGER, themeValues[0]]"
25+
:theme="dangerThemeValues"
2626
:disabled="!selectedNodes.some(([n]) => n)"
2727
@click="deleteNodesAndRefresh"
2828
>
@@ -210,11 +210,12 @@
210210
<Dropdown
211211
class="flx --flxRow --flx-center"
212212
:position="['left', 'center']"
213-
:theme="theme || themeValues"
214213
:size="size"
214+
v-bind="{ theme: theme || themeValues, ...modalProps }"
215215
>
216216
<template #toggle="{ setModel }">
217217
<ActionLink
218+
class="--pX-10"
218219
:aria-label="t('table_options')"
219220
:title="t('table_options')"
220221
:theme="theme || themeValues"
@@ -227,7 +228,9 @@
227228
</ActionLink>
228229
</template>
229230
<template #default="{ setModel, invertedTheme }">
230-
<ul class="flx --flxColumn --flx-start-stretch --gap-5">
231+
<ul
232+
class="flx --flxColumn --flx-start-stretch --gap-10"
233+
>
231234
<li v-if="!!cloneNode">
232235
<ActionLink
233236
:theme="invertedTheme"
@@ -243,7 +246,7 @@
243246
</li>
244247
<li v-if="!!deleteNode">
245248
<ActionLink
246-
:theme="[eColors.DANGER, invertedTheme[0]]"
249+
:theme="dangerThemeValues"
247250
:size="size"
248251
:aria-label="t('table_delete')"
249252
@click="
@@ -351,7 +354,7 @@
351354
tProps,
352355
tSizeModifier,
353356
} from "@open-xamu-co/ui-common-types";
354-
import { eColors, eSizes } from "@open-xamu-co/ui-common-enums";
357+
import { eSizes } from "@open-xamu-co/ui-common-enums";
355358
import { toOption, useSwal, useI18n } from "@open-xamu-co/ui-common-helpers";
356359
357360
import IconFa from "../icon/Fa.vue";
@@ -451,7 +454,7 @@
451454
452455
const { t, tet } = useHelpers(useI18n);
453456
const Swal = useHelpers(useSwal);
454-
const { themeClasses, themeValues } = useTheme(props);
457+
const { themeClasses, themeValues, dangerThemeValues } = useTheme(props);
455458
const router = getCurrentInstance()?.appContext.config.globalProperties.$router;
456459
const { uuid } = useUUID();
457460

packages/components-vue/src/components/value/List.stories.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ const value = {
1010
1111
cellphoneNumber: "1234567890",
1212
cellphoneIndicative: "CO+57",
13+
locationCountry: "CO",
14+
locationState: "VAC",
1315
locationCity: "Cali",
14-
locationDepartment: "VAC",
1516
address: "No address",
1617
zipCode: "124876",
1718
pathPhoto: "https://picsum.photos/seed/45465/100/100",

packages/components-vue/src/components/value/Simple.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,11 @@
189189
// bypass numbers
190190
if (!!Number(dateString)) return false;
191191
192+
const property = String(props.property?.value);
193+
194+
// TODO: improve date bypassing for phones
195+
if (["tel", "phone", "cel"].some((v) => property.includes(v))) return false;
196+
192197
return validator.isDate(dateString) || !isNaN(Date.parse(dateString));
193198
} catch (err) {
194199
// ignore errors

0 commit comments

Comments
 (0)