@dreamworld/dw-checkbox 3.1.2 → 3.1.3-migrate-circleci-to-github-actions.1

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.
@@ -0,0 +1,58 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - master
7
+ - 'feature/**'
8
+
9
+ concurrency:
10
+ group: release-${{ github.ref }}
11
+ cancel-in-progress: false
12
+
13
+ permissions:
14
+ contents: write # push release tags and create GitHub releases
15
+ issues: write # comment on issues resolved by a release
16
+ pull-requests: write # comment on pull requests included in a release
17
+
18
+ jobs:
19
+ release-snapshot:
20
+ if: startsWith(github.ref, 'refs/heads/feature/')
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ with:
25
+ fetch-depth: 0 # semantic-release needs full history and tags
26
+ - uses: actions/setup-node@v4
27
+ with:
28
+ node-version: lts/*
29
+ cache: yarn
30
+ - run: yarn install --frozen-lockfile --non-interactive
31
+ - name: Deploy
32
+ env:
33
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34
+ NPM_TOKEN: ${{ secrets.SNAPSHOT_NPM_TOKEN }}
35
+ NPM_PACKAGE_SCOPE: ${{ secrets.NPM_PACKAGE_SCOPE }}
36
+ NPM_SNAPSHOT_REPO: ${{ secrets.NPM_SNAPSHOT_REPO }}
37
+ run: |
38
+ npm config set "${NPM_PACKAGE_SCOPE}:registry" "${NPM_SNAPSHOT_REPO}"
39
+ npx semantic-release
40
+
41
+ release:
42
+ if: github.ref == 'refs/heads/master'
43
+ runs-on: ubuntu-latest
44
+ steps:
45
+ - uses: actions/checkout@v4
46
+ with:
47
+ fetch-depth: 0 # semantic-release needs full history and tags
48
+ - uses: actions/setup-node@v4
49
+ with:
50
+ node-version: lts/*
51
+ cache: yarn
52
+ - run: yarn install --frozen-lockfile --non-interactive
53
+ - run: echo "Running release job"
54
+ - name: Deploy
55
+ env:
56
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
58
+ run: npx semantic-release
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dreamworld/dw-checkbox",
3
- "version": "3.1.2",
3
+ "version": "3.1.3-migrate-circleci-to-github-actions.1",
4
4
  "description": "",
5
5
  "main": "dw-checkbox.js",
6
6
  "type": "module",
package/readme.md CHANGED
@@ -1,70 +1,167 @@
1
- # dw-checkbox
1
+ # @dreamworld/dw-checkbox
2
2
 
3
- A material checkbox element made with lit-html. It's an wrapper of [mwc-checkbox](https://github.com/material-components/material-components-web-components/tree/master/packages/checkbox) element. Supports all the features of `mwc-checkbox`.
3
+ A LitElement-based Material Design checkbox web component that wraps [`@material/mwc-checkbox`](https://github.com/material-components/material-components-web-components/tree/master/packages/checkbox) and integrates with `@dreamworld/dw-form` for form serialization.
4
4
 
5
+ ---
5
6
 
6
- ## Installation
7
+ ## 1. User Guide
7
8
 
8
- ``` html
9
- npm install --save @dreamworld/dw-checkbox
9
+ ### Installation & Setup
10
+
11
+ ```bash
12
+ yarn add @dreamworld/dw-checkbox
13
+ ```
14
+
15
+ The package is an ES module (`"type": "module"`). Import it as a side-effect to register the `<dw-checkbox>` custom element:
16
+
17
+ ```javascript
18
+ import '@dreamworld/dw-checkbox';
10
19
  ```
11
20
 
12
- ## Usage
21
+ ### Basic Usage
13
22
 
14
- ``` html
23
+ ```html
24
+ <script type="module">
15
25
  import '@dreamworld/dw-checkbox';
26
+ </script>
27
+
28
+ <!-- Unchecked -->
29
+ <dw-checkbox label="Accept terms"></dw-checkbox>
30
+
31
+ <!-- Pre-checked -->
32
+ <dw-checkbox label="Remember me" checked></dw-checkbox>
16
33
  ```
17
34
 
18
- ## [Demo](https://dreamworldsolutions.github.io/dw-checkbox/demo/index.html)
35
+ Listen for changes:
36
+
37
+ ```javascript
38
+ const cb = document.querySelector('dw-checkbox');
39
+
40
+ // Preferred
41
+ cb.addEventListener('change', () => {
42
+ console.log(cb.checked);
43
+ });
44
+ ```
45
+
46
+ ---
47
+
48
+ ### API Reference
49
+
50
+ #### Props / Attributes
51
+
52
+ | Name | Type | Default | Required | Description |
53
+ |---|---|---|---|---|
54
+ | `name` | `String` | — | No | Name of the element, used as the key during `dw-form` serialization. |
55
+ | `value` | `String` | `""` | No | Value submitted during form serialization. When multiple checkboxes share the same `name`, only the checked ones contribute their `value` to the serialized array. |
56
+ | `label` | `String` | `""` | No | Text label rendered alongside the checkbox. Clicking the label area toggles the checkbox. Omit for a label-less checkbox. |
57
+ | `alignEnd` | `Boolean` | `false` | No | When `true`, renders the label before (to the left of) the checkbox. |
58
+ | `disabled` | `Boolean` | `false` | No | Disables interaction with the checkbox. |
59
+ | `checked` | `Boolean` | `false` | No | Reflects and controls the checked state. Acts as both an input and output property — updated automatically on user interaction. |
60
+ | `indeterminate` | `Boolean` | `false` | No | Renders the checkbox in a partial-selection (mixed) state. |
61
+ | `reducedTouchTarget` | `Boolean` | `false` | No | Removes touch-screen padding and increases density. |
62
+
63
+ #### Events
64
+
65
+ | Event | Description |
66
+ |---|---|
67
+ | `change` | Dispatched when the user toggles the checkbox. Preferred over `checked-changed`. Read the new state via `element.checked`. |
68
+ | `checked-changed` | **Deprecated.** Dispatched alongside `change` on every user interaction. Prefer `change` for new code. |
19
69
 
20
- ## Properties
70
+ #### Slots
21
71
 
22
- It supports below properties:
72
+ | Name | Description |
73
+ |---|---|
74
+ | `label` | Named slot inside `<dw-form-field>`'s label area. Use for custom label markup (e.g. formatted text, icons). Takes precedence over the `label` property when both are present in the rendered output. |
23
75
 
24
- - disabled
76
+ **Example:**
25
77
 
26
- - label
78
+ ```html
79
+ <dw-checkbox>
80
+ <span slot="label">Accept <a href="/terms">Terms of Service</a></span>
81
+ </dw-checkbox>
82
+ ```
83
+
84
+ #### Methods
27
85
 
28
- - alignEnd
86
+ | Method | Signature | Description |
87
+ |---|---|---|
88
+ | `toggle()` | `toggle(): void` | Programmatically focuses and clicks the internal checkbox, toggling its checked state. |
89
+ | `focus()` | `focus(): void` | Moves focus to the internal `<base-checkbox>` element. |
29
90
 
30
- - checked
91
+ #### CSS Custom Properties
31
92
 
32
- - indeterminate
93
+ These properties are set on `:host` and cascade into the underlying `mwc-checkbox`:
33
94
 
34
- - value
95
+ | Property | Default Value | Description |
96
+ |---|---|---|
97
+ | `--mdc-checkbox-unchecked-color` | `var(--mdc-theme-text-secondary-on-background)` | Border color of the unchecked checkbox. |
98
+ | `--mdc-checkbox-disabled-color` | `var(--mdc-theme-text-disabled-on-background)` | Color applied when `disabled` is set. |
35
99
 
36
- ## Events
100
+ > All other CSS custom properties from `@material/mwc-checkbox` are also accepted and passed through.
37
101
 
38
- - `checked-changed`: Dispatched when user updates checked status. It's DEPRECATED now, instead use `change`.
39
- - `change`: Dispatched when user updates checked status. So, same as [browser default event][browser-event-change]
102
+ ---
40
103
 
41
- ## Features
104
+ ### Advanced Usage
42
105
 
43
- - It provides checkbox with it's label
44
- - On label click it changes checkbox's selection
106
+ #### Custom Theming
45
107
 
46
- ### Examples
108
+ ```html
109
+ <style>
110
+ .teal-checkbox {
111
+ --mdc-theme-secondary: #00BCD4;
112
+ --mdc-theme-text-primary: #00BCD4;
113
+ font-size: 30px;
114
+ }
115
+ </style>
47
116
 
48
- #### Set `alignEnd` property to show label after checkbox
49
- ``` html
50
- <dw-checkbox label="This is checkbox" alignEnd></dw-checkbox>
117
+ <dw-checkbox class="teal-checkbox" checked label="Custom styled"></dw-checkbox>
51
118
  ```
52
119
 
53
- #### Use `disabled` property to disable checkbox
54
- ``` html
55
- <dw-checkbox label="This is checkbox" disabled checked></dw-checkbox>
120
+
121
+ #### Form Integration with `dw-form`
122
+
123
+ When multiple `<dw-checkbox>` elements share the same `name` inside a `<dw-form>`, `dw-form.serialize()` returns an array of the `value`s of all checked boxes.
124
+
125
+ ```html
126
+ <dw-form>
127
+ <dw-checkbox name="fruit" value="apple" label="Apple" checked></dw-checkbox>
128
+ <dw-checkbox name="fruit" value="grapes" label="Grapes"></dw-checkbox>
129
+ <dw-checkbox name="fruit" value="kiwi" label="Kiwi" checked></dw-checkbox>
130
+ </dw-form>
56
131
  ```
57
132
 
58
- #### `value` property usage
59
- `value` property used to get selected item's value. e.g. `apple`.
60
- In below example, dwForm.serialize() method's result is `{fruit: ['apple', 'kiwi']}`
133
+ `dwForm.serialize()` → `{ fruit: ['apple', 'kiwi'] }`
134
+
135
+ ---
136
+
137
+ ## 2. Developer Guide / Architecture
138
+
139
+ ### Architecture Overview
61
140
 
62
- ``` html
63
- <dw-form>
64
- <dw-checkbox name="fruit" value="apple" label="Apple" checked></dw-checkbox>
65
- <dw-checkbox name="fruit" value="grapes" label="Grapes"></dw-checkbox>
66
- <dw-checkbox name="fruit" value="kiwi" label="Kiwi" checked></dw-checkbox>
67
- </dw-form>
68
141
  ```
142
+ DwCheckbox (dw-checkbox.js)
143
+ extends DwFormElement( LitElement )
144
+ └── renders <dw-form-field> (from @dreamworld/dw-form)
145
+ └── <base-checkbox> (base-checkbox.js)
146
+ extends Checkbox from @material/mwc-checkbox
147
+ ```
148
+
149
+ | Module | Responsibility |
150
+ |---|---|
151
+ | [dw-checkbox.js](dw-checkbox.js) | Public API — properties, events, methods, host styles, form-element mixin wiring. |
152
+ | [base-checkbox.js](base-checkbox.js) | Internal override of `mwc-checkbox`. Narrows the indeterminate (mixed) mark width to `8px` via a CSS override on `.mdc-checkbox__mixedmark`. |
153
+
154
+ ### Design Patterns
155
+
156
+ - **Mixin composition** — `DwFormElement(LitElement)` applies the `@dreamworld/dw-form` form-element mixin, which handles `name`/`value` serialization without modifying the base LitElement class.
157
+ - **Delegation** — All checked-state logic is delegated to the inner `<base-checkbox>`. `DwCheckbox` only syncs the `checked` property and re-dispatches events from the shadow DOM.
158
+ - **Auto-blur on click** — A `setTimeout(..., 1)` inside the `@click` handler on `<base-checkbox>` removes focus immediately after interaction, preventing a persistent focus ring on pointer devices.
69
159
 
70
- [browser-event-change]: https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/change_event
160
+ ### Development
161
+
162
+ Run the demo locally (requires Node.js):
163
+
164
+ ```bash
165
+ yarn start
166
+ # Launches: wds --node-resolve --app-index demo/index.html --open --watch
167
+ ```
@@ -1,41 +0,0 @@
1
- version: 2
2
- jobs:
3
- release-snapshot:
4
- docker:
5
- - image: circleci/node:lts
6
- steps:
7
- - checkout
8
- - run: yarn install --frozen-lockfile --non-interactive
9
- - run:
10
- name: Deploy
11
- command: |
12
- export NPM_TOKEN=${SNAPSHOT_NPM_TOKEN}
13
- npm config set ${NPM_PACKAGE_SCOPE}:registry ${NPM_SNAPSHOT_REPO}
14
- npx semantic-release
15
- release:
16
- docker:
17
- - image: circleci/node:lts
18
- steps:
19
- - checkout
20
- - run: yarn install --frozen-lockfile --non-interactive
21
- - run: echo "Running release job"
22
- - run:
23
- name: Deploy
24
- command: npx semantic-release
25
-
26
- workflows:
27
- version: 2
28
- release:
29
- jobs:
30
- - release-snapshot:
31
- context: Dreamworld
32
- filters:
33
- branches:
34
- only:
35
- - /^feature\/.+$/
36
- - release:
37
- context: Dreamworld
38
- filters:
39
- branches:
40
- only:
41
- - master