@razerspine/pug-ui-kit 1.2.0 → 1.2.2

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
@@ -1,34 +1,21 @@
1
- ## [1.0.1] - 2026-02-03
1
+ # Changelog
2
2
 
3
- ### Changed
4
- - **dataTable**: Refactored the `dataTable` mixin to improve configuration consistency.
5
- - **dataTable**: The `options` parameter now accepts an `actions` array to define row actions (links/buttons) dynamically.
3
+ ## [1.2.2] - 2026-02-08
6
4
 
7
- ### Removed
8
- - **dataTable**: Removed support for the Pug `block` (slot) content for rendering actions. The `showActions` boolean option has also been removed.
5
+ ### Added
6
+ - **Build script**: Added a no-op `build` script (`echo "pug-ui-kit: nothing to build"`) to ensure compatibility with monorepo CI pipelines.
9
7
 
10
- ### Migration Guide
11
- If you were using the block content for actions:
12
- ```pug
13
- // Old version (v1.0.0)
14
- +dataTable(items, cols, { showActions: true })
15
- a(href=`/edit/${item.id}`) Edit
16
- ```
17
- You should now update to:
8
+ ### Changed
9
+ - **Documentation**: Expanded `README.md` with full documentation of all available Pug mixins, including usage examples and configuration notes.
18
10
 
19
- ```pug
20
- // New version (v1.0.1)
21
- +dataTable(items, cols, {
22
- actions: [
23
- { label: 'Edit', url: (item) => `/edit/${item.id}` }
24
- ]
25
- })
26
- ```
11
+ ### Notes
12
+ - This release does not change runtime behavior.
13
+ - The update ensures smooth CI execution when building all workspace packages together.
27
14
 
28
- ## [1.1.0] - 2026-02-03
29
- ### Added
30
- - **Styles**: Full SCSS and LESS support for all UI components.
31
- - **Architecture**: Added global settings, grid system, and themes (light/dark).
15
+ ## [1.2.1] - 2026-02-03
16
+
17
+ ### Fixed
18
+ - **SCSS Scope**: Fixed "Undefined variable" error in `_fonts.scss` by explicitly importing settings module via `@use`.
32
19
 
33
20
  ## [1.2.0] - 2026-02-03
34
21
  ### Added
@@ -40,7 +27,7 @@ You should now update to:
40
27
  - **Assets**: Resolved "Module not found" errors in Webpack by using tilde-prefixed paths (~) for internal asset resolution.
41
28
 
42
29
  ### Migration Guide (Optional)
43
- By default, the kit now looks for fonts inside the package.
30
+ By default, the kit now looks for fonts inside the package.
44
31
  If you wish to use a custom font path (e.g., a CDN or a different local folder), override the path variable before importing the kit:
45
32
 
46
33
  #### SCSS:
@@ -56,3 +43,35 @@ If you wish to use a custom font path (e.g., a CDN or a different local folder),
56
43
  @font-path: "/my-custom-path/fonts";
57
44
  @import "@razerspine/pug-ui-kit/less/ui-kit.less";
58
45
  ```
46
+
47
+ ## [1.1.0] - 2026-02-03
48
+ ### Added
49
+ - **Styles**: Full SCSS and LESS support for all UI components.
50
+ - **Architecture**: Added global settings, grid system, and themes (light/dark).
51
+
52
+ ## [1.0.1] - 2026-02-03
53
+
54
+ ### Changed
55
+ - **dataTable**: Refactored the `dataTable` mixin to improve configuration consistency.
56
+ - **dataTable**: The `options` parameter now accepts an `actions` array to define row actions (links/buttons) dynamically.
57
+
58
+ ### Removed
59
+ - **dataTable**: Removed support for the Pug `block` (slot) content for rendering actions. The `showActions` boolean option has also been removed.
60
+
61
+ ### Migration Guide
62
+ If you were using the block content for actions:
63
+ ```pug
64
+ // Old version (v1.0.0)
65
+ +dataTable(items, cols, { showActions: true })
66
+ a(href=`/edit/${item.id}`) Edit
67
+ ```
68
+ You should now update to:
69
+
70
+ ```pug
71
+ // New version (v1.0.1)
72
+ +dataTable(items, cols, {
73
+ actions: [
74
+ { label: 'Edit', url: (item) => `/edit/${item.id}` }
75
+ ]
76
+ })
77
+ ```
package/README.md CHANGED
@@ -56,6 +56,50 @@ Note: Always import settings first, as other components depend on them.
56
56
  #### Button
57
57
 
58
58
  ```pug
