@designcrowd/fe-shared-lib 1.2.8 → 1.2.9-ali-disabled-2

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.
@@ -21,6 +21,7 @@ export const Sample = () => {
21
21
  {
22
22
  label: 'Medium',
23
23
  value: 'medium',
24
+ disabled: true,
24
25
  },
25
26
  {
26
27
  label: 'Large',
@@ -10,11 +10,14 @@
10
10
  <button
11
11
  class="button-group-item tw-text-xs tw-shadow-inner tw-w-full tw-py-2"
12
12
  :class="{
13
- '!tw-shadow-[0_0_0_2px] !tw-shadow-info-500': option.isSelected,
14
- '!tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200 hover:!tw-shadow-info-500': !option.isSelected,
13
+ '!tw-shadow-[0_0_0_2px] !tw-shadow-info-500': option.isSelected && !option.disabled,
14
+ '!tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200': !option.isSelected && !option.disabled,
15
+ 'hover:!tw-shadow-info-500': !option.isSelected && !option.disabled,
16
+ 'tw-opacity-50 !tw-cursor-not-allowed !tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200': option.disabled,
15
17
  }"
18
+ :disabled="option.disabled"
16
19
  v-bind="option.dataAttribute ? { [option.dataAttribute]: '' } : {}"
17
- @click="$emit('on-select', option)"
20
+ @click="!option.disabled && $emit('on-select', option)"
18
21
  >
19
22
  <slot name="content" :option="option"></slot>
20
23
  </button>
@@ -35,8 +38,10 @@
35
38
  <button
36
39
  v-if="variant === 'icon'"
37
40
  :class="{
38
- '!tw-shadow-[0_0_0_2px] !tw-shadow-info-500': option.isSelected,
39
- '!tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200 hover:!tw-shadow-info-500': !option.isSelected,
41
+ '!tw-shadow-[0_0_0_2px] !tw-shadow-info-500': option.isSelected && !option.disabled,
42
+ '!tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200': !option.isSelected && !option.disabled,
43
+ 'hover:!tw-shadow-info-500': !option.isSelected && !option.disabled,
44
+ 'tw-opacity-50 !tw-cursor-not-allowed !tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200': option.disabled,
40
45
  'tw-px-2': !option.iconViewBox,
41
46
  'tw-px-px':
42
47
  option.iconViewBox && !option.isSelected && !option.iconName.includes('display-style') && btnStyleVariant, // TODO - move style logic to computed prop
@@ -45,9 +50,10 @@
45
50
  'tw-px-0 tw-py-0': option.iconName.includes('display-style') || btnStyleVariant === 'compressed',
46
51
  }"
47
52
  :style="option.iconName.includes('display-style') ? { lineHeight: 0 } : {}"
53
+ :disabled="option.disabled"
48
54
  class="tw-text-xs button-group-icon-button tw-shadow-inner"
49
55
  v-bind="option.dataAttribute ? { [option.dataAttribute]: '' } : {}"
50
- @click="$emit('on-select', option)"
56
+ @click="!option.disabled && $emit('on-select', option)"
51
57
  >
52
58
  <div
53
59
  :class="{
@@ -67,12 +73,15 @@
67
73
  <button
68
74
  v-else
69
75
  :class="{
70
- '!tw-shadow-[0_0_0_2px] !tw-shadow-info-500': option.isSelected,
71
- '!tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200 hover:!tw-shadow-info-500': !option.isSelected,
76
+ '!tw-shadow-[0_0_0_2px] !tw-shadow-info-500': option.isSelected && !option.disabled,
77
+ '!tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200': !option.isSelected && !option.disabled,
78
+ 'hover:!tw-shadow-info-500': !option.isSelected && !option.disabled,
79
+ 'tw-opacity-50 !tw-cursor-not-allowed !tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200': option.disabled,
72
80
  }"
81
+ :disabled="option.disabled"
73
82
  class="tw-text-xs button-group-image-button tw-shadow-inner"
