Skip to content

Commit

Permalink
HLM 5902 (#62)
Browse files Browse the repository at this point in the history
* updated multiselectdropdown categoryselectall functionality

* added key navigation for dropdown options

* pdated dropdown checkbox css

* updated css version

* updated ui-components version
  • Loading branch information
Swathi-eGov authored May 17, 2024
1 parent bf3538c commit a885237
Show file tree
Hide file tree
Showing 16 changed files with 70 additions and 30 deletions.
1 change: 1 addition & 0 deletions react/css/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ frontend/micro-ui/web/public/index.html
# Changelog
```bash
1.8.2-coreui.14 updated dropdown checkbox css
1.8.2-coreui.13 added spacers
1.8.2-coreui.12 updated css for toast info and category option css
1.8.2-coreui.11 added info varinat for toast
Expand Down
2 changes: 1 addition & 1 deletion react/css/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-css",
"version": "1.8.2-coreui.13",
"version": "1.8.2-coreui.14",
"license": "MIT",
"main": "dist/index.css",
"author": "Jagankumar <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
}
input:active~.digit-multiselectdropodwn-custom-checkbox-selectAll,
input:checked~.digit-multiselectdropodwn-custom-checkbox-selectAll {
border: theme(digitv2.spacers.spacer5) solid theme(digitv2.lightTheme.primary-1);
border: 0.125rem solid theme(digitv2.lightTheme.primary-1);
background-color: theme(digitv2.lightTheme.paper-secondary);
}
input:active~.digit-multiselectdropodwn-custom-checkbox-selectAll svg,
Expand Down
2 changes: 1 addition & 1 deletion react/example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build": "webpack --mode production"
},
"dependencies": {
"@egovernments/digit-ui-components": "0.0.1-beta.18",
"@egovernments/digit-ui-components": "0.0.1-beta.20",
"@egovernments/digit-ui-libraries": "1.8.2-beta.1",
"@egovernments/digit-ui-module-common": "1.7.10",
"@egovernments/digit-ui-module-core": "1.8.1-beta.6",
Expand Down
2 changes: 1 addition & 1 deletion react/example/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
rel='stylesheet' type='text/css'>
<link
rel="stylesheet"
href="https://unpkg.com/@egovernments/[email protected].13/dist/index.css"
href="https://unpkg.com/@egovernments/[email protected].14/dist/index.css"
/>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#00bcd1" />
Expand Down
2 changes: 1 addition & 1 deletion react/modules/Project/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.1-beta.4",
"@egovernments/digit-ui-components": "0.0.1-beta.18",
"@egovernments/digit-ui-components": "0.0.1-beta.20",
"lodash": "^4.17.21",
"react": "17.0.2",
"react-date-range": "^1.4.0",
Expand Down
2 changes: 1 addition & 1 deletion react/modules/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"prepublish": "yarn build"
},
"dependencies": {
"@egovernments/digit-ui-components": "0.0.1-beta.18",
"@egovernments/digit-ui-components": "0.0.1-beta.20",
"@egovernments/digit-ui-react-components": "1.8.1-beta.4",
"react": "17.0.2",
"react-dom": "17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion react/modules/sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"dependencies": {
"@egovernments/digit-ui-react-components": "1.8.1-beta.4",
"@egovernments/digit-ui-components": "0.0.1-beta.18",
"@egovernments/digit-ui-components": "0.0.1-beta.20",
"react": "17.0.2",
"react-date-range": "^1.4.0",
"react-dom": "17.0.2",
Expand Down
2 changes: 1 addition & 1 deletion react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
"@egovernments/digit-ui-module-sample": "0.0.1",
"@egovernments/digit-ui-react-components": "1.7.10",
"@egovernments/digit-ui-svg-components": "1.0.4",
"@egovernments/digit-ui-components": "0.0.1-beta.18",
"@egovernments/digit-ui-components": "0.0.1-beta.20",
"babel-loader": "8.1.0",
"clean-webpack-plugin": "4.0.0",
"css-loader": "5.2.6",
Expand Down
1 change: 1 addition & 0 deletions react/ui-components/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ yarn storybook
# Changelog

```bash
0.0.1-beta.20 updated multiselectdropdown categoryselectall functionality and added key navigation for dropdown options
0.0.1-beta.19 making CheckBox more customizable and adding custom color for Button
0.0.1-beta.18 updated dropdown option labels
0.0.1-beta.17 updated toast info varinat css and category option css
Expand Down
4 changes: 2 additions & 2 deletions react/ui-components/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-components",
"version": "0.0.1-beta.19",
"version": "0.0.1-beta.20",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.modern.js",
Expand Down Expand Up @@ -51,7 +51,7 @@
"dist"
],
"dependencies": {
"@egovernments/digit-ui-css": "1.8.2-coreui.13",
"@egovernments/digit-ui-css": "1.8.2-coreui.14",
"@egovernments/digit-ui-libraries": "1.8.1-beta.1",
"@egovernments/digit-ui-svg-components": "1.0.4",
"@googlemaps/js-api-loader": "1.13.10",
Expand Down
16 changes: 12 additions & 4 deletions react/ui-components/src/atoms/Dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,13 @@ const Dropdown = (props) => {
?.indexOf(filterVal?.toUpperCase()) > -1
)) ||
[];
function selectOption(ind) {
onSelect(filteredOption[ind]);
}
function selectOption(ind) {
const optionsToSelect =
props.variant === "nesteddropdown" || props.variant === "treedropdown"
? flattenedOptions
: filteredOption;
onSelect(optionsToSelect[ind]);
}

