@muonic/muon 0.0.2-beta.50 → 0.0.2-beta.52

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/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [0.0.2-beta.52](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.50...v0.0.2-beta.52) (2024-01-08)
6
+
7
+
8
+ ### Features
9
+
10
+ * update background-size property name ([b51dead](https://github.com/centrica-engineering/muon/commit/b51deadbe7786111f93d4e8ac5f2716c150b868f))
11
+ * update property name ([4fbaadd](https://github.com/centrica-engineering/muon/commit/4fbaadddcd722c9642710b50a35bc0daea6b45d9))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * add full stop if not there ([894a7e5](https://github.com/centrica-engineering/muon/commit/894a7e528757ed6fde26025d1672a8be97eedc54))
17
+ * update validation in date inputter ([c150172](https://github.com/centrica-engineering/muon/commit/c15017272b64130aa5e8e2a51cb083ad83795ac7))
18
+
19
+ ### [0.0.2-beta.51](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.49...v0.0.2-beta.51) (2023-12-06)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * add full stop if not there ([894a7e5](https://github.com/centrica-engineering/muon/commit/894a7e528757ed6fde26025d1672a8be97eedc54))
25
+ * remove console log ([e84aa7d](https://github.com/centrica-engineering/muon/commit/e84aa7dfb66b9ab5d760b190c6cbce8d3ac3839f))
26
+
5
27
  ### [0.0.2-beta.50](https://github.com/centrica-engineering/muon/compare/v0.0.2-beta.48...v0.0.2-beta.50) (2023-12-04)
6
28
 
7
29
 
@@ -18,16 +18,35 @@ export class Card extends ScopedElementsMixin(ImageHolderMixin(CardMixin(MuonEle
18
18
  };
19
19
  }
20
20
 
21
+ static get styles() {
22
+ return styles;
23
+ }
24
+
25
+ /**
26
+ * Getter method to construct classes object.
27
+ * @protected
28
+ * @returns {object} - Classes object to be included in the template.
29
+ */
21
30
  get classes() {
22
31
  return {
23
32
  card: true
24
33
  };
25
34
  }
26
35
 
36
+ /**
37
+ * Getter method to construct styles object.
38
+ * @protected
39
+ * @returns {object} - Styles object to be included in the template.
40
+ */
27
41
  get inlineStyles() {
28
42
  return {};
29
43
  }
30
44
 
45
+ /**
46
+ * Getter method to construct card image template.
47
+ * @protected
48
+ * @returns {object} TemplateResult - Image template.
49
+ */
31
50
  get _addImage() {
32
51
  return this.image ? html`
33
52
  <div class="media">
@@ -35,6 +54,11 @@ export class Card extends ScopedElementsMixin(ImageHolderMixin(CardMixin(MuonEle
35
54
  </div>` : undefined;
36
55
  }
37
56
 
57
+ /**
58
+ * Getter method to construct template for type `standard`.
59
+ * @protected
60
+ * @returns {object} TemplateResult - Template to render.
61
+ */
38
62
  get standardTemplate() {
39
63
  return html`
40
64
  <div class="${classMap(this.classes)}" style="${styleMap(this.inlineStyles)}">
@@ -47,8 +71,4 @@ export class Card extends ScopedElementsMixin(ImageHolderMixin(CardMixin(MuonEle
47
71
  </div>
48
72
  `;
49
73
  }
50
-
51
- static get styles() {
52
- return styles;
53
- }
54
74
  }
@@ -49,6 +49,11 @@ export class Cta extends ScopedElementsMixin(MuonElement) {
49
49
  this.icon = CTA_ICON_NAME;
50
50
  }
51
51
 
52
+ /**
53
+ * Getter method to construct classes object.
54
+ * @protected
55
+ * @returns {object} - Classes object to be included in the template.
56
+ */
52
57
  get classes() {
53
58
  const parentElement = this.parentElement;
54
59
  const isDisabled = parentElement?.getAttribute('disabled') || this.disabled;
@@ -61,6 +66,11 @@ export class Cta extends ScopedElementsMixin(MuonElement) {
61
66
  };
62
67
  }
63
68
 
69
+ /**
70
+ * Getter method to construct styles object.
71
+ * @protected
72
+ * @returns {object} - Styles object to be included in the template.
73
+ */
64
74
  get inlineStyles() {
65
75
  return {};
66
76
  }
@@ -159,6 +169,11 @@ export class Cta extends ScopedElementsMixin(MuonElement) {
159
169
  `;
160
170
  }
161
171
 
172
+ /**
173
+ * Getter method to construct template for type `standard`.
174
+ * @protected
175
+ * @returns {object} TemplateResult - Template to render.
176
+ */
162
177
  get standardTemplate() {
163
178
  const isLoading = this.loading;
164
179
  const iconAdd = this._addIcon;
@@ -179,12 +194,22 @@ export class Cta extends ScopedElementsMixin(MuonElement) {
179
194
  `;
180
195
  }
181
196
 
197
+ /**
198
+ * Getter method to construct template for type `submit`.
199
+ * @protected
200
+ * @returns {object} TemplateResult - Template to render.
201
+ */
182
202
  get submitTemplate() {
183
203
  this.setAttribute('type', 'submit');
184
204
 
185
205
  return this.standardTemplate;
186
206
  }
187
207
 
208
+ /**
209
+ * Getter method to construct template for type `reset`.
210
+ * @protected
211
+ * @returns {object} TemplateResult - Template to render.
212
+ */
188
213
  get resetTemplate() {
189
214
  this.setAttribute('type', 'reset');
190
215
 
@@ -10,16 +10,16 @@ import styles from './form-styles.css';
10
10
 
11
11
  export class Form extends MuonElement {
12
12
 
13
+ static get styles() {
14
+ return styles;
15
+ }
16
+
13
17
  constructor() {
14
18
  super();
15
19
  this._submit = this._submit.bind(this);
16
20
  this._reset = this._reset.bind(this);
17
21
  }
18
22
 
19
- static get styles() {
20
- return styles;
21
- }
22
-
23
23
  connectedCallback() {
24
24
  super.connectedCallback();
25
25
 
@@ -201,6 +201,11 @@ export class Form extends MuonElement {
201
201
  };
202
202
  }
203
203
 
204
+ /**
205
+ * Getter method to construct template for type `standard`.
206
+ * @protected
207
+ * @returns {object} TemplateResult - Template to render.
208
+ */
204
209
  get standardTemplate() {
205
210
  return html`
206
211
  <slot></slot>
@@ -61,7 +61,7 @@ Standard.args = {
61
61
  ...InputterStories.DateMask.args,
62
62
  name: 'dob',
63
63
  label: 'Date of birth',
64
- validation: ['maxDate(\'031/12/2022\')']
64
+ validation: ['maxDate("31/12/2022")']
65
65
  },
66
66
  Submit: {
67
67
  ...SubmitCTA.args,
@@ -24,7 +24,8 @@ export class Icon extends MuonElement {
24
24
  describe: { type: String },
25
25
  size: { type: Number },
26
26
  category: { type: String },
27
- _url: { type: String, state: true }
27
+ _url: { type: String, state: true },
28
+ _allSizes: { type: Array, state: true }
28
29
  };
29
30
  }
30
31
 
@@ -38,11 +39,16 @@ export class Icon extends MuonElement {
38
39
  this.type = ICON_CONFIG_TYPE;
39
40
  this.name = ICON_CONFIG_NAME;
40
41
  this.category = ICON_CONFIG_CATEGORY;
41
- this.allSizes = ICON_CONFIG_SIZES;
42
+ this._allSizes = ICON_CONFIG_SIZES;
42
43
  this._url = ICON_CONFIG_URL;
43
44
  this.describe = '';
44
45
  }
45
46
 
47
+ /**
48
+ * Getter method to construct classes object.
49
+ * @protected
50
+ * @returns {object} - Classes object to be included in the template.
51
+ */
46
52
  get classes() {
47
53
  return {
48
54
  icon: true,
@@ -50,6 +56,11 @@ export class Icon extends MuonElement {
50
56
  };
51
57
  }
52
58
 
59
+ /**
60
+ * Getter method to construct styles object.
61
+ * @protected
62
+ * @returns {object} - Styles object to be included in the template.
63
+ */
53
64
  get inlineStyles() {
54
65
  return {
55
66
  '--icon-size': this.iconSize
@@ -57,17 +68,23 @@ export class Icon extends MuonElement {
57
68
  }
58
69
 
59
70
  /**
60
- * A getter method to get size of image.
71
+ * A getter method to get size of icon.
61
72
  *
62
73
  * @returns {number | string} - Size at specific index or 100%.
74
+ * @protected
63
75
  * @readonly
64
76
  */
65
77
  get sizes() {
66
78
  const size = this.size - 1;
67
79
 
68
- return this.allSizes[size] || '100%';
80
+ return this._allSizes[size] || '100%';
69
81
  }
70
82
 
83
+ /**
84
+ * Getter method to get size od icon in percentage or pixels.
85
+ * @protected
86
+ * @returns {string} - Icon size in percentage or pixels.
87
+ */
71
88
  get iconSize() {
72
89
  const computedSize = this.sizes;
73
90
  const size = computedSize === '100%' ? computedSize : `${computedSize}px`;
@@ -75,6 +92,11 @@ export class Icon extends MuonElement {
75
92
  return size;
76
93
  }
77
94
 
95
+ /**
96
+ * Getter method to construct template for type `standard`.
97
+ * @protected
98
+ * @returns {object} TemplateResult - Template to render.
99
+ */
78
100
  get standardTemplate() {
79
101
  const hidden = this.describe?.length === 0 ? 'true' : undefined;
80
102
  const role = !hidden ? 'img' : undefined;
@@ -20,7 +20,7 @@ export class Image extends MuonElement {
20
20
  static get properties() {
21
21
  return {
22
22
  background: { type: Boolean },
23
- backgroundsize: { type: String, attribute: 'background-size' },
23
+ backgroundSize: { type: String, attribute: 'background-size' },
24
24
  src: { type: String },
25
25
  alt: { type: String },
26
26
  ratio: { type: String },
@@ -39,7 +39,7 @@ export class Image extends MuonElement {
39
39
 
40
40
  this.type = IMAGE_CONFIG_TYPE;
41
41
  this.background = false;
42
- this.backgroundsize = 'cover'; // cover, contain
42
+ this.backgroundSize = 'cover'; // cover, contain
43
43
  this.alt = '';
44
44
  this.ratio = IMAGE_CONFIG_RATIO;
45
45
  this.placeholder = IMAGE_CONFIG_PLACEHOLDER;
@@ -47,6 +47,11 @@ export class Image extends MuonElement {
47
47
  this._ratios = IMAGE_CONFIG_RATIOS;
48
48
  }
49
49
 
50
+ /**
51
+ * Getter method to construct classes object.
52
+ * @protected
53
+ * @returns {object} - Classes object to be included in the template.
54
+ */
50
55
  get classes() {
51
56
  return {
52
57
  image: true,
@@ -55,19 +60,34 @@ export class Image extends MuonElement {
55
60
  };
56
61
  }
57
62
 
63
+ /**
64
+ * Getter method to construct styles object.
65
+ * @protected
66
+ * @returns {object} - Styles object to be included in the template.
67
+ */
58
68
  get inlineStyles() {
59
69
  const [x, y] = this.ratio.split(' / ');
60
70
  return {
61
71
  '--image-ratio': CSS?.supports('aspect-ratio', '1 / 1') && this.ratio ? this.ratio : undefined,
62
72
  '--image-padding': CSS?.supports('aspect-ratio', '1 / 1') || !x && !y ? undefined : `${y / x * 100}%`,
63
- '--background-size': this.background ? this.backgroundsize : undefined
73
+ '--background-size': this.background ? this.backgroundSize : undefined
64
74
  };
65
75
  }
66
76
 
77
+ /**
78
+ * Getter method to construct placeholder image file name.
79
+ * @protected
80
+ * @returns {string} - Placeholder image.
81
+ */
67
82
  get placeholderImage() {
68
83
  return this.placeholder.replace('(src)', this.src); // @TODO: test alternative ways for this
69
84
  }
70
85
 
86
+ /**
87
+ * Getter method to construct template for type `standard`.
88
+ * @protected
89
+ * @returns {object} TemplateResult - Template to render.
90
+ */
71
91
  get standardTemplate() {
72
92
  const isBackground = this.background;
73
93
 
@@ -47,6 +47,11 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
47
47
  return styles;
48
48
  }
49
49
 
50
+ /**
51
+ * Getter method to construct classes object.
52
+ * @protected
53
+ * @returns {object} - Classes object to be included in the template.
54
+ */
50
55
  get classes() {
51
56
  const type = this._isSingle && this.querySelector('input')?.type;
52
57
  const autocomplete = this._isSingle && this.querySelector('input')?.autocomplete || undefined;
@@ -65,6 +70,11 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
65
70
  };
66
71
  }
67
72
 
73
+ /**
74
+ * Getter method to construct styles object.
75
+ * @protected
76
+ * @returns {object} - Styles object to be included in the template.
77
+ */
68
78
  get inlineStyles() {
69
79
  if (this.mask) {
70
80
  return {
@@ -199,6 +209,11 @@ export class Inputter extends ScopedElementsMixin(ValidationMixin(MaskMixin(Muon
199
209
  return false;
200
210
  }
201
211
 
212
+ /**
213
+ * Getter method to construct template for type `standard`.
214
+ * @protected
215
+ * @returns {object} TemplateResult - Template to render.
216
+ */
202
217
  get standardTemplate() {
203
218
  return html`
204
219
  <div class="${classMap(this.classes)}" style="${styleMap(this.inlineStyles)}">
@@ -107,7 +107,7 @@ Date.args = {
107
107
  label: 'Date',
108
108
  value: '',
109
109
  placeholder: '',
110
- validation: ['isRequired', 'minDate(\'01/01/2022\')']
110
+ validation: ['isRequired', 'minDate("01/01/2022")']
111
111
  };
112
112
 
113
113
  export const DateMask = InputterStandardTemplate.bind({});
@@ -118,7 +118,7 @@ DateMask.args = {
118
118
  placeholder: '',
119
119
  mask: 'dd/mm/yyyy',
120
120
  separator: '/',
121
- validation: ['isRequired', 'minDate(\'01/01/2022\')']
121
+ validation: ['isRequired', 'minDate("01/01/2022")']
122
122
  };
123
123
 
124
124
  export const Mask = InputterStandardTemplate.bind({});
@@ -50,6 +50,11 @@ export const DetailMixin = dedupeMixin((superClass) =>
50
50
  this._toggleEvent = 'detail-toggle';
51
51
  }
52
52
 
53
+ /**
54
+ * Getter method to construct classes object.
55
+ * @protected
56
+ * @returns {object} - Classes object to be included in the template.
57
+ */
53
58
  get classes() {
54
59
  return {
55
60
  details: true,
@@ -59,6 +64,11 @@ export const DetailMixin = dedupeMixin((superClass) =>
59
64
  };
60
65
  }
61
66
 
67
+ /**
68
+ * Getter method to construct styles object.
69
+ * @protected
70
+ * @returns {object} - Styles object to be included in the template.
71
+ */
62
72
  get inlineStyles() {
63
73
  return {};
64
74
  }
@@ -82,6 +92,11 @@ export const DetailMixin = dedupeMixin((superClass) =>
82
92
  }));
83
93
  }
84
94
 
95
+ /**
96
+ * Getter method to construct template for type `standard`.
97
+ * @protected
98
+ * @returns {object} TemplateResult - Template to render.
99
+ */
85
100
  get standardTemplate() {
86
101
  return html`
87
102
  <details class=${classMap(this.classes)} style=${styleMap(this.inlineStyles)} ?open="${this.open}" @toggle="${this._onToggle}">
@@ -52,6 +52,7 @@ export const ValidationMixin = dedupeMixin((superClass) =>
52
52
  *
53
53
  * @returns {boolean} - Pristine state.
54
54
  * @public
55
+ * @readonly
55
56
  */
56
57
  get isPristine() {
57
58
  return this._pristine;
@@ -62,6 +63,7 @@ export const ValidationMixin = dedupeMixin((superClass) =>
62
63
  *
63
64
  * @returns {boolean} - Dirty state.
64
65
  * @public
66
+ * @readonly
65
67
  */
66
68
  get isDirty() {
67
69
  return !this._pristine;
@@ -71,6 +73,11 @@ export const ValidationMixin = dedupeMixin((superClass) =>
71
73
  return this.validity;
72
74
  }
73
75
 
76
+ /**
77
+ * A getter method to get validity of the form element.
78
+ * @returns {ValidityState} - Validity state of the form element.
79
+ * @readonly
80
+ */
74
81
  get validity() {
75
82
  this._pristine = false;
76
83
  return this.validate();
@@ -206,6 +213,10 @@ export const ValidationMixin = dedupeMixin((superClass) =>
206
213
  return this._validationState?.filter((state) => {
207
214
  return state?.value;
208
215
  }).map((state) => {
216
+ if (state.value.charAt(state.value.length - 1) === '.') {
217
+ return state.value;
218
+ }
219
+
209
220
  return state.value + '.';
210
221
  }).join(' ');
211
222
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@muonic/muon",
3
- "version": "0.0.2-beta.50",
3
+ "version": "0.0.2-beta.52",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -198,14 +198,14 @@ testRunner('sourceFilesAnalyzer', async (t) => {
198
198
 
199
199
  const components = ['muon-card', 'muon-cta', 'muon-detail', 'muon-form', 'muon-icon', 'muon-image', 'muon-inputter', 'inputter-detail'];
200
200
  const propertiesMap = {
201
- 'muon-card': ['classes', 'inlineStyles', 'standardTemplate', 'image', 'alt', 'background', 'type'],
202
- 'muon-cta': ['href', 'classes', 'inlineStyles', 'standardTemplate', 'submitTemplate', 'resetTemplate', 'loading', 'loadingMessage', 'disabled', 'icon', 'type'],
203
- 'muon-detail': ['icon', 'classes', 'inlineStyles', 'standardTemplate', 'open', 'type'],
204
- 'muon-form': ['standardTemplate', 'type'],
205
- 'muon-icon': ['size', 'classes', 'inlineStyles', 'sizes', 'iconSize', 'standardTemplate', 'name', 'category', 'allSizes', 'describe', 'type'],
206
- 'muon-image': ['src', 'classes', 'inlineStyles', 'placeholderImage', 'standardTemplate', 'background', 'backgroundsize', 'alt', 'ratio', 'placeholder', 'loading', 'type'],
207
- 'muon-inputter': ['helper', 'classes', 'inlineStyles', 'slottedStyles', 'isHelperOpen', 'isPristine', 'isDirty', 'validity', 'validationMessage', 'validation', 'disableNative', 'showMessage', 'name', 'value', 'labelID', 'heading', 'mask', 'separator', 'ignoreSeparator', 'type'],
208
- 'inputter-detail': ['icon', 'classes', 'inlineStyles', 'standardTemplate', 'open', 'type']
201
+ 'muon-card': ['image', 'alt', 'background', 'type'],
202
+ 'muon-cta': ['href', 'loading', 'loadingMessage', 'disabled', 'icon', 'type'],
203
+ 'muon-detail': ['icon', 'open', 'type'],
204
+ 'muon-form': ['type'],
205
+ 'muon-icon': ['size', 'name', 'category', 'describe', 'type'],
206
+ 'muon-image': ['src', 'background', 'backgroundSize', 'alt', 'ratio', 'placeholder', 'loading', 'type'],
207
+ 'muon-inputter': ['helper', 'slottedStyles', 'isHelperOpen', 'isPristine', 'isDirty', 'validity', 'validationMessage', 'validation', 'disableNative', 'showMessage', 'name', 'value', 'labelID', 'heading', 'mask', 'separator', 'ignoreSeparator', 'type'],
208
+ 'inputter-detail': ['icon', 'open', 'type']
209
209
  };
210
210
  t.deepEqual(jsonResult.tags?.map((tag) => tag.name).sort(), components.sort());
211
211
 
@@ -232,9 +232,9 @@ testRunner('sourceFilesAnalyzer with prefix override', async (t) => {
232
232
 
233
233
  const components = ['muon-cta', 'muon-inputter', 'inputter-detail', 'mnx-cta'];
234
234
  const propertiesMap = {
235
- 'muon-cta': ['href', 'classes', 'inlineStyles', 'standardTemplate', 'submitTemplate', 'resetTemplate', 'loading', 'loadingMessage', 'disabled', 'icon', 'type'],
236
- 'muon-inputter': ['helper', 'classes', 'inlineStyles', 'slottedStyles', 'isHelperOpen', 'isPristine', 'isDirty', 'validity', 'validationMessage', 'validation', 'disableNative', 'showMessage', 'name', 'value', 'labelID', 'heading', 'mask', 'separator', 'ignoreSeparator', 'type'],
237
- 'inputter-detail': ['icon', 'classes', 'inlineStyles', 'standardTemplate', 'open', 'type'],
235
+ 'muon-cta': ['href', 'loading', 'loadingMessage', 'disabled', 'icon', 'type'],
236
+ 'muon-inputter': ['helper', 'slottedStyles', 'isHelperOpen', 'isPristine', 'isDirty', 'validity', 'validationMessage', 'validation', 'disableNative', 'showMessage', 'name', 'value', 'labelID', 'heading', 'mask', 'separator', 'ignoreSeparator', 'type'],
237
+ 'inputter-detail': ['icon', 'open', 'type'],
238
238
  'mnx-cta': ['enabled', 'type']
239
239
  };
240
240
  t.deepEqual(jsonResult.tags?.map((tag) => tag.name).sort(), components.sort());
@@ -299,7 +299,7 @@ testRunner('sourceFilesAnalyzer single file', async (t) => {
299
299
 
300
300
  const components = ['muon-card'];
301
301
  const propertiesMap = {
302
- 'muon-card': ['classes', 'inlineStyles', 'standardTemplate', 'image', 'alt', 'background', 'type']
302
+ 'muon-card': ['image', 'alt', 'background', 'type']
303
303
  };
304
304
  t.deepEqual(jsonResult.tags?.map((tag) => tag.name), components);
305
305