59
+ //- Renders a configurable button with optional icon and text. Visual appearance
60
+ //- is primarily controlled by the `variant` and `size` parameters and by CSS
61
+ //- classes applied via `attrs` or global styles.
62
+ //-
63
+ //- NOTE: project migrated to an SVG sprite. The mixin references symbols by id
64
+ //- using <use href="#icon-{iconName}"> (xlink:href kept for legacy browsers).
65
+ //- Ensure your sprite contains <symbol id="icon-{name}"> entries.
66
+ //-
67
+ //- Parameters:
68
+ //- text - **String | null** — Visible button text. If `null` or an empty
69
+ //- string, the text node is omitted (icon-only button).
70
+ //- Default: null
71
+ //- variant - **String** — Visual variant modifier appended to `.btn--{variant}`.
72
+ //- Common values: 'primary', 'secondary', 'outline', 'text-primary',
73
+ //- 'text-secondary', 'icon-primary', 'icon-secondary', 'icon-outline', 'icon'.
74
+ //- Default: 'primary'
75
+ //- size - **String** — Size modifier appended to `.btn--{size}` and used
76
+ //- for icon sizing `.icon--{size}`. Common values: 'small', 'medium', 'large'.
77
+ //- Default: 'medium'
78
+ //- attrs - **Object | null** — Attributes to spread onto the `<button>`
79
+ //- element via `&attributes(attrs)`. Use this to pass `type`,
80
+ //- `id`, `aria-*`, `data-*`, etc. If `null`, no attributes are spread.
81
+ //- If `attrs.class` is present it will be merged with the base classes.
82
+ //- Default: { type: 'button' }
83
+ //- iconName - **String | null** — Icon name (without prefix). The mixin uses
84
+ //- `#icon-{iconName}` in <use> to reference the SVG sprite symbol.
85
+ //- If `null`, no icon is rendered.
86
+ //- Default: null
87
+ //-
88
+ //- Accessibility notes:
89
+ //- - If the button has visible text, the SVG is treated as decorative and gets
90
+ //- `aria-hidden="true"` so screen readers ignore it.
91
+ //- - If the button is icon-only (text === null or empty), the mixin will set
92
+ //- `aria-label` on the button if `attrs` does not already provide one. Provide
93
+ //- a meaningful `aria-label` in `attrs` for icon-only buttons.
94
+ //-
95
+ //- Behavior summary:
96
+ //- - Computes `hasText` to decide whether to render the text node.
97
+ //- - Builds base classes and safely merges any `attrs.class` with them.
98
+ //- - Renders <svg><use href="#icon-{iconName}" xlink:href="#icon-{iconName}"></use></svg>
99
+ //- when `iconName` is provided.
100
+ //- - Sets `aria-hidden` on the SVG when text is present; ensures icon-only buttons
101
+ //- have an accessible label.
102
+
59
103
  include ~pug-ui-kit/btn.pug
60
104
 
61
105
  +btn('Save', 'primary', 'small', { type: 'submit' })
@@ -64,6 +108,40 @@ include ~pug-ui-kit/btn.pug
64
108
  #### Data Table (New in v1.1.0)
65
109
 