if (props.isBPAREG && selectedOption) {
let isSelectedSameAsOptions =
Expand Down Expand Up @@ -437,7 +441,11 @@ const Dropdown = (props) => {
}
filterVal={filterVal}
addProps={{
length: filteredOption.length,
length:
props.variant === "nesteddropdown" ||
props.variant === "treedropdown"
? flattenedOptions.length
: filteredOption.length,
currentIndex: optionIndex,
selectOption: selectOption,
}}
Expand Down
2 changes: 1 addition & 1 deletion react/ui-components/src/atoms/ErrorBoundary.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Toast } from '@egovernments/digit-ui-components';
import Toast from "./Toast";
import React, { Component } from 'react';

class ErrorBoundary extends Component {
Expand Down
54 changes: 42 additions & 12 deletions react/ui-components/src/atoms/MultiSelectDropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const MultiSelectDropdown = ({
addSelectAllCheck = false,
addCategorySelectAllCheck = false,
selectAllLabel = "",
categorySelectAllLabel = ""
categorySelectAllLabel = "",
}) => {
const [active, setActive] = useState(false);
const [searchQuery, setSearchQuery] = useState();
Expand Down Expand Up @@ -124,7 +124,7 @@ const MultiSelectDropdown = ({
newCategorySelected[category.code] = allChildrenSelected;
});
setCategorySelected(newCategorySelected);
}, [alreadyQueuedSelectedState]);
}, [options, alreadyQueuedSelectedState]);

