Skip to content

Commit

Permalink
Merge branch 'main' into dependabot/npm_and_yarn/prettier-3.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
andresin87 authored Jun 12, 2024
2 parents 1fd7600 + f5a2f12 commit 1c0e437
Show file tree
Hide file tree
Showing 30 changed files with 737 additions and 17 deletions.
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 'Bug Report'
description: 'File a bug report'
labels: ['Needs Triage', 'Type: Bug']
projects: ['adevinta/4']
body:
- type: 'markdown'
attributes:
Expand Down
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: 'Feature Request'
description: 'Request a feature or enhancement'
labels: ['Needs Triage', 'Type: Feature Request']
projects: ['adevinta/4']
body:
- type: 'markdown'
attributes:
Expand Down
109 changes: 104 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/components/checkbox/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [2.2.11](https://github.com/adevinta/spark/compare/@spark-ui/[email protected]...@spark-ui/[email protected]) (2024-06-07)

### Bug Fixes

- **checkbox:** remove the required attr from checkboxes as soon as 1 checkbox is checked ([bea7ccf](https://github.com/adevinta/spark/commit/bea7ccf3d2c67821d85c937c2129d189e274c8a9)), closes [#2205](https://github.com/adevinta/spark/issues/2205)

## [2.2.10](https://github.com/adevinta/spark/compare/@spark-ui/[email protected]...@spark-ui/[email protected]) (2024-06-06)

**Note:** Version bump only for package @spark-ui/checkbox
Expand Down
2 changes: 1 addition & 1 deletion packages/components/checkbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@spark-ui/checkbox",
"version": "2.2.10",
"version": "2.2.11",
"description": "A control that allows the user to toggle between checked and not checked.",
"publishConfig": {
"access": "public"
Expand Down
32 changes: 32 additions & 0 deletions packages/components/checkbox/src/Checkbox.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -322,5 +322,37 @@ describe('CheckboxGroup', () => {
})
).toBeInTheDocument()
})

it('should remove the required attribute from individual checkboxes when at least one checkbox is checked', async () => {
render(
<FormField name="sports" isRequired>
<FormField.Label>Sports</FormField.Label>

<CheckboxGroup>
<Checkbox value="soccer">Soccer</Checkbox>
<Checkbox value="baseball">Baseball</Checkbox>
</CheckboxGroup>
</FormField>
)

const checkboxEls = within(screen.getByRole('group', { name: 'Sports' })).getAllByRole(
'checkbox'
)

expect(checkboxEls[0]).toHaveAttribute('aria-required', 'true')
expect(checkboxEls[1]).toHaveAttribute('aria-required', 'true')

await userEvent.click(
screen.getByRole('checkbox', {
name: 'Baseball',
})
)

expect(checkboxEls[0]).toHaveAttribute('aria-required', 'false')
expect(checkboxEls[0]).not.toBeRequired()

expect(checkboxEls[1]).toHaveAttribute('aria-required', 'false')
expect(checkboxEls[1]).not.toBeRequired()
})
})
})
17 changes: 15 additions & 2 deletions packages/components/checkbox/src/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { useFormFieldControl } from '@spark-ui/form-field'
import { useMergeRefs } from '@spark-ui/use-merge-refs'
import { cx } from 'class-variance-authority'
import { forwardRef, useId, useRef } from 'react'
import { forwardRef, useId, useMemo, useRef } from 'react'

import { CheckboxGroupContextState, useCheckboxGroup } from './CheckboxGroupContext'
import { CheckboxInput, CheckboxInputProps } from './CheckboxInput'
Expand Down Expand Up @@ -73,12 +73,25 @@ export const Checkbox = forwardRef<HTMLButtonElement, CheckboxProps>(
}
}