74
83
  v-bind="option.dataAttribute ? { [option.dataAttribute]: '' } : {}"
75
- @click="$emit('on-select', option)"
84
+ @click="!option.disabled && $emit('on-select', option)"
76
85
  >
77
86
  <img :src="option.src" :alt="option.alt" class="tw-w-full tw-h-full" />
78
87
  </button>
@@ -90,11 +99,14 @@
90
99
  :key="`button-${option.value}`"
91
100
  :class="{
92
101
  'tw-ml-2': idx > 0 && !columns,
93
- '!tw-shadow-[0_0_0_2px] !tw-shadow-info-500': option.isSelected,
94
- '!tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200 hover:!tw-shadow-info-500': !option.isSelected,
102
+ '!tw-shadow-[0_0_0_2px] !tw-shadow-info-500': option.isSelected && !option.disabled,
103
+ '!tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200': !option.isSelected && !option.disabled,
104
+ 'hover:!tw-shadow-info-500': !option.isSelected && !option.disabled,
105
+ 'tw-opacity-50 !tw-cursor-not-allowed !tw-shadow-[0_0_0_1px] !tw-shadow-secondary-200': option.disabled,
95
106
  }"
107
+ :disabled="option.disabled"
96
108
  class="tw-text-xs button-group-button tw-shadow-inner"
97
- @click="$emit('on-select', option)"
109
+ @click="!option.disabled && $emit('on-select', option)"
98
110
  >
99
111
  {{ option.label }}
100
112
  </button>
@@ -36,10 +36,11 @@
36
36
  {{ title }}
37
37
  </h2>
38
38
  <p class="tw-mb-8 tw-text-grayscale-600">{{ modalDescription }}</p>
39
- <form id="forgotPassword" ref="forgotPasswordForm" method="post" @submit="validate">
39
+ <form id="forgotPassword" ref="forgotPasswordForm" method="post" novalidate @submit="validate">
40
40
  <input type="hidden" name="__RequestVerificationToken" :value="antiForgeryToken" />
41
41
  <label for="email" class="tw-sr-only"> {{ emailLabel }} </label>
42
42
  <input
43
+ ref="emailInput"
43
44
  v-model="aEmail"
44
45
  name="email"
45
46
  :class="{ 'tw-border-error-500': !!emailError }"
@@ -72,6 +73,7 @@
72
73
  </div>
73
74
  </template>
74
75
  <script>
76
+ import { getCurrentLocale } from '../../../useSharedLibTranslate';
75
77
  import HelloBar from '../../../../src/atoms/components/HelloBar/HelloBar.vue';
76
78
  import SubmissionButton from './SubmissionButton.vue';
77
79
 
@@ -136,11 +138,15 @@ export default {
136
138
  goBackToLoginLabel: this.forgotPasswordContent?.goBackToLoginLabel ?? 'Go back to login',
137
139
  emailAddressPlaceholderLabel: this.forgotPasswordContent?.emailAddressPlaceholderLabel ?? 'Email address',
138
140
  emailLabel: this.forgotPasswordContent?.emailLabel ?? 'Email',
141
+ emailErrorMessage: this.forgotPasswordContent?.emailErrorMessage ?? 'Please enter a valid email address',
139
142
  modalDescription: this.forgotPasswordContent?.description ?? 'Enter your email below. We will then send a reset-password link to your email address.',
140
143
  title: this.forgotPasswordContent?.title ?? 'Forgot your password?',
141
144
  };
142
145
  },
