@stonecrop/aform 0.62.8 → 0.63.1

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.
package/dist/aform.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { flattenFields, hasBadgeOptions, isBadgeDescriptor, lookupBadge, partsPatch, readParts, selectChoices } from "@stonecrop/schema";
2
2
  import { TABLE_TUPLE_CURRENCY_PICKER, TABLE_TUPLE_QUANTITY_PICKER, install as install$1, isTableTuplePickerModal } from "@stonecrop/atable";
3
- import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeModels, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, toHandlers, unref, useId, useModel, useTemplateRef, vModelCheckbox, vModelRadio, vModelSelect, vModelText, vShow, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers } from "vue";
3
+ import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createSlots, createTextVNode, createVNode, defineComponent, inject, mergeModels, mergeProps, nextTick, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, provide, reactive, ref, renderList, renderSlot, resolveComponent, resolveDynamicComponent, toDisplayString, toHandlers, unref, useId, useModel, useTemplateRef, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, watch, watchEffect, withCtx, withDirectives, withKeys, withModifiers } from "vue";
4
4
  import { currencyAmountEntryPattern, currencyAmountSeparators, currencyInputFractionDigits, formatCurrencyAmount, formatCurrencyAmountInput, formatCurrencySymbol, fromISODate, isSemver, isSemverPrefix, parseCurrencyAmountInput, roundToPrecision, useArithmeticInput } from "@stonecrop/utilities";
5
5
  import { vOnClickOutside } from "@vueuse/components";
6
6
  import { Temporal } from "temporal-polyfill";
@@ -919,8 +919,8 @@ var _hoisted_12$4 = {
919
919
  class: "acurrency__field acurrency__field--base-currency",
920
920
  "aria-hidden": "true"
921
921
  };
922
- var _hoisted_13$2 = ["value"];
923
- var _hoisted_14$2 = ["id"];
922
+ var _hoisted_13$3 = ["value"];
923
+ var _hoisted_14$3 = ["id"];
924
924
  var _hoisted_15$1 = ["id"];
925
925
  // src/components/form/ACurrencyInput.vue
926
926
  var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
