@hokulea/ember 0.7.2 → 0.8.0
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/declarations/components/form/description.gts.d.ts.map +1 -0
- package/declarations/components/form/errors.gts.d.ts +15 -0
- package/declarations/components/form/errors.gts.d.ts.map +1 -0
- package/declarations/components/form/field.gts.d.ts +111 -0
- package/declarations/components/form/field.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/checkbox.gts.d.ts +16 -0
- package/declarations/components/form/fields/checkbox.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/currency.gts.d.ts +16 -0
- package/declarations/components/form/fields/currency.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/date.gts.d.ts +16 -0
- package/declarations/components/form/fields/date.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/email.gts.d.ts +16 -0
- package/declarations/components/form/fields/email.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/list.gts.d.ts +28 -0
- package/declarations/components/form/fields/list.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/multiple-choice.gts.d.ts +60 -0
- package/declarations/components/form/fields/multiple-choice.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/number.gts.d.ts +16 -0
- package/declarations/components/form/fields/number.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/password.gts.d.ts +18 -0
- package/declarations/components/form/fields/password.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/phone.gts.d.ts +18 -0
- package/declarations/components/form/fields/phone.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/range.gts.d.ts +16 -0
- package/declarations/components/form/fields/range.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/select.gts.d.ts +17 -0
- package/declarations/components/form/fields/select.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/singular-choice.gts.d.ts +56 -0
- package/declarations/components/form/fields/singular-choice.gts.d.ts.map +1 -0
- package/declarations/{-private/form/components → components/form}/fields/stories-utils.d.ts +2 -2
- package/declarations/components/form/fields/stories-utils.d.ts.map +1 -0
- package/declarations/components/form/fields/text-area.gts.d.ts +16 -0
- package/declarations/components/form/fields/text-area.gts.d.ts.map +1 -0
- package/declarations/components/form/fields/text.gts.d.ts +18 -0
- package/declarations/components/form/fields/text.gts.d.ts.map +1 -0
- package/declarations/components/form/form.gts.d.ts +210 -0
- package/declarations/components/form/form.gts.d.ts.map +1 -0
- package/declarations/components/form/index.d.ts +4 -0
- package/declarations/components/form/index.d.ts.map +1 -0
- package/declarations/components/form/label.gts.d.ts.map +1 -0
- package/declarations/components/form/manage-validation.d.ts +18 -0
- package/declarations/components/form/manage-validation.d.ts.map +1 -0
- package/declarations/components/form/reset.gts.d.ts.map +1 -0
- package/declarations/components/form/rules.gts.d.ts +36 -0
- package/declarations/components/form/rules.gts.d.ts.map +1 -0
- package/declarations/components/form/submit.gts.d.ts.map +1 -0
- package/declarations/components/form.gts.d.ts +1 -318
- package/declarations/components/form.gts.d.ts.map +1 -1
- package/declarations/components/page.gts.d.ts +1 -1
- package/declarations/components/page.gts.d.ts.map +1 -1
- package/declarations/components/select.gts.d.ts.map +1 -1
- package/declarations/index.d.ts +2 -3
- package/declarations/index.d.ts.map +1 -1
- package/declarations/test-support/page-objects/-private/field.d.ts +4 -0
- package/declarations/test-support/page-objects/-private/field.d.ts.map +1 -1
- package/dist/components/checkbox.js +1 -1
- package/dist/components/checkbox.js.map +1 -1
- package/dist/components/currency-input.js +1 -1
- package/dist/components/currency-input.js.map +1 -1
- package/dist/components/date-input.js +1 -1
- package/dist/components/date-input.js.map +1 -1
- package/dist/components/email-input.js +1 -1
- package/dist/components/email-input.js.map +1 -1
- package/dist/components/form.js +1 -835
- package/dist/components/form.js.map +1 -1
- package/dist/components/number-input.js +1 -1
- package/dist/components/number-input.js.map +1 -1
- package/dist/components/page.js +1 -1
- package/dist/components/page.js.map +1 -1
- package/dist/components/password-input.js +1 -1
- package/dist/components/password-input.js.map +1 -1
- package/dist/components/phone-input.js +1 -1
- package/dist/components/phone-input.js.map +1 -1
- package/dist/components/radio.js +1 -1
- package/dist/components/radio.js.map +1 -1
- package/dist/components/range-input.js +3 -3
- package/dist/components/range-input.js.map +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/select.js.map +1 -1
- package/dist/components/text-area.js +1 -1
- package/dist/components/text-area.js.map +1 -1
- package/dist/components/text-input.js +1 -1
- package/dist/components/text-input.js.map +1 -1
- package/dist/form-DBuzL4_0.js +518 -0
- package/dist/form-DBuzL4_0.js.map +1 -0
- package/dist/index.js +1 -1
- package/dist/test-support/index.js +6 -0
- package/dist/test-support/index.js.map +1 -1
- package/package.json +27 -25
- package/declarations/-private/form/components/description.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/errors.gts.d.ts +0 -15
- package/declarations/-private/form/components/errors.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/field.gts.d.ts +0 -147
- package/declarations/-private/form/components/field.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/checkbox.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/checkbox.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/currency.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/currency.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/date.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/date.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/email.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/email.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/list.gts.d.ts +0 -27
- package/declarations/-private/form/components/fields/list.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/multiple-choice.gts.d.ts +0 -58
- package/declarations/-private/form/components/fields/multiple-choice.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/number.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/number.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/password.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/password.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/phone.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/phone.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/range.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/range.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/select.gts.d.ts +0 -16
- package/declarations/-private/form/components/fields/select.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/singular-choice.gts.d.ts +0 -56
- package/declarations/-private/form/components/fields/singular-choice.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/stories-utils.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/text-area.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/text-area.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/fields/text.gts.d.ts +0 -15
- package/declarations/-private/form/components/fields/text.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/label.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/reset.gts.d.ts.map +0 -1
- package/declarations/-private/form/components/submit.gts.d.ts.map +0 -1
- package/declarations/-private/form/index.d.ts +0 -49
- package/declarations/-private/form/index.d.ts.map +0 -1
- package/declarations/-private/form/modifiers/capture-events.d.ts +0 -21
- package/declarations/-private/form/modifiers/capture-events.d.ts.map +0 -1
- package/declarations/-private/form/modifiers/manage-validation.d.ts +0 -24
- package/declarations/-private/form/modifiers/manage-validation.d.ts.map +0 -1
- /package/declarations/{-private/form/components → components/form}/description.gts.d.ts +0 -0
- /package/declarations/{-private/form/components → components/form}/label.gts.d.ts +0 -0
- /package/declarations/{-private/form/components → components/form}/reset.gts.d.ts +0 -0
- /package/declarations/{-private/form/components → components/form}/submit.gts.d.ts +0 -0
|
@@ -0,0 +1,518 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
import { hash, uniqueId } from '@ember/helper';
|
|
3
|
+
import styles from '@hokulea/core/forms.module.css';
|
|
4
|
+
import { createForm } from '@hokulea/ember-pahu';
|
|
5
|
+
import { tracked } from '@glimmer/tracking';
|
|
6
|
+
import { next } from '@ember/runloop';
|
|
7
|
+
import { element } from 'ember-element-helper';
|
|
8
|
+
import { a as and, b as asBoolean, c as asNumber, d as asString, e as eq } from './helpers-DS9du02l.js';
|
|
9
|
+
import { precompileTemplate } from '@ember/template-compilation';
|
|
10
|
+
import { setComponentTemplate } from '@ember/component';
|
|
11
|
+
import templateOnly from '@ember/component/template-only';
|
|
12
|
+
import Icon from './components/icon.js';
|
|
13
|
+
import { g, i } from 'decorator-transforms/runtime-esm';
|
|
14
|
+
import Checkbox from './components/checkbox.js';
|
|
15
|
+
import { modifier } from 'ember-modifier';
|
|
16
|
+
import CurrencyInput from './components/currency-input.js';
|
|
17
|
+
import DateInput from './components/date-input.js';
|
|
18
|
+
import EmailInput from './components/email-input.js';
|
|
19
|
+
import List from './components/list.js';
|
|
20
|
+
import NumberInput from './components/number-input.js';
|
|
21
|
+
import PasswordInput from './components/password-input.js';
|
|
22
|
+
import PhoneInput from './components/phone-input.js';
|
|
23
|
+
import RangeInput from './components/range-input.js';
|
|
24
|
+
import Select from './components/select.js';
|
|
25
|
+
import Radio from './components/radio.js';
|
|
26
|
+
import TextInput from './components/text-input.js';
|
|
27
|
+
import TextArea from './components/text-area.js';
|
|
28
|
+
import styles$1 from '@hokulea/core/actions.module.css';
|
|
29
|
+
import { d as disabled } from './disabled-B_FQ0Z51.js';
|
|
30
|
+
|
|
31
|
+
const Description = setComponentTemplate(precompileTemplate("\n <p class={{styles.description}} data-test-description ...attributes>\n {{yield}}\n </p>\n", {
|
|
32
|
+
strictMode: true,
|
|
33
|
+
scope: () => ({
|
|
34
|
+
styles
|
|
35
|
+
})
|
|
36
|
+
}), templateOnly());
|
|
37
|
+
|
|
38
|
+
const Errors = setComponentTemplate(precompileTemplate("\n <div id={{@id}} aria-live=\"assertive\" class={{styles.errors}} ...attributes>\n {{!-- <span><Icon @icon='dismiss-circle' @style='filled' /></span> --}}\n {{#if (has-block)}}\n {{yield @errors}}\n {{else}}\n <div>\n {{#each @errors as |e|}}\n {{#if e.message}}\n <p data-test-error data-test-error-type=\"{{e.type}}\" data-test-error-value=\"{{e.value}}\">{{e.message}}</p>\n {{/if}}\n {{/each}}\n </div>\n {{/if}}\n </div>\n", {
|
|
39
|
+
strictMode: true,
|
|
40
|
+
scope: () => ({
|
|
41
|
+
styles
|
|
42
|
+
})
|
|
43
|
+
}), templateOnly());
|
|
44
|
+
|
|
45
|
+
const Label = setComponentTemplate(precompileTemplate("\n {{#let (if @element @element (element \"label\")) as |Element|}}\n <Element class={{styles.label}} data-test-label ...attributes>\n {{yield}}\n </Element>\n {{/let}}\n", {
|
|
46
|
+
strictMode: true,
|
|
47
|
+
scope: () => ({
|
|
48
|
+
element,
|
|
49
|
+
styles
|
|
50
|
+
})
|
|
51
|
+
}), templateOnly());
|
|
52
|
+
|
|
53
|
+
const ErrorIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="256"
|
|
54
|
+
height="256" viewBox="0 0 256 256"><path fill="currentColor" d="M208.49
|
|
55
|
+
191.51a12 12 0 0 1-17 17L128 145l-63.51 63.49a12 12 0 0 1-17-17L111 128L47.51
|
|
56
|
+
64.49a12 12 0 0 1 17-17L128 111l63.51-63.52a12 12 0 0 1 17 17L145
|
|
57
|
+
128Z"/></svg>`;
|
|
58
|
+
const ValidIcon = `<svg xmlns="http://www.w3.org/2000/svg" width="256"
|
|
59
|
+
height="256" viewBox="0 0 256 256"><path fill="currentColor" d="m232.49
|
|
60
|
+
80.49l-128 128a12 12 0 0 1-17 0l-56-56a12 12 0 1 1 17-17L96 183L215.51 63.51a12
|
|
61
|
+
12 0 0 1 17 17Z"/></svg>`;
|
|
62
|
+
class Rule extends Component {
|
|
63
|
+
isInvalid = () => {
|
|
64
|
+
return this.args.errors?.some(i => this.args.key in i && i[this.args.key] === this.args.value);
|
|
65
|
+
};
|
|
66
|
+
static {
|
|
67
|
+
setComponentTemplate(precompileTemplate("\n <p data-test-rule data-test-rule-invalid={{(this.isInvalid)}}>\n <Icon @icon={{if (this.isInvalid) ErrorIcon ValidIcon}} data-invalid={{(this.isInvalid)}} data-icon />\n\n <span>{{yield}}</span>\n </p>\n ", {
|
|
68
|
+
strictMode: true,
|
|
69
|
+
scope: () => ({
|
|
70
|
+
Icon,
|
|
71
|
+
ErrorIcon,
|
|
72
|
+
ValidIcon
|
|
73
|
+
})
|
|
74
|
+
}), this);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
class Rules extends Component {
|
|
78
|
+
constructor(owner, args) {
|
|
79
|
+
super(owner, args);
|
|
80
|
+
args.useRules(true);
|
|
81
|
+
}
|
|
82
|
+
static {
|
|
83
|
+
setComponentTemplate(precompileTemplate("\n <div id={{@id}} aria-live=\"assertive\" class={{styles.rules}} ...attributes>\n {{yield (component Rule errors=@errors)}}\n </div>\n ", {
|
|
84
|
+
strictMode: true,
|
|
85
|
+
scope: () => ({
|
|
86
|
+
styles,
|
|
87
|
+
Rule
|
|
88
|
+
})
|
|
89
|
+
}), this);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
class Field extends Component {
|
|
94
|
+
static {
|
|
95
|
+
g(this.prototype, "rulesUsed", [tracked], function () {
|
|
96
|
+
return false;
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
#rulesUsed = (i(this, "rulesUsed"), void 0);
|
|
100
|
+
#field;
|
|
101
|
+
get validateOn() {
|
|
102
|
+
return this.rulesUsed ? 'input' : this.args.validateOn;
|
|
103
|
+
}
|
|
104
|
+
get revalidateOn() {
|
|
105
|
+
return this.rulesUsed ? 'input' : this.args.revalidateOn;
|
|
106
|
+
}
|
|
107
|
+
createOrUpdateField = config => {
|
|
108
|
+
const filteredConfig = Object.fromEntries(Object.entries(config).filter(([_, v]) => v !== undefined));
|
|
109
|
+
if (this.#field) {
|
|
110
|
+
this.#field.updateConfig(filteredConfig);
|
|
111
|
+
} else {
|
|
112
|
+
this.#field = this.args.form.createField(filteredConfig);
|
|
113
|
+
}
|
|
114
|
+
return this.#field;
|
|
115
|
+
};
|
|
116
|
+
useRules = useRules => {
|
|
117
|
+
// eslint-disable-next-line ember/no-runloop
|
|
118
|
+
next(async () => {
|
|
119
|
+
this.rulesUsed = useRules;
|
|
120
|
+
if (useRules) {
|
|
121
|
+
await this.#field?.validate();
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
get showErrors() {
|
|
126
|
+
return !this.rulesUsed && this.args.showErrors !== false;
|
|
127
|
+
}
|
|
128
|
+
static {
|
|
129
|
+
setComponentTemplate(precompileTemplate("\n {{#let (uniqueId) (uniqueId) (if @element @element (element \"div\")) (this.createOrUpdateField name=@name ignoreNativeValidation=@ignoreNativeValidation linkedField=@linkedField validateOn=this.validateOn revalidateOn=this.revalidateOn validate=@validate validated=@validated value=@value) (component Rules useRules=this.useRules) as |fieldId errorId Element field WiredRules|}}\n <Element class={{styles.field}} data-test-field={{@name}}>\n {{#if @label}}\n {{#let (if @labelComponent @labelComponent Label) as |L|}}\n <L for={{unless @labelComponent fieldId}}>{{@label}}</L>\n {{/let}}\n {{/if}}\n\n {{#if @description}}\n <Description>{{@description}}</Description>\n {{/if}}\n\n {{yield (hash value=field.value setValue=field.setValue id=fieldId errorId=errorId invalid=field.invalid registerElement=field.registerElement issues=field.issues validate=field.validate showErrors=this.showErrors Rules=(component WiredRules id=errorId errors=field.issues))}}\n\n {{#if (and this.showErrors field.issues)}}\n <Errors @id={{errorId}} @errors={{field.issues}} />\n {{/if}}\n </Element>\n {{/let}}\n ", {
|
|
130
|
+
strictMode: true,
|
|
131
|
+
scope: () => ({
|
|
132
|
+
uniqueId,
|
|
133
|
+
element,
|
|
134
|
+
Rules,
|
|
135
|
+
styles,
|
|
136
|
+
Label,
|
|
137
|
+
Description,
|
|
138
|
+
hash,
|
|
139
|
+
and,
|
|
140
|
+
Errors
|
|
141
|
+
})
|
|
142
|
+
}), this);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const manageValidation = modifier((element, _, {
|
|
147
|
+
showErrors,
|
|
148
|
+
invalid,
|
|
149
|
+
errorMessageId
|
|
150
|
+
}) => {
|
|
151
|
+
if (showErrors !== false) {
|
|
152
|
+
element.ariaInvalid = invalid ? 'true' : 'false';
|
|
153
|
+
if (invalid) {
|
|
154
|
+
element.setAttribute('aria-errormessage', errorMessageId);
|
|
155
|
+
} else {
|
|
156
|
+
element.removeAttribute('aria-errormessage');
|
|
157
|
+
}
|
|
158
|
+
if (element.parentElement && 'inputBuilder' in element.parentElement.dataset) {
|
|
159
|
+
element.parentElement.dataset.invalid = invalid ? 'true' : 'false';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
});
|
|
164
|
+
|
|
165
|
+
class CheckboxField extends Component {
|
|
166
|
+
Field = this.args.Field;
|
|
167
|
+
setBooleanValue = setValue => {
|
|
168
|
+
return value => setValue(value);
|
|
169
|
+
};
|
|
170
|
+
static {
|
|
171
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @label @name={{@name}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <div class={{styles.choices}}>\n <div class={{styles.choice}}>\n <span>\n <Checkbox @value={{asBoolean f.value}} @update={{this.setBooleanValue f.setValue}} @disabled={{@disabled}} id={{f.id}} name={{@name}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n </span>\n\n <div>\n <Label for={{f.id}}>{{@label}}</Label>\n\n {{#if @description}}\n <Description>{{@description}}</Description>\n {{/if}}\n </div>\n </div>\n </div>\n </this.Field>\n ", {
|
|
172
|
+
strictMode: true,
|
|
173
|
+
scope: () => ({
|
|
174
|
+
styles,
|
|
175
|
+
Checkbox,
|
|
176
|
+
asBoolean,
|
|
177
|
+
manageValidation,
|
|
178
|
+
Label,
|
|
179
|
+
Description
|
|
180
|
+
})
|
|
181
|
+
}), this);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
class CurrencyField extends Component {
|
|
186
|
+
Field = this.args.Field;
|
|
187
|
+
setNumberValue = setValue => {
|
|
188
|
+
return value => setValue(value);
|
|
189
|
+
};
|
|
190
|
+
static {
|
|
191
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <CurrencyInput @value={{asNumber f.value}} @update={{this.setNumberValue f.setValue}} @disabled={{@disabled}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n </this.Field>\n ", {
|
|
192
|
+
strictMode: true,
|
|
193
|
+
scope: () => ({
|
|
194
|
+
CurrencyInput,
|
|
195
|
+
asNumber,
|
|
196
|
+
manageValidation
|
|
197
|
+
})
|
|
198
|
+
}), this);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
class DateField extends Component {
|
|
203
|
+
Field = this.args.Field;
|
|
204
|
+
setStringValue = setValue => {
|
|
205
|
+
return value => setValue(value);
|
|
206
|
+
};
|
|
207
|
+
static {
|
|
208
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <DateInput @value={{asString f.value}} @update={{this.setStringValue f.setValue}} @disabled={{@disabled}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n </this.Field>\n ", {
|
|
209
|
+
strictMode: true,
|
|
210
|
+
scope: () => ({
|
|
211
|
+
DateInput,
|
|
212
|
+
asString,
|
|
213
|
+
manageValidation
|
|
214
|
+
})
|
|
215
|
+
}), this);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
class EmailField extends Component {
|
|
220
|
+
Field = this.args.Field;
|
|
221
|
+
setStringValue = setValue => {
|
|
222
|
+
return value => setValue(value);
|
|
223
|
+
};
|
|
224
|
+
static {
|
|
225
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <EmailInput @value={{asString f.value}} @update={{this.setStringValue f.setValue}} @disabled={{@disabled}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n </this.Field>\n ", {
|
|
226
|
+
strictMode: true,
|
|
227
|
+
scope: () => ({
|
|
228
|
+
EmailInput,
|
|
229
|
+
asString,
|
|
230
|
+
manageValidation
|
|
231
|
+
})
|
|
232
|
+
}), this);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
const ListLabel = setComponentTemplate(precompileTemplate("\n <Label @element={{element \"span\"}} id={{@id}}>{{yield}}</Label>\n", {
|
|
237
|
+
strictMode: true,
|
|
238
|
+
scope: () => ({
|
|
239
|
+
Label,
|
|
240
|
+
element
|
|
241
|
+
})
|
|
242
|
+
}), templateOnly());
|
|
243
|
+
class ListField extends Component {
|
|
244
|
+
Field = this.args.Field;
|
|
245
|
+
List = List;
|
|
246
|
+
setValue = setValue => {
|
|
247
|
+
return value => setValue(value);
|
|
248
|
+
};
|
|
249
|
+
asValue = value => value;
|
|
250
|
+
static {
|
|
251
|
+
setComponentTemplate(precompileTemplate("\n {{#let (uniqueId) as |labelId|}}\n <this.Field @name={{@name}} @label={{@label}} @labelComponent={{component ListLabel id=labelId}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <this.List @value={{this.asValue f.value}} @update={{this.setValue f.setValue}} @disabled={{@disabled}} {{!-- name={{@name}} --}} aria-labelledby={{labelId}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid}} ...attributes as |s|>\n {{yield s}}\n </this.List>\n </this.Field>\n {{/let}}\n ", {
|
|
252
|
+
strictMode: true,
|
|
253
|
+
scope: () => ({
|
|
254
|
+
uniqueId,
|
|
255
|
+
ListLabel,
|
|
256
|
+
manageValidation
|
|
257
|
+
})
|
|
258
|
+
}), this);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
let Option$1 = class Option extends Component {
|
|
263
|
+
select = checked => {
|
|
264
|
+
if (checked) {
|
|
265
|
+
this.args.field.setValue([...(this.args.field.value ?? []), this.args.value]);
|
|
266
|
+
} else {
|
|
267
|
+
const values = this.args.field.value;
|
|
268
|
+
const index = this.args.field.value?.indexOf(this.args.value);
|
|
269
|
+
if (Array.isArray(values) && index) {
|
|
270
|
+
values.splice(index, 1);
|
|
271
|
+
this.args.field.setValue(values);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
get checked() {
|
|
276
|
+
return this.args.field.value?.includes(this.args.value);
|
|
277
|
+
}
|
|
278
|
+
get issues() {
|
|
279
|
+
return this.args.field.issues.filter(i => 'value' in i && i.value === this.args.value);
|
|
280
|
+
}
|
|
281
|
+
get invalid() {
|
|
282
|
+
return this.issues.length > 0;
|
|
283
|
+
}
|
|
284
|
+
static {
|
|
285
|
+
setComponentTemplate(precompileTemplate("\n {{#let (uniqueId) (uniqueId) as |id errorId|}}\n <div class={{styles.choice}} data-test-option>\n <span>\n <Checkbox @value={{this.checked}} @update={{this.select}} @disabled={{@disabled}} id={{id}} name={{@name}} value={{@value}} {{@field.registerElement}} {{manageValidation errorMessageId=errorId invalid=this.invalid}} ...attributes />\n </span>\n\n <div>\n <Label for={{id}}>{{@label}}</Label>\n\n {{#if @description}}\n <Description>{{@description}}</Description>\n {{/if}}\n\n {{yield}}\n\n {{#if this.issues}}\n <Errors @id={{errorId}} @errors={{this.issues}} />\n {{/if}}\n\n </div>\n </div>\n {{/let}}\n ", {
|
|
286
|
+
strictMode: true,
|
|
287
|
+
scope: () => ({
|
|
288
|
+
uniqueId,
|
|
289
|
+
styles,
|
|
290
|
+
Checkbox,
|
|
291
|
+
manageValidation,
|
|
292
|
+
Label,
|
|
293
|
+
Description,
|
|
294
|
+
Errors
|
|
295
|
+
})
|
|
296
|
+
}), this);
|
|
297
|
+
}
|
|
298
|
+
};
|
|
299
|
+
class MultipleChoiceField extends Component {
|
|
300
|
+
Field = this.args.Field;
|
|
301
|
+
Option = Option$1;
|
|
302
|
+
asMultiField = field => {
|
|
303
|
+
return field;
|
|
304
|
+
};
|
|
305
|
+
static {
|
|
306
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @element={{element \"fieldset\"}} @showErrors={{false}} @labelComponent={{component Label element=(element \"legend\")}} @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <div class={{styles.choices}} data-test-choices>\n {{yield (hash Option=(component this.Option field=(this.asMultiField f) name=@name disabled=@disabled))}}\n </div>\n </this.Field>\n ", {
|
|
307
|
+
strictMode: true,
|
|
308
|
+
scope: () => ({
|
|
309
|
+
element,
|
|
310
|
+
Label,
|
|
311
|
+
styles,
|
|
312
|
+
hash
|
|
313
|
+
})
|
|
314
|
+
}), this);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
class NumberField extends Component {
|
|
319
|
+
Field = this.args.Field;
|
|
320
|
+
setNumberValue = setValue => {
|
|
321
|
+
return value => setValue(value);
|
|
322
|
+
};
|
|
323
|
+
static {
|
|
324
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <NumberInput @value={{asNumber f.value}} @update={{this.setNumberValue f.setValue}} @disabled={{@disabled}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n </this.Field>\n ", {
|
|
325
|
+
strictMode: true,
|
|
326
|
+
scope: () => ({
|
|
327
|
+
NumberInput,
|
|
328
|
+
asNumber,
|
|
329
|
+
manageValidation
|
|
330
|
+
})
|
|
331
|
+
}), this);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
class PasswordField extends Component {
|
|
336
|
+
Field = this.args.Field;
|
|
337
|
+
setStringValue = setValue => {
|
|
338
|
+
return value => setValue(value);
|
|
339
|
+
};
|
|
340
|
+
static {
|
|
341
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <PasswordInput @value={{asString f.value}} @update={{this.setStringValue f.setValue}} @disabled={{@disabled}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n\n {{#if (has-block \"rules\")}}\n <f.Rules as |Rule|>\n {{yield Rule to=\"rules\"}}\n </f.Rules>\n {{/if}}\n </this.Field>\n ", {
|
|
342
|
+
strictMode: true,
|
|
343
|
+
scope: () => ({
|
|
344
|
+
PasswordInput,
|
|
345
|
+
asString,
|
|
346
|
+
manageValidation
|
|
347
|
+
})
|
|
348
|
+
}), this);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
class PhoneField extends Component {
|
|
353
|
+
Field = this.args.Field;
|
|
354
|
+
setStringValue = setValue => {
|
|
355
|
+
return value => setValue(value);
|
|
356
|
+
};
|
|
357
|
+
static {
|
|
358
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <PhoneInput @value={{asString f.value}} @update={{this.setStringValue f.setValue}} @disabled={{@disabled}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n\n {{#if (has-block \"rules\")}}\n <f.Rules as |Rule|>\n {{yield Rule to=\"rules\"}}\n </f.Rules>\n {{/if}}\n </this.Field>\n ", {
|
|
359
|
+
strictMode: true,
|
|
360
|
+
scope: () => ({
|
|
361
|
+
PhoneInput,
|
|
362
|
+
asString,
|
|
363
|
+
manageValidation
|
|
364
|
+
})
|
|
365
|
+
}), this);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
class RangeField extends Component {
|
|
370
|
+
Field = this.args.Field;
|
|
371
|
+
setNumberValue = setValue => {
|
|
372
|
+
return value => setValue(value);
|
|
373
|
+
};
|
|
374
|
+
static {
|
|
375
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <RangeInput @value={{asNumber f.value}} @update={{this.setNumberValue f.setValue}} @disabled={{@disabled}} @orientation={{@orientation}} @min={{@min}} @max={{@max}} @step={{@step}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n </this.Field>\n ", {
|
|
376
|
+
strictMode: true,
|
|
377
|
+
scope: () => ({
|
|
378
|
+
RangeInput,
|
|
379
|
+
asNumber,
|
|
380
|
+
manageValidation
|
|
381
|
+
})
|
|
382
|
+
}), this);
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
class SelectField extends Component {
|
|
387
|
+
Field = this.args.Field;
|
|
388
|
+
setValue = setValue => {
|
|
389
|
+
return value => setValue(value);
|
|
390
|
+
};
|
|
391
|
+
static {
|
|
392
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <Select @value={{asString f.value}} @update={{this.setValue f.setValue}} @disabled={{@disabled}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes as |s|>\n {{yield s}}\n </Select>\n </this.Field>\n ", {
|
|
393
|
+
strictMode: true,
|
|
394
|
+
scope: () => ({
|
|
395
|
+
Select,
|
|
396
|
+
asString,
|
|
397
|
+
manageValidation
|
|
398
|
+
})
|
|
399
|
+
}), this);
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
403
|
+
class Option extends Component {
|
|
404
|
+
select = () => {
|
|
405
|
+
this.args.field.setValue(this.args.value);
|
|
406
|
+
};
|
|
407
|
+
static {
|
|
408
|
+
setComponentTemplate(precompileTemplate("\n {{#let (uniqueId) as |id|}}\n <div class={{styles.choice}} data-test-option>\n <span>\n <Radio @value={{eq @field.value @value}} @update={{this.select}} @disabled={{@disabled}} id={{id}} name={{@name}} value={{@value}} {{@field.registerElement}} ...attributes />\n </span>\n\n <div>\n <Label for={{id}}>{{@label}}</Label>\n\n {{#if @description}}\n <Description>{{@description}}</Description>\n {{/if}}\n\n {{yield}}\n </div>\n </div>\n {{/let}}\n ", {
|
|
409
|
+
strictMode: true,
|
|
410
|
+
scope: () => ({
|
|
411
|
+
uniqueId,
|
|
412
|
+
styles,
|
|
413
|
+
Radio,
|
|
414
|
+
eq,
|
|
415
|
+
Label,
|
|
416
|
+
Description
|
|
417
|
+
})
|
|
418
|
+
}), this);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
class SingularChoiceField extends Component {
|
|
422
|
+
Field = this.args.Field;
|
|
423
|
+
Option = Option;
|
|
424
|
+
static {
|
|
425
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @element={{element \"fieldset\"}} @labelComponent={{component Label element=(element \"legend\")}} @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <div class={{styles.choices}} data-test-choices>\n {{yield (hash Option=(component this.Option field=f name=@name disabled=@disabled))}}\n </div>\n </this.Field>\n ", {
|
|
426
|
+
strictMode: true,
|
|
427
|
+
scope: () => ({
|
|
428
|
+
element,
|
|
429
|
+
Label,
|
|
430
|
+
styles,
|
|
431
|
+
hash
|
|
432
|
+
})
|
|
433
|
+
}), this);
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
class TextField extends Component {
|
|
438
|
+
Field = this.args.Field;
|
|
439
|
+
setStringValue = setValue => {
|
|
440
|
+
return value => setValue(value);
|
|
441
|
+
};
|
|
442
|
+
static {
|
|
443
|
+
setComponentTemplate(precompileTemplate("\n <@Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <TextInput @value={{asString f.value}} @update={{this.setStringValue f.setValue}} @disabled={{@disabled}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n\n {{#if (has-block \"rules\")}}\n <f.Rules as |Rule|>\n {{yield Rule to=\"rules\"}}\n </f.Rules>\n {{/if}}\n </@Field>\n ", {
|
|
444
|
+
strictMode: true,
|
|
445
|
+
scope: () => ({
|
|
446
|
+
TextInput,
|
|
447
|
+
asString,
|
|
448
|
+
manageValidation
|
|
449
|
+
})
|
|
450
|
+
}), this);
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
class TextAreaField extends Component {
|
|
455
|
+
Field = this.args.Field;
|
|
456
|
+
setStringValue = setValue => {
|
|
457
|
+
return value => setValue(value);
|
|
458
|
+
};
|
|
459
|
+
static {
|
|
460
|
+
setComponentTemplate(precompileTemplate("\n <this.Field @name={{@name}} @label={{@label}} @description={{@description}} @value={{@value}} @ignoreNativeValidation={{@ignoreNativeValidation}} @validateOn={{@validateOn}} @revalidateOn={{@revalidateOn}} @validate={{@validate}} @validated={{@validated}} as |f|>\n <TextArea @value={{asString f.value}} @update={{this.setStringValue f.setValue}} @disabled={{@disabled}} name={{@name}} id={{f.id}} {{f.registerElement}} {{manageValidation errorMessageId=f.errorId invalid=f.invalid showErrors=f.showErrors}} ...attributes />\n </this.Field>\n ", {
|
|
461
|
+
strictMode: true,
|
|
462
|
+
scope: () => ({
|
|
463
|
+
TextArea,
|
|
464
|
+
asString,
|
|
465
|
+
manageValidation
|
|
466
|
+
})
|
|
467
|
+
}), this);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
const Reset = setComponentTemplate(precompileTemplate("\n <button type=\"reset\" class={{styles.button}} data-intent={{if @intent @intent \"action\"}} data-importance={{if @importance @importance \"supreme\"}} data-spacing={{@spacing}} {{disabled when=(if @disabled @disabled false)}} data-test-button ...attributes>\n {{#if (has-block \"before\")}}\n <span data-test-button=\"before\">\n {{yield to=\"before\"}}\n </span>\n {{/if}}\n\n <span data-test-button=\"label\">\n {{#if (has-block \"label\")}}\n {{yield to=\"label\"}}\n {{/if}}\n\n {{#if (has-block)}}\n {{yield}}\n {{/if}}\n </span>\n\n {{#if (has-block \"after\")}}\n <span data-test-button=\"after\">\n {{yield to=\"after\"}}\n </span>\n {{/if}}\n </button>\n", {
|
|
472
|
+
strictMode: true,
|
|
473
|
+
scope: () => ({
|
|
474
|
+
styles: styles$1,
|
|
475
|
+
disabled
|
|
476
|
+
})
|
|
477
|
+
}), templateOnly());
|
|
478
|
+
|
|
479
|
+
const Submit = setComponentTemplate(precompileTemplate("\n <button type=\"submit\" class={{styles.button}} data-intent={{if @intent @intent \"action\"}} data-importance={{if @importance @importance \"supreme\"}} data-spacing={{@spacing}} {{disabled when=(if @disabled @disabled false)}} data-test-button ...attributes>\n {{#if (has-block \"before\")}}\n <span data-test-button=\"before\">\n {{yield to=\"before\"}}\n </span>\n {{/if}}\n\n <span data-test-button=\"label\">\n {{#if (has-block \"label\")}}\n {{yield to=\"label\"}}\n {{/if}}\n\n {{#if (has-block)}}\n {{yield}}\n {{/if}}\n </span>\n\n {{#if (has-block \"after\")}}\n <span data-test-button=\"after\">\n {{yield to=\"after\"}}\n </span>\n {{/if}}\n </button>\n", {
|
|
480
|
+
strictMode: true,
|
|
481
|
+
scope: () => ({
|
|
482
|
+
styles: styles$1,
|
|
483
|
+
disabled
|
|
484
|
+
})
|
|
485
|
+
}), templateOnly());
|
|
486
|
+
|
|
487
|
+
class Form extends Component {
|
|
488
|
+
Field = Field;
|
|
489
|
+
CheckboxField = CheckboxField;
|
|
490
|
+
CurrencyField = CurrencyField;
|
|
491
|
+
DateField = DateField;
|
|
492
|
+
EmailField = EmailField;
|
|
493
|
+
ListField = ListField;
|
|
494
|
+
MultipleChoiceField = MultipleChoiceField;
|
|
495
|
+
NumberField = NumberField;
|
|
496
|
+
PasswordField = PasswordField;
|
|
497
|
+
PhoneField = PhoneField;
|
|
498
|
+
RangeField = RangeField;
|
|
499
|
+
SelectField = SelectField;
|
|
500
|
+
SingularChoiceField = SingularChoiceField;
|
|
501
|
+
TextAreaField = TextAreaField;
|
|
502
|
+
TextField = TextField;
|
|
503
|
+
static {
|
|
504
|
+
setComponentTemplate(precompileTemplate("\n {{#let (createForm data=@data ignoreNativeValidation=@ignoreNativeValidation validateOn=@validateOn revalidateOn=@revalidateOn submit=@submit validate=@validate validated=@validated) as |f|}}\n <form novalidate class={{styles.form}} data-test-form ...attributes {{f.registerElement}}>\n {{#let (component this.Field form=f) as |WiredField|}}\n {{yield (hash invalid=f.invalid submit=f.submit Field=WiredField Checkbox=(component this.CheckboxField Field=WiredField) Currency=(component this.CurrencyField Field=WiredField) Date=(component this.DateField Field=WiredField) Email=(component this.EmailField Field=WiredField) List=(component this.ListField Field=WiredField) MultipleChoice=(component this.MultipleChoiceField Field=WiredField) Number=(component this.NumberField Field=WiredField) Password=(component this.PasswordField Field=WiredField) Phone=(component this.PhoneField Field=WiredField) Range=(component this.RangeField Field=WiredField) Select=(component this.SelectField Field=WiredField) SingularChoice=(component this.SingularChoiceField Field=WiredField) TextArea=(component this.TextAreaField Field=WiredField) Text=(component this.TextField Field=WiredField) Submit=Submit Reset=Reset form=f)}}\n {{/let}}\n </form>\n {{/let}}\n ", {
|
|
505
|
+
strictMode: true,
|
|
506
|
+
scope: () => ({
|
|
507
|
+
createForm,
|
|
508
|
+
styles,
|
|
509
|
+
hash,
|
|
510
|
+
Submit,
|
|
511
|
+
Reset
|
|
512
|
+
})
|
|
513
|
+
}), this);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
export { Form as F };
|
|
518
|
+
//# sourceMappingURL=form-DBuzL4_0.js.map
|