66
110
  ```pug
111
+ //- Renders a flexible table from an array of objects. Columns are derived
112
+ //- from the provided `columns` array or automatically collected from object keys.
113
+ //-
114
+ //- Parameters:
115
+ //- items - **Array** — Array of objects to render as rows. Each object
116
+ //- represents one row.
117
+ //- Default: []
118
+ //- columns - **Array | undefined** — Optional ordered list of keys to use
119
+ //- as columns. If omitted, unique keys are collected from `items`.
120
+ //- Default: auto-collected from items
121
+ //- options - **Object | undefined** — Configuration options:
122
+ //- - emptyText: **String** — Text shown when no rows; Default: 'No data'.
123
+ //- - showIndex: **Boolean** — Render leading index column; Default: false.
124
+ //- - formatters: **Object** — Map of column -> function(value) for custom rendering.
125
+ //- Example: { createdAt: v => new Date(v).toLocaleDateString() }.
126
+ //- - labels: **Object** — Map of column -> header label string.
127
+ //- Example: { id: 'ID', user_name: 'Name' }.
128
+ //- - actions: **Array** — List of action objects to render in the last column.
129
+ //- Replaces the deprecated block/slot mechanism.
130
+ //- Structure:
131
+ //- [
132
+ //- {
133
+ //- label: String, // Text of the link/button
134
+ //- url: Function(item), // Callback returning the URL string based on the row item
135
+ //- class: String (optional) // CSS classes for the link
136
+ //- }
137
+ //- ]
138
+ //- Default: []
139
+ //-
140
+ //- Behavior:
141
+ //- - Renders a table with Bootstrap-like classes (`table`).
142
+ //- - If `items` is empty, displays a unified row with `emptyText`.
143
+ //- - Actions are rendered as `<a>` tags in a separate column if `options.actions` is provided.
144
+
67
145
  include ~pug-ui-kit/data-table.pug
68
146
 
69
147
  - const data = [{id: 1, name: 'Alice'}, {id: 2, name: 'Bob'}];
@@ -78,12 +156,51 @@ include ~pug-ui-kit/data-table.pug
78
156
  url: (item) => `/users/edit/${item.id}`
79
157
  }
80
158
  ]
81
- })
159
+ })]
82
160
  ```
83
161
 
84
162
  #### Form Input
85
163
 
86
164
  ```pug
165
+ //- Renders a configurable <input> element with optional label and placeholder.
166
+ //- Supports different input types, custom name, value, and placeholder text.
167
+ //-
168
+ //- Parameters:
169
+ //- type - **String** — Input type attribute.
170
+ //- Example: 'text', 'email', 'password', 'number'.
171
+ //- Default: none (required).
172
+ //- id - **String** — Unique identifier for the <input> element.
173
+ //- Also used by the <label> `for` attribute.
174
+ //- Example: 'username', 'email'.
175
+ //- Default: none (required).
176
+ //- label - **String | null** — Visible label text. If `null` or empty,
177
+ //- no label is rendered.
178
+ //- Example: 'Name', 'Email address'.
179
+ //- Default: null.
180
+ //- placeholder - **String** — Placeholder text displayed inside the input
181
+ //- when empty.
182
+ //- Example: 'Enter your name', 'example@mail.com'.
183
+ //- Default: ''.
184
+ //- name - **String** — Name attribute for form submission.
185
+ //- Example: 'username', 'email'.
186
+ //- Default: ''.
187
+ //- value - **String** — Default value for the input field.
188
+ //- Example: 'John Doe', 'test@mail.com'.
189
+ //- Default: ''.
190
+ //-
191
+ //- Behavior:
192
+ //- - The input always has `.form-control` class for styling.
193
+ //- - The label, if provided, uses `.form-label` class and is linked via `for=id`.
194
+ //- - The placeholder text is shown until the user types content.
195
+ //- - The `name` attribute ensures the input value is submitted with the form.
196
+ //- - The `value` attribute pre-fills the input field if provided.
197
+ //-
198
+ //- Notes about styling and classes:
199
+ //- - Visual appearance is controlled by `.form-control` and `.form-label`
200
+ //- styles in your SCSS.
201
+ //- - To add custom classes or attributes, extend the mixin or wrap it.
202
+ //- - Ensure `id` is unique to avoid duplicate `for`/`id` collisions.
203
+
87
204
  include ~pug-ui-kit/form-input.pug
88
205
 
89
206
  +formInput('text', 'name', 'Name', 'Enter your name', 'name')
@@ -92,6 +209,38 @@ include ~pug-ui-kit/form-input.pug
92
209
  #### Form Textarea
93
210
 
94
211
  ```pug