function handleOutsideClickAndSubmitSimultaneously() {
setActive(false);
Expand Down Expand Up @@ -248,10 +248,15 @@ const MultiSelectDropdown = ({
const childoptions = parentOption.options;
if (!categorySelected[parentOption.code]) {
childoptions?.forEach((option) => {
dispatch({
type: "ADD_TO_SELECTED_EVENT_QUEUE",
payload: [null, option],
});
const isAlreadySelected = alreadyQueuedSelectedState.some(
(selectedOption) => selectedOption.code === option.code
);
if (!isAlreadySelected) {
dispatch({
type: "ADD_TO_SELECTED_EVENT_QUEUE",
payload: [null, option],
});
}
});
} else {
childoptions?.forEach((option) => {
Expand Down Expand Up @@ -280,13 +285,34 @@ const MultiSelectDropdown = ({
return count;
};

const selectOptionThroughKeys = (e, option) => {
let checked = alreadyQueuedSelectedState.find(
(selectedOption) => selectedOption.code === option.code
)
? true
: false;
if (!checked) {
dispatch({
type: "ADD_TO_SELECTED_EVENT_QUEUE",
payload: [null, option],
});
} else {
dispatch({
type: "REMOVE_FROM_SELECTED_EVENT_QUEUE",
payload: [null, option],
});
}
};

/* Custom function to scroll and select in the dropdowns while using key up and down */
const keyChange = (e) => {
const optionToScroll =
variant === "nestedmultiselect" ? flattenedOptions : filteredOptions;
if (e.key == "ArrowDown") {
setOptionIndex((state) =>
state + 1 == filtOptns.length ? 0 : state + 1
state + 1 == optionToScroll.length ? 0 : state + 1
);
if (optionIndex + 1 == filtOptns.length) {
if (optionIndex + 1 == optionToScroll.length) {
e?.target?.parentElement?.parentElement?.children
?.namedItem("jk-dropdown-unique")
?.scrollTo?.(0, 0);
Expand All @@ -299,7 +325,7 @@ const MultiSelectDropdown = ({
e.preventDefault();
} else if (e.key == "ArrowUp") {
setOptionIndex((state) =>
state !== 0 ? state - 1 : filtOptns.length - 1
state !== 0 ? state - 1 : optionToScroll.length - 1
);
if (optionIndex === 0) {
e?.target?.parentElement?.parentElement?.children
Expand All @@ -313,7 +339,7 @@ const MultiSelectDropdown = ({
}
e.preventDefault();
} else if (e.key == "Enter") {
onSelectToAddToQueue(e, filtOptns[optionIndex]);
selectOptionThroughKeys(e, optionToScroll[optionIndex]);
}
};

Expand All @@ -331,7 +357,9 @@ const MultiSelectDropdown = ({
)
: options;

const parentOptionsWithChildren = filteredOptions.filter(option => option.options && option.options.length > 0);
const parentOptionsWithChildren = filteredOptions.filter(
(option) => option.options && option.options.length > 0
);

const flattenOptions = (options) => {
let flattened = [];
Expand Down Expand Up @@ -484,7 +512,9 @@ const MultiSelectDropdown = ({
addSelectAllCheck ? "selectAll" : ""
}`}
>
<div className="digit-category-name">{t(option[optionsKey])}</div>
<div className="digit-category-name">
{t(option[optionsKey])}
</div>
{addCategorySelectAllCheck && (
<div
className="digit-category-selectAll"
Expand Down
4 changes: 2 additions & 2 deletions react/ui-components/yarn-error.log
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Trace:
npm manifest:
{
"name": "@egovernments/digit-ui-components",
"version": "0.0.1-beta.15",
"version": "0.0.1-beta.20",
"license": "MIT",
"main": "dist/index.js",
"module": "dist/index.modern.js",
Expand Down Expand Up @@ -80,7 +80,7 @@ npm manifest:
"dist"
],
"dependencies": {
"@egovernments/digit-ui-css": "1.8.2-coreui.13",
"@egovernments/digit-ui-css": "1.8.2-coreui.14",
"@egovernments/digit-ui-libraries": "1.8.1-beta.1",
"@egovernments/digit-ui-svg-components": "1.0.4",
"@googlemaps/js-api-loader": "1.13.10",
Expand Down
2 changes: 1 addition & 1 deletion react/yarn-error.log
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ npm manifest:
"dependencies": {
"lodash": "4.17.21",
"microbundle-crl": "0.13.11",
"@egovernments/digit-ui-components": "0.0.1-beta.15",
"@egovernments/digit-ui-components": "0.0.1-beta.20",
"babel-loader": "8.1.0",
"clean-webpack-plugin": "4.0.0",
"react": "17.0.2",
Expand Down

0 comments on commit a885237

Please sign in to comment.