@@ -1206,12 +1206,12 @@ var ACurrencyInput_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/*
1206
1206
  readonly: "",
1207
1207
  tabindex: "-1",
1208
1208
  value: baseCurrencyText.value
1209
- }, null, 8, _hoisted_13$2)])]),
1209
+ }, null, 8, _hoisted_13$3)])]),
1210
1210
  showBase.value && !errorText.value ? (openBlock(), createElementBlock("p", {
1211
1211
  key: 0,
1212
1212
  id: helperId.value,
1213
1213
  class: "acurrency__helper"
1214
- }, toDisplayString(conversionHelperText.value), 9, _hoisted_14$2)) : createCommentVNode("", true),
1214
+ }, toDisplayString(conversionHelperText.value), 9, _hoisted_14$3)) : createCommentVNode("", true),
1215
1215
  withDirectives(createElementVNode("p", {
1216
1216
  id: unref(errorId),
1217
1217
  class: "aform_error",
@@ -1276,7 +1276,7 @@ var _hoisted_9$3 = { class: "date-input" };
1276
1276
  var _hoisted_10$3 = ["value"];
1277
1277
  var _hoisted_11$3 = ["value"];
1278
1278
  var _hoisted_12$3 = { class: "days-header" };
1279
- var _hoisted_13$1 = [
1279
+ var _hoisted_13$2 = [
1280
1280
  "tabindex",
1281
1281
  "aria-label",
1282
1282
  "aria-selected",
@@ -1285,7 +1285,7 @@ var _hoisted_13$1 = [
1285
1285
  "onKeydown",
1286
1286
  "onMouseover"
1287
1287
  ];
1288
- var _hoisted_14$1 = ["id"];
1288
+ var _hoisted_14$2 = ["id"];
1289
1289
  var numberOfRows = 6;
1290
1290
  var numberOfColumns = 7;
1291
1291
  // src/components/form/ADatePicker.vue
@@ -1588,14 +1588,14 @@ var ADatePicker_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__
1588
1588
  onClick: withModifiers(($event) => selectDate(getCurrentCell(rowNo, colNo)), ["prevent", "stop"]),
1589
1589
  onKeydown: ($event) => onDayKeydown($event, getCurrentCell(rowNo, colNo)),
1590
1590
  onMouseover: ($event) => hoverDate(getCurrentCell(rowNo, colNo))
1591
- }, toDisplayString(getCurrentDate(rowNo, colNo).day), 43, _hoisted_13$1);
1591
+ }, toDisplayString(getCurrentDate(rowNo, colNo).day), 43, _hoisted_13$2);
1592
1592
  }), 64))]);
1593
1593
  }), 64))
1594
1594
  ])], 40, _hoisted_5$14)]), withDirectives(createElementVNode("p", {
1595
1595
  id: unref(errorId),
1596
1596
  class: "aform_error",
1597
1597
  role: "alert"
1598
- }, toDisplayString(errorText.value), 9, _hoisted_14$1), [[vShow, errorText.value]])], 64));
1598
+ }, toDisplayString(errorText.value), 9, _hoisted_14$2), [[vShow, errorText.value]])], 64));
1599
1599
  };
1600
1600
  }
1601
1601
  }), [["__scopeId", "data-v-2d02eab2"]]);
@@ -3262,11 +3262,11 @@ var _hoisted_11$2 = {
3262
3262
  d: "M2.5 8h11M9 3.5 13.5 8 9 12.5"
3263
3263
  };
3264
3264
  var _hoisted_12$2 = { class: "aform_form-btn-name" };
3265
- var _hoisted_13 = {
3265
+ var _hoisted_13$1 = {
3266
3266
  key: 0,
3267
3267
  class: "loading autocomplete-result"
3268
3268
  };
3269
- var _hoisted_14 = [
3269
+ var _hoisted_14$1 = [
3270
3270
  "id",
3271
3271
  "aria-selected",
3272
3272
  "onMousedown",
@@ -3497,7 +3497,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
3497
3497
  "option-count": () => dropdownResults.value.length,
3498
3498
  "active-index": () => activeIndex.value
3499
3499
  }, {
3500
- default: withCtx(() => [loading.value ? (openBlock(), createElementBlock("li", _hoisted_13, "Loading…")) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(dropdownResults.value, (option, i) => {
3500
+ default: withCtx(() => [loading.value ? (openBlock(), createElementBlock("li", _hoisted_13$1, "Loading…")) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(dropdownResults.value, (option, i) => {
3501
3501
  return openBlock(), createElementBlock("li", {
3502
3502
  id: `${listboxId}-opt-${i}`,
3503
3503
  key: String(option.id),
@@ -3509,7 +3509,7 @@ var AFormLink_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PU
3509
3509
  }]),
3510
3510
  onMousedown: withModifiers(($event) => selectOption(option), ["prevent"]),
3511
3511
  onMouseenter: ($event) => activeIndex.value = i
3512
- }, [renderSlot(_ctx.$slots, "option", { option }, () => [createTextVNode(toDisplayString(option.displayText ?? String(option.id)), 1)], true)], 42, _hoisted_14);
3512
+ }, [renderSlot(_ctx.$slots, "option", { option }, () => [createTextVNode(toDisplayString(option.displayText ?? String(option.id)), 1)], true)], 42, _hoisted_14$1);
3513
3513
  }), 128))]),
3514
3514
  _: 3
3515
3515
  }, 8, [
@@ -4116,89 +4116,111 @@ var _hoisted_1$6 = { class: "login-container" };
4116
4116
  var _hoisted_2$2 = { class: "account-container" };
4117
4117
  var _hoisted_3 = { class: "account-header" };
4118
4118
  var _hoisted_4 = { id: "account-title" };
4119
- var _hoisted_5 = { id: "account-subtitle" };
4119
+ var _hoisted_5 = {
4120
+ key: 0,
4121
+ id: "account-subtitle"
4122
+ };
4120
4123
  var _hoisted_6 = { class: "login-form-container" };
4121
- var _hoisted_7 = { class: "login-form-email aform_form-element" };
4122
- var _hoisted_8 = ["disabled"];
4123
- var _hoisted_9 = { class: "login-form-password aform_form-element" };
4124
- var _hoisted_10 = ["disabled"];
4124
+ var _hoisted_7 = { class: "login-form-identity aform_form-element" };
4125
+ var _hoisted_8 = ["id", "for"];
4126
+ var _hoisted_9 = [
4127
+ "id",
4128
+ "name",
4129
+ "placeholder",
4130
+ "type",
4131
+ "autocomplete",
4132
+ "disabled"
4133
+ ];
4134
+ var _hoisted_10 = { class: "login-form-password aform_form-element" };
4125
4135
  var _hoisted_11 = ["disabled"];
4126
- var _hoisted_12 = {
4136
+ var _hoisted_12 = ["disabled"];
4137
+ var _hoisted_13 = {
4127
4138
  key: 0,
4128
- class: "material-symbols-outlined loading-icon"
4139
+ class: "loading-icon",
4140
+ "aria-hidden": "true"
4141
+ };
4142
+ var _hoisted_14 = {
4143
+ key: 0,
4144
+ class: "login-alternate"
4129
4145
  };
4130
4146
  // src/components/utilities/Login.vue
4131
4147
  var Login_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/* @__PURE__ */ defineComponent({
4132
4148
  __name: "Login",
4133
4149
  props: {
4134
4150
  headerTitle: { default: "Login" },
4135
- headerSubtitle: { default: "Enter your email and password to login" }
4151
+ headerSubtitle: {},
4152
+ identity: {},
4153
+ authenticate: { type: Function }
4136
4154
  },
4137
4155
  emits: ["loginFailed", "loginSuccess"],
4138
4156
  setup(__props, { emit: __emit }) {
4139
4157
  const emit = __emit;
4140
- const email = ref("");
4158
+ const identityValue = ref("");
4141
4159
  const password = ref("");
4142
4160
  const isLoading = ref(false);
4143
- const loginFailed = ref(false);
4144
- function onSubmit(event) {
4161
+ const passwordInput = useTemplateRef("passwordInput");
4162
+ async function onSubmit(event) {
4145
4163
  event.preventDefault();
4146
4164
  isLoading.value = true;
4147
- if (loginFailed.value) {
4165
+ try {
4166
+ await __props.authenticate(identityValue.value, password.value);
4167
+ emit("loginSuccess");
4168
+ } catch (error) {
4169
+ isLoading.value = false;
4170
+ await nextTick();
4171
+ passwordInput.value?.focus();
4172
+ passwordInput.value?.select();
4173
+ emit("loginFailed", error);
4174
+ } finally {
4148
4175
  isLoading.value = false;
4149
- emit("loginFailed");
4150
- return;
4151
4176
  }
4152
- isLoading.value = false;
4153
- emit("loginSuccess");
4154
4177
  }
4155
4178
  return (_ctx, _cache) => {
4156
4179
  return openBlock(), createElementBlock("div", _hoisted_1$6, [createElementVNode("div", null, [createElementVNode("div", _hoisted_2$2, [
4157
- createElementVNode("div", _hoisted_3, [createElementVNode("h1", _hoisted_4, toDisplayString(__props.headerTitle), 1), createElementVNode("p", _hoisted_5, toDisplayString(__props.headerSubtitle), 1)]),
4180
+ createElementVNode("div", _hoisted_3, [createElementVNode("h1", _hoisted_4, toDisplayString(__props.headerTitle), 1), __props.headerSubtitle ? (openBlock(), createElementBlock("p", _hoisted_5, toDisplayString(__props.headerSubtitle), 1)) : createCommentVNode("", true)]),
4158
4181
  createElementVNode("form", { onSubmit }, [createElementVNode("div", _hoisted_6, [
4159
- createElementVNode("div", _hoisted_7, [_cache[2] || (_cache[2] = createElementVNode("label", {
4160
- id: "login-email",
4161
- for: "email",
4182
+ createElementVNode("div", _hoisted_7, [createElementVNode("label", {
4183
+ id: `login-${__props.identity.name}`,
4184
+ for: __props.identity.name,
4162
4185
  class: "aform_field-label"
4163
- }, "Email", -1)), withDirectives(createElementVNode("input", {
4164
- id: "email",
4165
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => email.value = $event),
4186
+ }, toDisplayString(__props.identity.label), 9, _hoisted_8), withDirectives(createElementVNode("input", {
4187
+ id: __props.identity.name,
4188
+ "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => identityValue.value = $event),
4166
4189
  class: "aform_input-field",
4167
- name: "email",
4168
- placeholder: "name@example.com",
4169
- type: "email",
4170
- autocomplete: "email",
4190
+ name: __props.identity.name,
4191
+ placeholder: __props.identity.placeholder,
4192
+ type: __props.identity.inputType,
4193
+ autocomplete: __props.identity.autocomplete,
4171
4194
  autocapitalize: "none",
4172
4195
  autocorrect: "off",
4173
4196
  disabled: isLoading.value
4174
- }, null, 8, _hoisted_8), [[vModelText, email.value]])]),
4175
- createElementVNode("div", _hoisted_9, [_cache[3] || (_cache[3] = createElementVNode("label", {
4197
+ }, null, 8, _hoisted_9), [[vModelDynamic, identityValue.value]])]),
4198
+ createElementVNode("div", _hoisted_10, [_cache[2] || (_cache[2] = createElementVNode("label", {
4176
4199
  id: "login-password",
4177
4200
  for: "password",
4178
4201
  class: "aform_field-label"
4179
4202
  }, "Password", -1)), withDirectives(createElementVNode("input", {
4180
4203
  id: "password",
4204
+ ref_key: "passwordInput",
4205
+ ref: passwordInput,
4181
4206
  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => password.value = $event),
4182
4207
  class: "aform_input-field",
4183
4208
  name: "password",
4184
4209
  type: "password",
4185
4210
  autocomplete: "current-password",
4186
4211
  disabled: isLoading.value
4187
- }, null, 8, _hoisted_10), [[vModelText, password.value]])]),
4212
+ }, null, 8, _hoisted_11), [[vModelText, password.value]])]),
4188
4213
  createElementVNode("button", {
4189
4214
  type: "submit",
4190
4215
  class: "btn",
4191
- disabled: isLoading.value || !email.value || !password.value
4192
- }, [isLoading.value ? (openBlock(), createElementBlock("span", _hoisted_12, "progress_activity")) : createCommentVNode("", true), _cache[4] || (_cache[4] = createElementVNode("span", { id: "login-form-button" }, "Login", -1))], 8, _hoisted_11)
4216
+ disabled: isLoading.value || !identityValue.value || !password.value
4217
+ }, [isLoading.value ? (openBlock(), createElementBlock("span", _hoisted_13)) : createCommentVNode("", true), _cache[3] || (_cache[3] = createElementVNode("span", { id: "login-form-button" }, "Login", -1))], 8, _hoisted_12)
4193
4218
  ])], 32),
4194
- _cache[5] || (_cache[5] = createElementVNode("button", {
4195
- type: "button",
4196
- class: "btn"
4197
- }, [createElementVNode("span", { id: "forgot-password-button" }, "Forgot password?")], -1))
4219
+ _ctx.$slots.alternateSignIn ? (openBlock(), createElementBlock("div", _hoisted_14, [renderSlot(_ctx.$slots, "alternateSignIn", { identity: identityValue.value }, void 0, true)])) : createCommentVNode("", true)
4198
4220
  ])])]);
4199
4221
  };
4200
4222
  }