212
+ //- Renders a configurable <textarea> element with optional label and placeholder.
213
+ //- Supports custom name attribute for form submission.
214
+ //-
215
+ //- Parameters:
216
+ //- id - **String** — Unique identifier for the <textarea> element.
217
+ //- Also used by the <label> `for` attribute.
218
+ //- Example: 'message', 'comment'.
219
+ //- Default: none (required).
220
+ //- label - **String | null** — Visible label text. If `null` or empty,
221
+ //- no label is rendered.
222
+ //- Example: 'Message', 'Comment'.
223
+ //- Default: null.
224
+ //- placeholder - **String** — Placeholder text displayed inside the textarea
225
+ //- when empty.
226
+ //- Example: 'Type your message...', 'Enter comment here'.
227
+ //- Default: ''.
228
+ //- name - **String** — Name attribute for form submission.
229
+ //- Example: 'message', 'feedback'.
230
+ //- Default: ''.
231
+ //-
232
+ //- Behavior:
233
+ //- - The textarea always has `.form-textarea` class for styling.
234
+ //- - The label, if provided, uses `.form-label` class and is linked via `for=id`.
235
+ //- - The placeholder text is shown until the user types content.
236
+ //- - The `name` attribute ensures the textarea value is submitted with the form.
237
+ //-
238
+ //- Notes about styling and classes:
239
+ //- - Visual appearance is controlled by `.form-textarea` and `.form-label`
240
+ //- styles in your SCSS.
241
+ //- - To add custom classes or attributes, extend the mixin or wrap it.
242
+ //- - Ensure `id` is unique to avoid duplicate `for`/`id` collisions.
243
+
95
244
  include ~pug-ui-kit/form-textarea.pug
96
245
 
97
246
  +formTextarea('message', 'Message', 'Type your message...', 'message')
@@ -100,6 +249,35 @@ include ~pug-ui-kit/form-textarea.pug
100
249
  #### Input Checkbox
101
250
 
102
251
  ```pug
252
+ //- Renders a configurable checkbox with label and optional attributes.
253
+ //-
254
+ //- Summary
255
+ //- Renders a checkbox input and its label inside a single inline control.
256
+ //- Uses the project's base input styles so visual appearance is driven by SCSS.
257
+ //-
258
+ //- Parameters
259
+ //- id - **String** — Unique id for the <input>. Also used by <label for>.
260
+ //- Required; example: 'agree'.
261
+ //- label - **String** — Visible label text shown next to the checkbox.
262
+ //- Required; example: 'I agree to terms'.
263
+ //- name - **String** — Name attribute for form submission/grouping.
264
+ //- Optional; default: ''.
265
+ //- value - **String** — Value submitted when checked. Optional; default: 'on'.
266
+ //- checked - **Boolean** — Whether the checkbox is checked by default.
267
+ //- Optional; default: false.
268
+ //-
269
+ //- Behavior
270
+ //- - Wraps input and label in a single inline control element (uses .check-control-label).
271
+ //- - Input uses base input class (.input-base) so theme styles apply consistently.
272
+ //- - Label text is rendered in a sibling element (.input-text) and is clickable.
273
+ //- - If checked is true, the input is rendered with the checked attribute.
274
+ //- - Any attributes passed via attrs are applied to the <input> (useful for disabled, required, aria-*).
275
+ //-
276
+ //- Styling and accessibility
277
+ //- - Visual styling is controlled by .input-base, input[type="checkbox"], .check-control-label and .input-text in SCSS.
278
+ //- - Ensure id is unique to keep label association correct for screen readers.
279
+ //- - Prefer passing ARIA attributes via attrs for additional accessibility.
280
+
103
281
  include ~pug-ui-kit/input-checkbox.pug
104
282
 
105
283
  +inputCheckbox('agree', 'I agree to all terms')
@@ -108,6 +286,33 @@ include ~pug-ui-kit/input-checkbox.pug
108
286
  #### Input Radio
109
287
 
110
288
  ```pug