143
146
  computed: {
147
+ currentLocale() {
148
+ return getCurrentLocale();
149
+ },
144
150
  getRedirectToSignInUrl() {
145
151
  const url = new URL(`https://${window.location.host}${this.signInUrl}`);
146
152
  if (this.aEmail) {
@@ -170,21 +176,27 @@ export default {
170
176
  },
171
177
  validate(e) {
172
178
  if (this.submitAction) {
173
- this.$refs.forgotPasswordForm.action = this.submitAction;
174
- }
175
- if (this.aEmail) {
176
- this.isLoading = true;
177
- return true;
179
+ const url = new URL(this.submitAction, window.location.origin);
180
+ url.searchParams.set('locale', this.currentLocale);
181
+ this.$refs.forgotPasswordForm.action = url.toString();
178
182
  }
179
183
 
180
- this.isLoading = false;
181
-
182
184
  this.emailError = undefined;
183
185
 
184
186
  if (!this.aEmail) {
185
- this.emailError = 'Please enter a valid email address';
187
+ this.isLoading = false;
188
+ this.emailError = this.emailErrorMessage;
189
+ e.preventDefault();
190
+ return false;
191
+ }
192
+
193
+ if (this.$refs.emailInput.checkValidity()) {
194
+ this.isLoading = true;
195
+ return true;
186
196
  }
187
197
 
198
+ this.isLoading = false;
199
+ this.emailError = this.emailErrorMessage;
188
200
  e.preventDefault();
189
201
  return false;
190
202
  },
@@ -13,7 +13,7 @@
13
13
  {{ title }}
14
14
  </h2>
15
15
  <p class="tw-mb-8 tw-text-grayscale-600">{{ description }}</p>
16
- <form id="resetPassword" method="post" @submit="validate">
16
+ <form id="resetPassword" ref="resetPasswordForm" method="post" @submit="validate">
17
17
  <input name="__RequestVerificationToken" type="hidden" :value="antiForgeryToken" />
18
18
  <input name="userName" type="hidden" :value="userName" />
19
19
  <input name="resetPasswordToken" type="hidden" :value="resetPasswordToken" />
@@ -25,14 +25,14 @@
25
25
  aria-required="true"
26
26
  :aria-invalid="!!passwordError"
27
27
  autocomplete="new-password"
28
- placeholder="New password"
28
+ :placeholder="newPasswordPlaceholder"
29
29
  class="password-input tw-mb-3 tw-h-12 tw-bg-no-repeat tw-w-full tw-rounded tw-shadow-inner tw-outline-none tw-py-4 tw-pl-10-important tw-pr-2 tw-text-grayscale-600 tw-border tw-border-grayscale-500 focus:tw-border-grayscale-700"
30
30
  :class="{ 'tw-border-error-500': !!passwordError }"
31
31
  />
32
32
  <p v-if="!!passwordError" class="tw-text-error-500 tw-text-sm tw-text-left tw-mb-4">
33
33
  {{ passwordError }}
34
34
  </p>
35
- <label for="confirmPassword" class="tw-sr-only"> Confirm Password </label>
35
+ <label for="confirmPassword" class="tw-sr-only">{{ confirmPasswordLabel }}</label>
36
36
  <input
37
37
  v-model="confirmPassword"
38
38
  name="confirmPassword"
@@ -40,7 +40,7 @@
40
40
  aria-required="true"
41
41
  :aria-invalid="!!confirmPasswordError"
42
42
  autocomplete="off"
43
- placeholder="Confirm new password"
43
+ :placeholder="confirmPasswordPlaceholder"
44
44
  class="password-input tw-mb-3 tw-h-12 tw-bg-no-repeat tw-w-full tw-rounded tw-shadow-inner tw-outline-none tw-py-4 tw-pl-10-important tw-pr-2 tw-text-grayscale-600 tw-border tw-border-grayscale-500 focus:tw-border-grayscale-700"
45
45
  :class="{ 'tw-border-error-500': !!confirmPasswordError }"
46
46
  />
@@ -50,7 +50,7 @@
50
50
  <SubmissionButton
51
51
  variant="primary"
52
52
  size="medium"
53
- label="UPDATE PASSWORD"
53
+ :label="updatePasswordLabel"
54
54
  label-size="larger"
55
55
  :is-loading="isLoading"
56
56
  :disabled="isLoading"
@@ -63,6 +63,7 @@
63
63
  </div>
64
64
  </template>
65
65
  <script>
66
+ import { getCurrentLocale } from '../../../useSharedLibTranslate';
66
67
  import HelloBar from '../../../../src/atoms/components/HelloBar/HelloBar.vue';
67
68
  import SubmissionButton from './SubmissionButton.vue';
68
69
 
@@ -80,7 +81,7 @@ export default {
80
81
  description: {
81
82
  type: String,
82
83
  required: false,
83
- default: 'Enter and confirm your new password',
84
+ default: undefined,
84
85
  },
85
86
  userName: {
86
87
  type: String,
@@ -104,6 +105,16 @@ export default {
104
105
  required: false,
105
106
  default: undefined,
106
107
  },
108
+ submitAction: {
109
+ type: String,
110
+ required: false,
111
+ default: undefined,
112
+ },
113
+ resetPasswordContent: {
114
+ type: Object,
115
+ required: false,
116
+ default: () => {},
117
+ },
107
118
  },
108
119
  data() {
109
120
  return {
@@ -112,10 +123,28 @@ export default {
112
123
  confirmPassword: undefined,
113
124
  passwordError: undefined,
114
125
  confirmPasswordError: undefined,
126
+
127
+ newPasswordLabel: this.resetPasswordContent?.newPasswordLabel ?? 'New Password',
128
+ newPasswordPlaceholder: this.resetPasswordContent?.newPasswordPlaceholder ?? 'New password',
129
+ confirmPasswordLabel: this.resetPasswordContent?.confirmPasswordLabel ?? 'Confirm Password',
130
+ confirmPasswordPlaceholder: this.resetPasswordContent?.confirmPasswordPlaceholder ?? 'Confirm new password',
131
+ updatePasswordLabel: this.resetPasswordContent?.updatePasswordLabel ?? 'UPDATE PASSWORD',
132
+ passwordRequiredError: this.resetPasswordContent?.passwordRequiredError ?? 'Please enter a password',
133
+ passwordsDoNotMatchError: this.resetPasswordContent?.passwordsDoNotMatchError ?? 'Passwords do not match',
115
134
  };
116
135
  },
136
+ computed: {
137
+ currentLocale() {
138
+ return getCurrentLocale();
139
+ },
140
+ },
117
141
  methods: {
118
142
  validate(e) {
143
+ if (this.submitAction) {
144
+ const url = new URL(this.submitAction, window.location.origin);
145
+ url.searchParams.set('locale', this.currentLocale);
146
+ this.$refs.resetPasswordForm.action = url.toString();
147
+ }
119
148
  if (this.password && this.password === this.confirmPassword) {
120
149
  this.isLoading = true;
121
150
  return true;
@@ -127,9 +156,9 @@ export default {
127
156
  this.confirmPasswordError = undefined;
128
157
 
129
158
  if (!this.password) {
130
- this.passwordError = 'Please enter a password';
159
+ this.passwordError = this.passwordRequiredError;
131
160
  } else if (!this.confirmPassword || this.password !== this.confirmPassword) {
132
- this.confirmPasswordError = 'Passwords do not match';
161
+ this.confirmPasswordError = this.passwordsDoNotMatchError;
133
162
  }
134
163
 
135
164
  e.preventDefault();
@@ -55,8 +55,13 @@ const sellDomainNameListModalTr = (key, valuesToInterpolate = {}) =>
55
55
 
56
56
  const sellDomainNameListTr = (key, valuesToInterpolate = {}) => tr(`sellDomainNameList.${key}`, valuesToInterpolate);
57
57
 
58
+ const getCurrentLocale = () => {
59
+ return i18next.language || 'en-US';
60
+ };
61
+
58
62
  export {
59
63
  setSharedLibLocaleAsync,
64
+ getCurrentLocale,
60
65
  tr,
61
66
  publishBrandPageModalTr,
62
67
  sellDomainNameWidgetTr,
@@ -66,3 +71,4 @@ export {
66
71
  sellDomainNameListModalTr,
67
72
  sellDomainNameListTr,
68
73
  };
74
+