4201
- }), [["__scopeId", "data-v-555c3224"]]);
4223
+ }), [["__scopeId", "data-v-206dce0e"]]);
4202
4224
  // src/components/AFormLoading.vue
4203
4225
  var _sfc_main = {};
4204
4226
  var _hoisted_1$5 = { class: "aform-loading" };
@@ -4760,6 +4782,36 @@ var ATupleCellEditor_default = /*#__PURE__*/ _plugin_vue_export_helper_default(/
4760
4782
  };
4761
4783
  }
4762
4784
  }), [["__scopeId", "data-v-9630226d"]]);
4785
+ // src/login/loginIdentity.ts
4786
+ /**
4787
+ * Built-in identity field presets for email and username sign-in.
4788
+ * @public
4789
+ */
4790
+ var loginIdentities = {
4791
+ email: {
4792
+ label: "Email",
4793
+ inputType: "email",
4794
+ autocomplete: "email",
4795
+ name: "email"
4796
+ },
4797
+ username: {
4798
+ label: "Username",
4799
+ inputType: "text",
4800
+ autocomplete: "username",
4801
+ name: "username"
4802
+ }
4803
+ };
4804
+ // src/composables/useLoginPreset.ts
4805
+ /**
4806
+ * Header copy and identity field wiring for common login modes.
4807
+ * @public
4808
+ */
4809
+ function useLoginPreset(preset) {
4810
+ return {
4811
+ identity: loginIdentities[preset],
4812
+ headerSubtitle: preset === "email" ? "Enter your email and password to login" : "Enter your username and password to login"
4813
+ };
4814
+ }
4763
4815
  // src/index.ts