289
+ //- Renders a configurable radio input with label for use in radio groups.
290
+ //-
291
+ //- Summary
292
+ //- Renders a single radio control paired with a clickable label.
293
+ //- Intended for groups where multiple radios share the same name.
294
+ //-
295
+ //- Parameters
296
+ //- id - **String** — Unique id for the <input>. Also used by <label for>.
297
+ //- Required; example: 'contact-email'.
298
+ //- label - **String** — Visible label text shown next to the radio.
299
+ //- Required; example: 'Email'.
300
+ //- name - **String** — Name attribute to group radios. Required; example: 'contact'.
301
+ //- value - **String** — Value submitted when selected. Required; example: 'email'.
302
+ //- checked - **Boolean** — Whether this radio is selected by default.
303
+ //- Optional; default: false.
304
+ //-
305
+ //- Behavior
306
+ //- - Wraps input and label in a single inline control (.check-control-label).
307
+ //- - Input uses .input-base so theme styles apply consistently.
308
+ //- - Radios with the same name are mutually exclusive; only one can be selected.
309
+ //- - If checked is true, the input is rendered with the checked attribute.
310
+ //- - Any attrs are applied to the <input> (useful for disabled, required, aria-*).
311
+ //-
312
+ //- Styling and accessibility
313
+ //- - Visual styling is controlled by .input-base, input[type="radio"], .check-control-label and .input-text in SCSS.
314
+ //- - Ensure id is unique to keep label association correct for screen readers.
315
+
111
316
  include ~pug-ui-kit/input-radio.pug
112
317
 
113
318
  .form-group
@@ -120,6 +325,57 @@ include ~pug-ui-kit/input-radio.pug
120
325
  #### Single Select
121
326
 