const { id, name, isInvalid, isRequired, description, intent } = getCheckboxAttributes({
const {
id,
name,
isInvalid,
description,
intent,
isRequired: isRequiredAttr,
} = getCheckboxAttributes({
fieldState: field,
groupState: group,
checkboxIntent: intentProp,
})

const isRequired = useMemo(() => {
if (!group) return isRequiredAttr

return isRequiredAttr ? !group.value?.length : false
}, [group, isRequiredAttr])

const checkboxLabel = children && (
<CheckboxLabel disabled={disabled} htmlFor={id || innerId} id={innerLabelId}>
{children}
Expand Down
2 changes: 2 additions & 0 deletions packages/components/collapsible/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
src
**/*.stories.*
18 changes: 18 additions & 0 deletions packages/components/collapsible/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

## [0.1.1](https://github.com/adevinta/spark/compare/@spark-ui/[email protected]...@spark-ui/[email protected]) (2024-06-10)

**Note:** Version bump only for package @spark-ui/collapsible

# 0.1.0 (2024-06-07)

### Bug Fixes

- **collapsible:** code review updates, tests and types ([6c351bd](https://github.com/adevinta/spark/commit/6c351bd92a32968c62d77312dacc7bea29825f8e))

### Features

- **collapsible:** collapsible package, using zagjs ([b196c08](https://github.com/adevinta/spark/commit/b196c08ee81974d82838de7c12bf7db184a51eee))
21 changes: 21 additions & 0 deletions packages/components/collapsible/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Adevinta ASA.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
13 changes: 13 additions & 0 deletions packages/components/collapsible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Collapsible
> @spark-ui/collapsible
[![storybook](https://img.shields.io/badge/storybook-black?logo=storybook)](https://sparkui.vercel.app/?path=/docs/components-collapsible--docs)
[![documentation](https://img.shields.io/badge/documentation-black?logo=googledocs)](https://sparkui-adv.vercel.app/docs/components/collapsible)
[![issue](https://img.shields.io/badge/report%20a%20bug-black?logo=openbugbounty&logoColor=red)](https://github.com/adevinta/spark/issues/new?&projects=4&template=bug-report.yml&assignees=&labels=component,collapsible)
[![npm](https://img.shields.io/npm/dt/%40spark-ui/collapsible?logo=npm&labelColor=black)](https://www.npmjs.com/package/@spark-ui/collapsible)


This package is part of the [`@spark-ui`](https://github.com/adevinta/spark) react-js user interface component library project.

[![Issues open](https://img.shields.io/github/issues-search/adevinta/spark?query=is%3Aopen%20label%3Acomponent%20label%3Acollapsible&logo=openbugbounty&logoColor=red&label=issues%20open&color=red)](https://github.com/adevinta/spark/issues?q=is%3Aopen+label%3Acomponent+label%3Acollapsible)
[![NPM](https://img.shields.io/npm/l/%40spark-ui%2Fcollapsible)](https://github.com/adevinta/spark/blob/main/packages/components/collapsible/LICENSE.md)
51 changes: 51 additions & 0 deletions packages/components/collapsible/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name": "@spark-ui/collapsible",
"version": "0.1.1",
"description": "An interactive component which expands/collapses a panel.",
"publishConfig": {
"access": "public"
},
"keywords": [
"@spark-ui",
"react",
"component",
"accessible",
"accessibility",
"wai-aria",
"aria",
"a11y",
"collapsible",
"disclosure"
],
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"scripts": {
"build": "vite build"
},
"peerDependencies": {
"@spark-ui/theme-utils": "^4.0.0",
"react": "^18.0 || ^19.0",
"react-dom": "^18.0 || ^19.0",
"tailwindcss": "^3.0.0"
},
"repository": {
"type": "git",
"url": "https://github.com/adevinta/spark.git",
"directory": "packages/components/collapsible"
},
"config": {
"title": "collapsible",
"category": "components"
},
"bugs": {
"url": "https://github.com/adevinta/spark/issues?q=is%3Aopen+label%3Autility+label%3Acollapsible"
},
"homepage": "https://sparkui.vercel.app",
"license": "MIT",
"dependencies": {
"@spark-ui/slot": "^1.7.1",
"@zag-js/collapsible": "^0.53.0",
"@zag-js/react": "^0.53.0"
}
}
Loading

0 comments on commit 1c0e437

Please sign in to comment.