4764
4816
  /**
4765
4817
  * Install all AForm components
@@ -4796,6 +4848,6 @@ function install(app) {
4796
4848
  app.component("ATupleCellEditor", ATupleCellEditor_default);
4797
4849
  app.component("ATupleCellShell", ATupleCellShell_default);
4798
4850
  }
4799
- export { ABadge_default as ABadge, ACheckbox_default as ACheckbox, ACurrencyInput_default as ACurrencyInput, ADate_default as ADate, ADatePicker_default as ADatePicker, ADateRange_default as ADateRange, ADateSelection_default as ADateSelection, ADateTime_default as ADateTime, ADateTimeInput_default as ADateTimeInput, ADropdown_default as ADropdown, ADuration_default as ADuration, AFieldset_default as AFieldset, AFileAttach_default as AFileAttach, AForm_default as AForm, AFormLink_default as AFormLink, AFormLoading_default as AFormLoading, ANumericInput_default as ANumericInput, AQuantityInput_default as AQuantityInput, ASegmentedControl_default as ASegmentedControl, ASemverInput_default as ASemverInput, ATableTupleCurrencyPicker_default as ATableTupleCurrencyPicker, ATableTupleQuantityPicker_default as ATableTupleQuantityPicker, ATextInput_default as ATextInput, ATextboxInput_default as ATextboxInput, ATupleCellEditor_default as ATupleCellEditor, ATupleCellShell_default as ATupleCellShell, ExpandButton_default as ExpandButton, Login_default as Login, badgeInputAccentStyle, deserializeFunction, install, resolveFieldBadge, resolvedFieldsToColumns };
4851
+ export { ABadge_default as ABadge, ACheckbox_default as ACheckbox, ACurrencyInput_default as ACurrencyInput, ADate_default as ADate, ADatePicker_default as ADatePicker, ADateRange_default as ADateRange, ADateSelection_default as ADateSelection, ADateTime_default as ADateTime, ADateTimeInput_default as ADateTimeInput, ADropdown_default as ADropdown, ADuration_default as ADuration, AFieldset_default as AFieldset, AFileAttach_default as AFileAttach, AForm_default as AForm, AFormLink_default as AFormLink, AFormLoading_default as AFormLoading, ANumericInput_default as ANumericInput, AQuantityInput_default as AQuantityInput, ASegmentedControl_default as ASegmentedControl, ASemverInput_default as ASemverInput, ATableTupleCurrencyPicker_default as ATableTupleCurrencyPicker, ATableTupleQuantityPicker_default as ATableTupleQuantityPicker, ATextInput_default as ATextInput, ATextboxInput_default as ATextboxInput, ATupleCellEditor_default as ATupleCellEditor, ATupleCellShell_default as ATupleCellShell, ExpandButton_default as ExpandButton, Login_default as Login, badgeInputAccentStyle, deserializeFunction, install, loginIdentities, resolveFieldBadge, resolvedFieldsToColumns, useLoginPreset };
4800
4852
 
4801
4853
  //# sourceMappingURL=aform.js.map