barbican-reset 3.30.0 → 3.31.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/README.md CHANGED
@@ -2,154 +2,236 @@
2
2
 
3
3
  ## Introduction
4
4
 
5
- The Barbican Reset is an NPM module created to maintain consistency between the various digital projects run by the Barbican.
5
+ Barbican Reset is an NPM package that provides a shared design system for Barbican digital projects including SCSS utilities, Vue components, icons, animations, logos, and JS helpers.
6
6
 
7
7
  ## Contents
8
8
 
9
- 1. Setup
10
- 2. Component library
11
- 3. SCSS documentation
12
- 4. JS documentation
13
- 5. Pattern library
14
- 6. Font library
9
+ - [Barbican Reset](#barbican-reset)
10
+ - [Introduction](#introduction)
11
+ - [Contents](#contents)
12
+ - [1. Setup](#1-setup)
13
+ - [2. Component library](#2-component-library)
14
+ - [3. SCSS](#3-scss)
15
+ - [Full stylesheet](#full-stylesheet)
16
+ - [Individual stylesheets](#individual-stylesheets)
17
+ - [Mixins](#mixins)
18
+ - [SCSS documentation](#scss-documentation)
19
+ - [4. Icons](#4-icons)
20
+ - [5. Animations](#5-animations)
21
+ - [6. Logos](#6-logos)
22
+ - [7. Scripts](#7-scripts)
23
+ - [8. Pattern library](#8-pattern-library)
24
+ - [Setup](#setup)
25
+ - [New pages](#new-pages)
26
+ - [Extending layouts](#extending-layouts)
27
+ - [Including components (mixins)](#including-components-mixins)
28
+ - [9. Font library](#9-font-library)
15
29
 
16
30
  ## 1. Setup
17
31
 
18
- You can install the Barbican Reset into any project by running `npm i barbican-reset` inside your project root folder.
32
+ Install the package into any project:
19
33
 
20
- You can then manually import a component using `import { BrExample } from barbican-reset`
34
+ ```sh
35
+ npm i barbican-reset
36
+ ```
21
37
 
22
- #### SCSS Stylesheet
38
+ Import a component:
23
39
 
24
- Vue.js: `@import '~barbican-reset';`
40
+ ```js
41
+ import { BrAlert } from 'barbican-reset'
42
+ ```
25
43
 
26
- > Use the ~ in Vue.js to import assets from the project root
44
+ ## 2. Component library
27
45
 
28
- Drupal: `@import "../node_modules/barbican-reset/scss/index";`
46
+ The component library is **Vue 3 only**.
47
+
48
+ > Many components are registered globally within the Barbican ticketing app. Check `main.js` to see which are available without an additional import.
49
+
50
+ | Component | File |
51
+ | --------------------------- | ------------------------------- |
52
+ | `<br-alert>` | BrAlert.vue |
53
+ | `<br-anchor>` | BrAnchor.vue |
54
+ | `<br-button>` | BrButton.vue |
55
+ | `<br-card>` | BrCard.vue |
56
+ | `<br-card-body>` | BrCardBody.vue |
57
+ | `<br-card-subtitle>` | BrCardSubtitle.vue |
58
+ | `<br-card-tearoff>` | BrCardTearoff.vue |
59
+ | `<br-card-text>` | BrCardText.vue |
60
+ | `<br-card-title>` | BrCardTitle.vue |
61
+ | `<br-collapse-button>` | BrCollapse/Button.vue |
62
+ | `<br-collapse-content>` | BrCollapse/Content.vue |
63
+ | `<br-confirm-done>` | BrConfirmDone.vue |
64
+ | `<br-confirm-email>` | BrConfirmEmail.vue |
65
+ | `<br-container>` | BrContainer.vue |
66
+ | `<br-details>` | BrDetails.vue |
67
+ | `<br-footer-lower>` | BrFooterLower.vue |
68
+ | `<br-footer-upper>` | BrFooterUpper.vue |
69
+ | `<br-form-block>` | BrFormBlock.vue |
70
+ | `<br-form-checkbox>` | BrFormCheckbox.vue |
71
+ | `<br-form-checkbox-group>` | BrFormCheckboxGroup.vue |
72
+ | `<br-form-date>` | BrFormDate.vue |
73
+ | `<br-form-edit>` | BrFormEdit.vue |
74
+ | `<br-form-email>` | BrFormEmail.vue |
75
+ | `<br-form-fieldset>` | BrFormFieldset.vue |
76
+ | `<br-form-input>` | BrFormInput.vue |
77
+ | `<br-form-password>` | BrFormPassword.vue |
78
+ | `<br-form-radio>` | BrFormRadio.vue |
79
+ | `<br-form-radio-group>` | BrFormRadioGroup.vue |
80
+ | `<br-form-row>` | BrFormRow.vue |
81
+ | `<br-form-tel>` | BrFormTel.vue |
82
+ | `<br-form-textarea>` | BrFormTextarea.vue |
83
+ | `<br-form-toggle>` | BrFormToggle.vue |
84
+ | `<br-form-update>` | BrFormUpdate.vue |
85
+ | `<br-form-visible>` | BrFormVisible.vue |
86
+ | `<br-link>` | BrLink.vue |
87
+ | `<br-loader>` | BrLoader.vue |
88
+ | `<br-overlay>` | BrOverlay.vue |
89
+ | `<br-skiplink>` | BrSkiplink.vue |
90
+ | `<br-status-bars>` | BrStatusBars.vue |
91
+ | `<br-table-header>` | BrTableHeader.vue |
92
+ | `<br-wrap>` | BrWrap.vue |
93
+
94
+ > The `br-` prefix makes it immediately clear that a component is from Barbican Reset and not native to the app. It also ensures two-word component names, which is the recommended format for custom elements (e.g. `<br-header>` rather than `<header>`).
95
+
96
+ ## 3. SCSS
97
+
98
+ ### Full stylesheet
99
+
100
+ ```scss
101
+ // Vite / webpack (resolves from node_modules automatically)
102
+ @import 'barbican-reset/scss';
103
+
104
+ // Explicit node_modules path (e.g. Drupal)
105
+ @import '../node_modules/barbican-reset/scss';
106
+ ```
29
107
 
30
- Spektrix iframe development: `@import "../../node_modules/barbican-reset/scss/index.scss";`
108
+ ### Individual stylesheets
31
109
 
32
- #### SCSS Mixins
110
+ The package exposes several standalone stylesheets:
33
111
 
34
- Vue.js: `@import "~barbican-reset/scss/helpers";`
112
+ | Export | Description |
113
+ | ------------------------------- | ---------------------------------- |
114
+ | `barbican-reset/scss` | Full stylesheet |
115
+ | `barbican-reset/reset` | CSS reset only |
116
+ | `barbican-reset/typography` | Typography styles |
117
+ | `barbican-reset/lists` | List styles |
118
+ | `barbican-reset/supreme` | Supreme font styles |
35
119
 
36
- > The Barbican ticketing site makes SCSS mixins globally available via the `vue.config.js` file
120
+ ### Mixins
37
121
 
38
- Drupal: `@import "../node_modules/barbican-reset/scss/helpers/index";`
122
+ ```scss
123
+ // Vite / webpack
124
+ @import 'barbican-reset/scss/mixins';
39
125
 
40
- ## 2. Component library
126
+ // Explicit node_modules path
127
+ @import '../node_modules/barbican-reset/scss/mixins';
128
+ ```
41
129
 
42
- The component library is currently **only available to Vue.js** apps.
43
-
44
- > Many components are available globally within the Barbican ticketing app. Check the main.js file to see which components are currently available. These won't need an additional import statement.
45
-
46
- > When manually importing components into Vue.js, be sure to declare the import as a Vue component as well
47
-
48
- You can reference any of the following components:
49
-
50
- | Component | Filename | SCSS Class | SCSS Mixin | Previously |
51
- | -------------------- | ------------------- | -------------------- | ---------------- | ------------- |
52
- | `<br-alert>` | BrAlert.vue | .br-alert | br-alert--setup | - |
53
- | `<br-anchor>` | BrAnchor.vue | .btn | setup-button | - |
54
- | `<br-button>` | BrButton.vue | .br-form-checkbox | br-form-checkbox | - |
55
- | `<br-confirm-done>` | BrConfirmDone.vue | - | - | - |
56
- | `<br-confirm-email>` | BrConfirmEmail.vue | - | - | - |
57
- | `<br-container>` | BrContainer.vue | .br-container--outer | - | - |
58
- | `<br-footer-lower>` | br_footer_lower.vue | .br-footer-lower | br-footer-lower | - |
59
- | `<br-footer-upper>` | br_footer_upper.vue | .br-footer-upper | br-footer-upper | - |
60
- | `<br-form-block>` | BrFormBlock.vue | - | - | - |
61
- | `<br-form-password>` | BrFormPassword.vue | .br-form-password | br-form-password | - |
62
- | `<br-form-row>` | BrFormRow.vue | .br-form-row | br-form-row | - |
63
- | `<br-form-update>` | BrFormUpdate.vue | .br-form-update | br-form-update | - |
64
- | `<br-loader>` | BrLoader.vue | .br-loader | - | - |
65
- | `<br-skiplink>` | BrSkiplink.vue | - | - | `<skip-link>` |
66
- | `<br-wrap>` | BrWrap.vue | .br-wrap | - | - |
67
-
68
- The following component titles are deprecated. You can still use them, but they will migrate to the BR naming convention in future.
69
-
70
- | Component | Filename | SCSS Class | SCSS Mixin |
71
- | ----------------- | ----------------- | ---------- | ---------- |
72
- | `<account-title>` | AccountTitle.vue | - | - |
73
- | `<card-display>` | card_display.vue | - | - |
74
- | `<event-summary>` | EventSummary.vue | - | - |
75
- | `<fluid-iframe>` | FluidIframe.vue | - | - |
76
- | `<help-row>` | help_row.vue | - | - |
77
- | `<placeholder>` | placeholder.vue | - | - |
78
- | `<payment-logo>` | payment_logo.vue | - | - |
79
- | `<related-card>` | related_card.vue | - | - |
80
- | `<related-title>` | related_title.vue | - | - |
81
- | `<related-row>` | related_row.vue | - | - |
82
- | `<type-text>` | type_text.vue | - | - |
83
- | `<video-content>` | VideoContent.vue | - | - |
130
+ > The Barbican ticketing site makes SCSS mixins globally available via `vue.config.js`, so individual component files do not need to import them explicitly.
84
131
 
132
+ ### SCSS documentation
133
+
134
+ We use SassDoc to document SCSS. To generate and watch for changes:
135
+
136
+ ```sh
137
+ npm run build:css
85
138
  ```
86
- The BR naming convention imitates the Bootstrap example. This format is useful for two reasons:
87
139
 
88
- 1. It is immediately obvious that the component is imported from the Barbican Reset and is not native to the app.
140
+ Open `sassdoc/index.html` in your browser to view the output.
141
+
142
+ ## 4. Icons
89
143
 
90
- 2. It forces components to use a two word syntax, which is the recommended format for custom components. For example, <br-header> instead of <header>, which avoids clashing with native HTML5 components.
144
+ Icons are Vue components exported from the `barbican-reset/icons` path.
145
+
146
+ ```js
147
+ import { Cart, Close } from 'barbican-reset/icons'
91
148
  ```
92
149
 
93
- ## 3. SCSS documentation
150
+ Icon sub-groups are available at their own export paths:
94
151
 
95
- We use SassDoc to document our SCSS. Here's some useful commands for working with this documentation:
152
+ ```js
153
+ import { Edit } from 'barbican-reset/icons/account'
154
+ import { Done } from 'barbican-reset/icons/confirm'
155
+ import { Live } from 'barbican-reset/icons/stream'
156
+ ```
96
157
 
97
- - To output the latest documentation and watch for changes to scss, run `gulp watch:css`
98
- - To view the documentation, open the file `sassdoc/index.html` in your browser. You will need to refresh this page to view any additional changes that you make.
158
+ ## 5. Animations
99
159
 
100
- Most components have corresponding SCSS classes (and mixins) which allow us to implement consistent styling across our various frontends, irrespective of their HTML structure.
160
+ GSAP animation helpers are exported from `barbican-reset/animations`.
101
161
 
102
- ## 4. JS documentation
162
+ ```js
163
+ import { confirm } from 'barbican-reset/animations'
164
+ ```
165
+
166
+ ## 6. Logos
167
+
168
+ SVG logo files are located in the `logos/` directory:
169
+
170
+ - `barbican.svg`
171
+ - `arts-council-england.svg`
172
+ - `city-of-london.svg`
173
+ - `lso.svg`
174
+
175
+ ## 7. Scripts
103
176
 
104
- We use JSDoc to document our Javascript. Here's some useful commands for working with this documentation:
177
+ JS helper utilities are available at two export paths:
105
178
 
106
- - To output the latest documentation and watch for changes to javascript, run `gulp watch:js`
107
- - To manually output documentation using gulp, run `gulp doc:js`
108
- - To manually output documentation using jsdoc, run `jsdoc gulpfile.js`
109
- - To view the documentation, open the file `out/index.html` in your browser. You will need to refresh this page to view any additional changes that you make.
179
+ ```js
180
+ // Top-level helpers barrel
181
+ import helpers from 'barbican-reset/scripts/helpers'
110
182
 
111
- ## 5. Pattern library
183
+ // Vue composition API mixins (input helpers)
184
+ import { useInput } from 'barbican-reset/mixins'
185
+ ```
112
186
 
113
- The Barbican Reset includes a pattern library. This provides a single source of truth for all the SCSS contained within and allows us to view a whole family of Barbican styles alongside each other.
187
+ ## 8. Pattern library
114
188
 
115
- #### Setup
189
+ The pattern library provides a single source of truth for all SCSS styles and lets you view the full family of Barbican styles alongside each other.
116
190
 
117
- > If this is your first time viewing the pattern library, navigate to the **patterns** subfolder and run `npm i`
191
+ ### Setup
118
192
 
119
- From the root folder, run `npm run serve:patterns` and visit `https://localhost:3000` in the web browser
193
+ > If this is your first time, navigate to the `patterns` subfolder and run `npm i`.
120
194
 
121
- #### New pages
195
+ From the root folder:
122
196
 
123
- > Begin instructions from the **patterns** subfolder.
197
+ ```sh
198
+ npm run serve:patterns
199
+ ```
124
200
 
125
- To create a new page in the pattern library, navigate to the **views** subfolder.
201
+ Then open `http://localhost:3000` in your browser.
126
202
 
127
- Duplicate the `index.pug` file and rename it.
203
+ ### New pages
128
204
 
129
- #### Extending layouts
205
+ > Run the following from the `patterns` subfolder.
130
206
 
131
- The first line of your new page reads `extends ../layouts/main`
207
+ Navigate to the `views` subfolder and duplicate `index.pug`, then rename it.
132
208
 
133
- If you navigate to the `layouts` subfolder you will see a `main.pug` file. Pug syntax looks like abbreviated HTML markup but also includes `block content`. Blocks describe which areas the page can use to output content.
209
+ ### Extending layouts
134
210
 
135
- Layouts are useful for creating page templates, allowing pages to focus on content and removing the need for repetitive scafolding code.
211
+ The first line of your page reads:
136
212
 
137
- #### Including components (mixins)
213
+ ```pug
214
+ extends ../layouts/main
215
+ ```
138
216
 
139
- The second line of your new page reads `include ../components/samples`
217
+ The `layouts/main.pug` file defines `block content` — the area your page can write into. Layouts are useful for page templates, removing the need for repetitive scaffolding code.
140
218
 
141
- If you navigate to the `components` subfolder you will see a `samples.pug` file. Pug syntax looks like abbreviated HTML markup but also includes `mixin Samples()`. Mixins can accept parameters, which they use to print HTML markup on the page.
219
+ ### Including components (mixins)
142
220
 
143
- To call the samples mixin from your new page, you might write `+Samples('Contemporary','contemporary-music')`
221
+ The second line of your page reads:
144
222
 
145
- Mixins are useful for printing repetitive code, such as loops to the page. The parameters they accept are quite narrow though, so if you need more flexibility, it's best to extend a layout instead.
223
+ ```pug
224
+ include ../components/samples
225
+ ```
146
226
 
147
- #### Future intent
227
+ The `components/samples.pug` file defines `mixin Samples()`. Call it from your page like so:
148
228
 
149
- The pattern library was created as a single source of truth for Barbican styles and components. Unfortunately the components are only compatible with Vue.js currently and so the HTML markup is duplicated.
229
+ ```pug
230
+ +Samples('Contemporary', 'contemporary-music')
231
+ ```
150
232
 
151
- ## 6. Font library
233
+ Mixins are useful for rendering repetitive markup. For more flexibility, extend a layout instead.
152
234
 
153
- The Barbican Reset includes a SCSS mixin called `font-face` which defaults font-face urls to `https://www.barbican.org.uk/themes/barb22/fonts/`. This means none of digital projects need to host additional font files.
235
+ ## 9. Font library
154
236
 
155
- > If you do need to host fonts locally, you can overwrite the path parameter in the `font-face` mixin to point to a local asset.
237
+ The package includes a `font-face` SCSS mixin that defaults font URLs to `https://static.barbican.org.uk/systems-public/fonts/subset/`, so no digital project needs to host its own font files.
@@ -1,59 +1,61 @@
1
- import gsap from "gsap";
1
+ import gsap from 'gsap'
2
2
 
3
+ /** @type {gsap.TweenVars} Fade-in vars: animates element from transparent with a short delay */
3
4
  const fadeIn = {
4
5
  duration: 0.3,
5
6
  opacity: 0,
6
7
  delay: 0.3,
7
- };
8
+ }
8
9
 
10
+ /** @type {gsap.TweenVars} Explode vars: scales element up and fades it out */
9
11
  const explode = {
10
- ease: "power1.out",
12
+ ease: 'power1.out',
11
13
  opacity: 0,
12
14
  scale: 1.5,
13
- };
15
+ }
14
16
 
17
+ /** @type {gsap.TimelineVars} Default timeline settings shared across all confirm animations */
15
18
  const defaults = {
16
19
  duration: 0.6,
17
- ease: "power1.in",
18
- transformOrigin: "center",
19
- };
20
-
20
+ ease: 'power1.in',
21
+ transformOrigin: 'center',
22
+ }
23
+
24
+ /**
25
+ * Animates the email confirmation card.
26
+ * Fades in the title, draws the envelope outline and fold SVG paths,
27
+ * explodes a cloned title, then slides in the arrow.
28
+ */
21
29
  export const animateEmail = () => {
22
- const query = (target) => document.querySelector(`.card[email] ${target}`);
23
- const title = query(".card-title");
24
- const outline = query(".outline");
25
- const arrow = query(".arrow");
26
- const fold = query(".fold");
27
- const tl = gsap.timeline({ defaults });
28
-
29
- const clone = title.cloneNode(true);
30
- clone.classList.add("clone");
31
- title.after(clone);
32
-
33
- tl.set(arrow, { opacity: 0 })
34
- .from(title, fadeIn)
35
- .set(clone, { opacity: 0.4 })
36
- .from(outline, { drawSVG: "0%" }, "start")
37
- .from(fold, { drawSVG: "0%", duration: 0.3 }, "start")
38
- .to(clone, explode, "start")
39
- .set(arrow, { opacity: 1 })
40
- .from(arrow, { x: -6, ease: "power1.out" });
41
- };
42
-
30
+ const query = (target) => document.querySelector(`.card[email] ${target}`)
31
+ const title = query('.card-title')
32
+ const outline = query('.outline')
33
+ const arrow = query('.arrow')
34
+ const fold = query('.fold')
35
+ const tl = gsap.timeline({ defaults })
36
+
37
+ const clone = title.cloneNode(true)
38
+ clone.classList.add('clone')
39
+ title.after(clone)
40
+
41
+ tl.set(arrow, { opacity: 0 }).from(title, fadeIn).set(clone, { opacity: 0.4 }).from(outline, { drawSVG: '0%' }, 'start').from(fold, { drawSVG: '0%', duration: 0.3 }, 'start').to(clone, explode, 'start').set(arrow, { opacity: 1 }).from(arrow, { x: -6, ease: 'power1.out' })
42
+ }
43
+
44
+ /**
45
+ * Animates the done confirmation card.
46
+ * Fades in the title, draws the circle outline and tick SVG paths,
47
+ * and explodes a cloned title.
48
+ */
43
49
  export const animateDone = () => {
44
- const query = (target) => document.querySelector(`.card[done] ${target}`);
45
- const title = query(".card-title");
46
- const outline = query(".outline");
47
- const tick = query(".tick");
48
- const tl = gsap.timeline({ defaults });
49
-
50
- const clone = title.cloneNode(true);
51
- clone.classList.add("clone");
52
- title.after(clone);
53
-
54
- tl.from(title, fadeIn)
55
- .set(clone, { opacity: 0.4 })
56
- .from(outline, { drawSVG: "0%" }, "start")
57
- .from(tick, { drawSVG: "0%", duration: 0.3 }, "start+=0.3")
58
- .to(clone, explode, "start");
59
- };
50
+ const query = (target) => document.querySelector(`.card[done] ${target}`)
51
+ const title = query('.card-title')
52
+ const outline = query('.outline')
53
+ const tick = query('.tick')
54
+ const tl = gsap.timeline({ defaults })
55
+
56
+ const clone = title.cloneNode(true)
57
+ clone.classList.add('clone')
58
+ title.after(clone)
59
+
60
+ tl.from(title, fadeIn).set(clone, { opacity: 0.4 }).from(outline, { drawSVG: '0%' }, 'start').from(tick, { drawSVG: '0%', duration: 0.3 }, 'start+=0.3').to(clone, explode, 'start')
61
+ }
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="br-form-checkbox">
2
+ <div :class="['br-form-checkbox', { block }]">
3
3
  <br-form-label
4
4
  :class="[{ success }, { error }]"
5
5
  :disabled="disabled"
@@ -11,7 +11,7 @@
11
11
  v-bind="$attrs"
12
12
  type="checkbox"
13
13
  :error="error" />
14
- <span class="label-text">
14
+ <span v-if="$slots.default" class="label-text">
15
15
  <slot />
16
16
  </span>
17
17
  </br-form-label>
@@ -29,21 +29,11 @@ defineOptions({
29
29
  })
30
30
 
31
31
  const props = defineProps({
32
- id: {
33
- type: String,
34
- },
35
- disabled: {
36
- default: false,
37
- type: Boolean,
38
- },
39
- success: {
40
- default: false,
41
- type: Boolean,
42
- },
43
- error: {
44
- default: false,
45
- type: Boolean,
46
- },
32
+ id: String,
33
+ disabled: Boolean,
34
+ success: Boolean,
35
+ error: Boolean,
36
+ block: Boolean,
47
37
  })
48
38
 
49
39
  // @description Returns a string for the "id" attribute
@@ -8,6 +8,7 @@
8
8
  :value="option.value"
9
9
  :success="success"
10
10
  v-model="model"
11
+ :block="block"
11
12
  :error="error"
12
13
  :name="name">
13
14
  <slot v-if="$slots.default" v-bind="option" />
@@ -31,13 +32,8 @@ const model = defineModel()
31
32
  const props = defineProps({
32
33
  options: Array,
33
34
  name: String,
34
- success: {
35
- default: false,
36
- type: Boolean,
37
- },
38
- error: {
39
- default: false,
40
- type: Boolean,
41
- },
35
+ success: Boolean,
36
+ error: Boolean,
37
+ block: Boolean,
42
38
  })
43
39
  </script>
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <a :href="href" class="br-skiplink">
3
- <slot></slot>
3
+ <slot />
4
4
  </a>
5
5
  </template>
6
6
 
@@ -12,5 +12,5 @@ export default {
12
12
  required: true,
13
13
  },
14
14
  },
15
- };
15
+ }
16
16
  </script>
package/index.js CHANGED
@@ -28,6 +28,7 @@ import BrFormEdit from '#components/BrFormEdit.vue'
28
28
  import BrFormEmail from '#components/BrFormEmail.vue'
29
29
  import BrFormFieldset from '#components/BrFormFieldset.vue'
30
30
  import BrFormInput from '#components/BrFormInput.vue'
31
+ import BrFormLabel from '#components/BrFormLabel.vue'
31
32
  import BrFormPassword from '#components/BrFormPassword.vue'
32
33
  import BrFormRadio from '#components/BrFormRadio.vue'
33
34
  import BrFormRadioGroup from '#components/BrFormRadioGroup.vue'
@@ -73,6 +74,7 @@ export {
73
74
  BrFormEmail,
74
75
  BrFormFieldset,
75
76
  BrFormInput,
77
+ BrFormLabel,
76
78
  BrFormPassword,
77
79
  BrFormRadio,
78
80
  BrFormRadioGroup,
package/mixins/inputs.js CHANGED
@@ -1,5 +1,14 @@
1
+ /**
2
+ * Mixin providing common computed properties and methods for input components.
3
+ * Handles v-model binding, autocomplete attributes, data-test attributes,
4
+ * input type normalization, label association, and ID generation.
5
+ */
1
6
  export default {
2
7
  computed: {
8
+ /**
9
+ * Two-way binding for the component's modelValue prop.
10
+ * @type {*}
11
+ */
3
12
  value: {
4
13
  get() {
5
14
  return this.modelValue
@@ -8,6 +17,12 @@ export default {
8
17
  this.$emit('update:modelValue', value)
9
18
  },
10
19
  },
20
+
21
+ /**
22
+ * Derives the HTML autocomplete attribute value based on the input's id,
23
+ * type, or explicit autocomplete prop.
24
+ * @returns {string|null} Kebab-cased autocomplete token, or null if not applicable.
25
+ */
11
26
  generateAutoComplete() {
12
27
  let result = null
13
28
 
@@ -21,6 +36,11 @@ export default {
21
36
 
22
37
  return result && this.createKebabCase(result)
23
38
  },
39
+
40
+ /**
41
+ * Derives the data-test attribute value from the id or explicit dataTest prop.
42
+ * @returns {string|null} Kebab-cased test identifier, or null if neither prop is set.
43
+ */
24
44
  generateDataTest() {
25
45
  let result = null
26
46
 
@@ -30,6 +50,11 @@ export default {
30
50
 
31
51
  return result && this.createKebabCase(result)
32
52
  },
53
+
54
+ /**
55
+ * Normalizes the input type, defaulting to "text" if no type prop is provided.
56
+ * @returns {string} Kebab-cased input type string.
57
+ */
33
58
  generateType() {
34
59
  let result = 'text'
35
60
 
@@ -37,6 +62,12 @@ export default {
37
62
 
38
63
  return this.createKebabCase(result)
39
64
  },
65
+
66
+ /**
67
+ * Derives the `for` attribute value to associate a label with its input.
68
+ * Prefers id over label text. Returns null if no label is present.
69
+ * @returns {string|null} Kebab-cased for attribute value, or null if no label.
70
+ */
40
71
  generateFor() {
41
72
  let result = null
42
73
 
@@ -48,6 +79,12 @@ export default {
48
79
 
49
80
  return result && this.createKebabCase(result)
50
81
  },
82
+
83
+ /**
84
+ * Derives the input's id attribute, falling back to a random integer-based
85
+ * value if no id prop is provided.
86
+ * @returns {string} Kebab-cased id string.
87
+ */
51
88
  generateID() {
52
89
  let result = 'random_' + Math.ceil(Math.random() * 1000000)
53
90
 
@@ -57,6 +94,11 @@ export default {
57
94
  },
58
95
  },
59
96
  methods: {
97
+ /**
98
+ * Converts a string to kebab-case by lowercasing and replacing spaces with hyphens.
99
+ * @param {string} [value=''] - The string to convert.
100
+ * @returns {string} The kebab-cased string.
101
+ */
60
102
  createKebabCase(value = '') {
61
103
  value = String(value)
62
104
  return value.toLowerCase().split(' ').join('-')