@ebrains/components 1.1.0 → 1.2.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.
@@ -1,4 +1,4 @@
1
- import { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client';
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { d as defineCustomElement$7 } from './eds-icon-wrapper2.js';
3
3
  import { d as defineCustomElement$6 } from './eds-input2.js';
4
4
  import { d as defineCustomElement$5 } from './eds-input-footer2.js';
@@ -15,39 +15,29 @@ const EdsInputField = /*@__PURE__*/ proxyCustomElement(class EdsInputField exten
15
15
  super();
16
16
  this.__registerHost();
17
17
  this.__attachShadow();
18
+ this.edsinput = createEvent(this, "edsinput", 7);
19
+ this.edschange = createEvent(this, "edschange", 7);
18
20
  this.handleNativeInput = (ev) => {
19
21
  var _a;
20
- // 1) Call any passed-in handler
21
22
  (_a = this.onInput) === null || _a === void 0 ? void 0 : _a.call(this, ev);
22
23
  if (this.shouldEmitValue()) {
23
- // 2) Re-emit on host so Vue/others can catch it
24
24
  const newValue = ev.target.value;
25
- this.hostEl.dispatchEvent(new CustomEvent('oninput', {
26
- detail: { value: newValue },
27
- bubbles: false,
28
- composed: true
29
- }));
25
+ this.edsinput.emit({ value: newValue });
30
26
  }
31
27
  };
32
28
  this.handleNativeChange = (ev) => {
33
29
  var _a;
34
- (_a = this.onChange) === null || _a === void 0 ? void 0 : _a.call(this, ev);
30
+ (_a = this.onChangeNative) === null || _a === void 0 ? void 0 : _a.call(this, ev);
35
31
  if (this.shouldEmitValue()) {
36
32
  const target = ev.target;
37
- this.hostEl.dispatchEvent(new CustomEvent('onchange', {
38
- detail: { value: target.value },
39
- bubbles: false,
40
- composed: true
41
- }));
33
+ const value = target.value;
34
+ this.edschange.emit({ value });
42
35
  }
43
36
  };
44
37
  this.name = undefined;
45
38
  this.inputId = undefined;
46
39
  this.placeholder = undefined;
47
40
  this.disabled = false;
48
- this.onChange = undefined;
49
- this.onInput = undefined;
50
- this.type = 'text';
51
41
  this.required = false;
52
42
  this.label = undefined;
53
43
  this.hint = undefined;
@@ -60,22 +50,22 @@ const EdsInputField = /*@__PURE__*/ proxyCustomElement(class EdsInputField exten
60
50
  this.value = undefined;
61
51
  this.maxLength = undefined;
62
52
  this.options = undefined;
53
+ this.type = 'text';
54
+ this.onChangeNative = undefined;
55
+ this.onInput = undefined;
63
56
  this.exposeValueEvents = true;
64
57
  }
65
58
  shouldEmitValue() {
66
- // Never emit for password fields, and respect the exposeValueEvents prop
67
59
  return this.exposeValueEvents && this.type !== 'password';
68
60
  }
69
61
  get parsedOptions() {
70
- if (Array.isArray(this.options)) {
62
+ if (Array.isArray(this.options))
71
63
  return this.options;
72
- }
73
- else if (typeof this.options === 'string') {
64
+ if (typeof this.options === 'string') {
74
65
  try {
75
66
  return JSON.parse(this.options);
76
67
  }
77
68
  catch (_a) {
78
- // eslint-disable-next-line
79
69
  console.warn('Invalid options format');
80
70
  return [];
81
71
  }
@@ -97,7 +87,8 @@ const EdsInputField = /*@__PURE__*/ proxyCustomElement(class EdsInputField exten
97
87
  icon: this.icon,
98
88
  checked: this.checked
99
89
  };
100
- return (h("div", { key: 'e46f1b26212ee915c2fde3fa0c58a152005d2b50', class: "space-y-8" }, this.type === 'checkbox' || this.type === 'radio' ? (this.parsedOptions.length > 0 ? (h("fieldset", { class: "space-y-4 mt-8" }, h("div", { class: "flex justify-between" }, this.label && (h("eds-input-label", { name: this.inputId || this.name, label: this.label, required: this.required })), this.hint && (h("p", { id: `${this.name}-hint`, class: "f-ui-05 text-lighter mt-8 ml-8" }, this.hint))), this.parsedOptions.map((option) => (h("div", { class: "flex items-center gap-x-2", key: option.value }, h("eds-input", Object.assign({}, inputOpts, { value: option.value, checked: (typeof this.value === 'string' ? this.value.split(',') : []).includes(String(option.value)) })), h("eds-input-label", { name: `${this.name}-${option.value}`, label: option.label })))))) : (h("div", { class: "flex items-center gap-x-8" }, h("eds-input", Object.assign({}, inputOpts, { value: this.value, checked: this.value === 'on' })), this.label && (h("eds-input-label", { name: this.inputId || this.name, label: this.label, disabled: this.disabled, required: this.required }))))) : (h("div", null, h("div", { class: "flex justify-between" }, this.label && (h("eds-input-label", { name: this.inputId || this.name, label: this.label, disabled: this.disabled, required: this.required })), this.hint && (h("p", { id: `${this.name}-hint`, class: "f-ui-05 text-lighter mt-8 ml-8" }, this.hint))), this.type === 'select' ? (h("eds-input-select", Object.assign({}, inputOpts, { options: this.parsedOptions }))) : this.type === 'file' ? (h("input", { type: "file", id: this.inputId || this.name, name: this.name, onChange: this.onChange, disabled: this.disabled, required: this.required })) : this.type === 'search' ? (h("eds-input-search", { name: "search-box" })) : this.type === 'range' ? ((() => {
90
+ return (h("div", { key: '2ff82dedd17922c5cb72fc30b7f616c7fafa7b07', class: "space-y-8" }, this.type === 'checkbox' || this.type === 'radio' ? (this.parsedOptions.length > 0 ? (h("fieldset", { class: "space-y-4 mt-8" }, h("div", { class: "flex justify-between" }, this.label && (h("eds-input-label", { name: this.inputId || this.name, label: this.label, required: this.required })), this.hint && (h("p", { id: `${this.name}-hint`, class: "f-ui-05 text-lighter mt-8 ml-8" }, this.hint))), this.parsedOptions.map((option) => (h("div", { class: "flex items-center gap-x-2", key: option.value }, h("eds-input", Object.assign({}, inputOpts, { value: option.value, checked: typeof this.value === 'string' &&
91
+ this.value.split(',').includes(String(option.value)) })), h("eds-input-label", { name: `${this.name}-${option.value}`, label: option.label })))))) : (h("div", { class: "flex items-center gap-x-8" }, h("eds-input", Object.assign({}, inputOpts, { value: this.value, checked: this.value === 'on' })), this.label && (h("eds-input-label", { name: this.inputId || this.name, label: this.label, disabled: this.disabled, required: this.required }))))) : (h("div", null, h("div", { class: "flex justify-between" }, this.label && (h("eds-input-label", { name: this.inputId || this.name, label: this.label, disabled: this.disabled, required: this.required })), this.hint && (h("p", { id: `${this.name}-hint`, class: "f-ui-05 text-lighter mt-8 ml-8" }, this.hint))), this.type === 'select' ? (h("eds-input-select", Object.assign({}, inputOpts, { options: this.parsedOptions }))) : this.type === 'file' ? (h("input", { type: "file", id: this.inputId || this.name, name: this.name, onChange: this.onChangeNative, disabled: this.disabled, required: this.required })) : this.type === 'search' ? (h("eds-input-search", { name: "search-box" })) : this.type === 'range' ? ((() => {
101
92
  var _a, _b, _c;
102
93
  const rangeProps = {
103
94
  name: inputOpts.name,
@@ -110,7 +101,7 @@ const EdsInputField = /*@__PURE__*/ proxyCustomElement(class EdsInputField exten
110
101
  const opt = this.parsedOptions;
111
102
  const numberValue = typeof this.value === 'string' ? parseFloat(this.value) : this.value || 0;
112
103
  return (h("eds-input-range", Object.assign({}, rangeProps, { min: (_a = opt[0]) === null || _a === void 0 ? void 0 : _a.value, max: (_b = opt[1]) === null || _b === void 0 ? void 0 : _b.value, step: (_c = opt[2]) === null || _c === void 0 ? void 0 : _c.value, value: numberValue })));
113
- })()) : (h("eds-input", Object.assign({}, inputOpts))))), h("eds-input-footer", { key: 'ecf3ee5c0400749f1d89b53edfdee6fe62ca2a32', id: `${this.name}-footer`, name: this.name, message: this.message, "error-message": this.errorMessage, error: this.error, link: this.link })));
104
+ })()) : (h("eds-input", Object.assign({}, inputOpts))))), h("eds-input-footer", { key: '4b8513dcd713d56953934b158ba1b9182e1497a8', id: `${this.name}-footer`, name: this.name, message: this.message, "error-message": this.errorMessage, error: this.error, link: this.link })));
114
105
  }
115
106
  get hostEl() { return this; }
116
107
  static get style() { return EdsInputFieldStyle0; }
@@ -119,9 +110,6 @@ const EdsInputField = /*@__PURE__*/ proxyCustomElement(class EdsInputField exten
119
110
  "inputId": [1, "input-id"],
120
111
  "placeholder": [1],
121
112
  "disabled": [4],
122
- "onChange": [16],
123
- "onInput": [16],
124
- "type": [1],
125
113
  "required": [4],
126
114
  "label": [1],
127
115
  "hint": [1],
@@ -134,6 +122,9 @@ const EdsInputField = /*@__PURE__*/ proxyCustomElement(class EdsInputField exten
134
122
  "value": [8],
135
123
  "maxLength": [2, "max-length"],
136
124
  "options": [1],
125
+ "type": [1],
126
+ "onChangeNative": [16],
127
+ "onInput": [16],
137
128
  "exposeValueEvents": [4, "expose-value-events"]
138
129
  }]);
139
130
  function defineCustomElement() {