122
327
  ```pug
328
+ //- Renders a configurable <select> element with label, options, and optional placeholder.
329
+ //- Supports both arrays of strings and arrays of objects with configurable
330
+ //- keys for label and value. Provides ability to set a default selected option.
331
+ //-
332
+ //- Parameters:
333
+ //- id - **String** — Unique identifier for the <select> element.
334
+ //- Also used as the `name` attribute.
335
+ //- Example: 'topic', 'country'.
336
+ //- Default: none (required).
337
+ //- label - **String | null** — Visible label text. If `null` or empty,
338
+ //- no label is rendered.
339
+ //- Example: 'Topic', 'Choose country'.
340
+ //- Default: null.
341
+ //- options - **Array** — Options to render. Can be:
342
+ //- - Array of strings: ['Support', 'Feedback', 'Other']
343
+ //- - Array of objects: [{value:'support', text:'Support'}, …]
344
+ //- - Array of objects with custom keys (see labelKey/valueKey).
345
+ //- Default: [].
346
+ //- labelKey - **String** — Key name in option objects for display text.
347
+ //- Example: 'text', 'label'.
348
+ //- Default: 'text'.
349
+ //- valueKey - **String** — Key name in option objects for option value.
350
+ //- Example: 'value', 'id'.
351
+ //- Default: 'value'.
352
+ //- selectedValue - **String** — Value of the option that should be selected
353
+ //- by default. If empty, no option is preselected.
354
+ //- Example: 'feedback', '2'.
355
+ //- Default: ''.
356
+ //- placeholder - **String** — Text for a placeholder option. Rendered only
357
+ //- if `label` is null and `selectedValue` is empty.
358
+ //- Example: 'Choose an option', 'Select country'.
359
+ //- Default: 'Choose an option'.
360
+ //-
361
+ //- Behavior:
362
+ //- - If `options` is an array of strings, each string is used as both
363
+ //- the option value and label.
364
+ //- - If `options` is an array of objects, the keys defined by `labelKey`
365
+ //- and `valueKey` are used.
366
+ //- - The option whose value matches `selectedValue` is rendered with
367
+ //- the `selected` attribute.
368
+ //- - If no label is provided and no selectedValue is set, a placeholder
369
+ //- option is rendered at the top (`disabled selected hidden`).
370
+ //- - The <select> element always has `.single-select` class for styling.
371
+ //- - The label, if provided, uses `.form-label` class.
372
+ //-
373
+ //- Notes about styling and classes:
374
+ //- - Visual appearance is controlled by `.single-select` and `.form-label`
375
+ //- styles in your SCSS.
376
+ //- - To add custom classes or attributes, extend the mixin or wrap it.
377
+ //- - Ensure `id` is unique to avoid duplicate `for`/`id` collisions.
378
+
123
379
  include ~pug-ui-kit/single-select.pug
124
380
 
125
381
  +singleSelect('topic', 'Topic', [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@razerspine/pug-ui-kit",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Shared Pug mixins for Webpack Starter templates",
5
5
  "keywords": [
6
6
  "pug",
@@ -18,6 +18,9 @@
18
18
  "LICENSE",
19
19
  "CHANGELOG.md"
20
20
  ],
21
+ "scripts": {
22
+ "build": "echo \"pug-ui-kit: nothing to build\""
23
+ },
21
24
  "style": "scss/ui-kit.scss",
22
25
  "less": "less/ui-kit.less",
23
26
  "author": "Razerspine",
@@ -26,6 +29,7 @@
26
29
  "url": "https://github.com/Razerspine/webpack-starter-monorepo",
27
30
  "directory": "packages/pug-ui-kit"
28
31
  },
32
+ "homepage": "https://github.com/Razerspine/webpack-starter-monorepo/blob/main/packages/pug-ui-kit#readme",
29
33
  "bugs": {
30
34
  "url": "https://github.com/Razerspine/webpack-starter-monorepo/issues"
31
35
  },
@@ -1,9 +1,9 @@
1
- @use '../settings/_variables';
1
+ @use '../settings' as var;
2
2
 
3
3
  @font-face {
4
4
  font-family: 'Roboto';
5
- src: url('#{$font-path}/Roboto-Thin.woff2') format('woff2'),
6
- url('#{$font-path}/Roboto-Thin.woff') format('woff');
5
+ src: url('#{var.$font-path}/Roboto-Thin.woff2') format('woff2'),
6
+ url('#{var.$font-path}/Roboto-Thin.woff') format('woff');
7
7
  font-weight: 100;
8
8
  font-style: normal;
9
9
  font-display: swap;
@@ -11,8 +11,8 @@
11
11
 
12
12
  @font-face {
13
13
  font-family: 'Roboto';
14
- src: url('#{$font-path}/Roboto-Light.woff2') format('woff2'),
15
- url('#{$font-path}/Roboto-Light.woff') format('woff');
14
+ src: url('#{var.$font-path}/Roboto-Light.woff2') format('woff2'),
15
+ url('#{var.$font-path}/Roboto-Light.woff') format('woff');
16
16
  font-weight: 300;
17
17
  font-style: normal;
18
18
  font-display: swap;
@@ -20,8 +20,8 @@
20
20
 
21
21
  @font-face {
22
22
  font-family: 'Roboto';
23
- src: url('#{$font-path}/Roboto-Regular.woff2') format('woff2'),
24
- url('#{$font-path}/Roboto-Regular.woff') format('woff');
23
+ src: url('#{var.$font-path}/Roboto-Regular.woff2') format('woff2'),
24
+ url('#{var.$font-path}/Roboto-Regular.woff') format('woff');
25
25
  font-weight: 400;
26
26
  font-style: normal;
27
27
  font-display: swap;
@@ -29,8 +29,8 @@
29
29
 
30
30
  @font-face {
31
31
  font-family: 'Roboto';
32
- src: url('#{$font-path}/Roboto-Medium.woff2') format('woff2'),
33
- url('#{$font-path}/Roboto-Medium.woff') format('woff');
32
+ src: url('#{var.$font-path}/Roboto-Medium.woff2') format('woff2'),
33
+ url('#{var.$font-path}/Roboto-Medium.woff') format('woff');
34
34
  font-weight: 500;
35
35
  font-style: normal;
36
36
  font-display: swap;
@@ -38,8 +38,8 @@
38
38
 
39
39
  @font-face {
40
40
  font-family: 'Roboto';
41
- src: url('#{$font-path}/Roboto-Bold.woff2') format('woff2'),
42
- url('#{$font-path}/Roboto-Bold.woff') format('woff');
41
+ src: url('#{var.$font-path}/Roboto-Bold.woff2') format('woff2'),
42
+ url('#{var.$font-path}/Roboto-Bold.woff') format('woff');
43
43
  font-weight: 700;
44
44
  font-style: normal;
45
45
  font-display: swap;