Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

refactor: slider component

Brad Barbin9d79e3653afd
diff --git a/apps/carbon/app/components/Contact.tsx b/apps/carbon/app/components/Contact.tsx
index b2fd64072a..9384adbb92 100644
--- a/apps/carbon/app/components/Contact.tsx
+++ b/apps/carbon/app/components/Contact.tsx
@@ -1,7 +1,6 @@
import {
ActionMenu,
Avatar,
- Dot,
DropdownMenuIcon,
DropdownMenuItem,
HStack,
@@ -52,10 +51,16 @@ const Contact = ({ contact, url, user, actions }: ContactProps) => {
)}
{userStatus === UserStatus.Active && (
- <Dot color="green.400" title="Active" />
+ <span
+ title="Active"
+ className="inline-block green-400 rounded-full w-3 h-3 ml-1.5"
+ />
)}
{userStatus === UserStatus.Inactive && (
- <Dot color="red.400" title="Inactive" />
+ <span
+ title="Inctive"
+ className="inline-block red-400 rounded-full w-3 h-3 ml-1.5"
+ />
)}
</HStack>
diff --git a/apps/carbon/app/components/Form/Number.tsx b/apps/carbon/app/components/Form/Number.tsx
index 1763c2d45f..7fc562fe54 100644
--- a/apps/carbon/app/components/Form/Number.tsx
+++ b/apps/carbon/app/components/Form/Number.tsx
@@ -30,7 +30,6 @@ const Number = forwardRef<HTMLInputElement, FormNumberProps>(
return (
<FormControl isInvalid={!!error} isRequired={isRequired}>
{label && <FormLabel htmlFor={name}>{label}</FormLabel>}
-
<NumberField
{...getInputProps({
id: name,
diff --git a/apps/carbon/app/components/Form/Slider.tsx b/apps/carbon/app/components/Form/Slider.tsx
deleted file mode 100644
index ae0e8ea772..0000000000
--- a/apps/carbon/app/components/Form/Slider.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import {
- FormControl,
- FormErrorMessage,
- FormHelperText,
- FormLabel,
-} from "@carbon/react";
-import type { SliderProps as SliderBaseProps } from "@chakra-ui/react";
-import {
- Box,
- Slider as SliderBase,
- SliderFilledTrack,
- SliderThumb,
- SliderTrack,
-} from "@chakra-ui/react";
-import { forwardRef } from "react";
-import { useField } from "remix-validated-form";
-
-type SliderProps = SliderBaseProps & {
- name: string;
- label?: string;
- isRequired?: boolean;
- helperText?: string;
-};
-
-const Slider = forwardRef<HTMLInputElement, SliderProps>(
- ({ name, label, isRequired, helperText, ...rest }, ref) => {
- const { getInputProps, error } = useField(name);
-
- return (
- <FormControl isInvalid={!!error} isRequired={isRequired}>
- {label && <FormLabel htmlFor={name}>{label}</FormLabel>}
-
- <SliderBase
- {...getInputProps({
- id: name,
- ...rest,
- })}
- >
- <SliderTrack bg="green.100" h={2}>
- <Box position="relative" right={10} />
- <SliderFilledTrack bg="green.500" />
- </SliderTrack>
- <SliderThumb boxSize={6} />
- </SliderBase>
- {helperText && <FormHelperText>{helperText}</FormHelperText>}
- {error && <FormErrorMessage>{error}</FormErrorMessage>}
- </FormControl>
- );
- }
-);
-
-Slider.displayName = "Slider";
-
-export default Slider;
diff --git a/apps/carbon/app/components/Form/index.ts b/apps/carbon/app/components/Form/index.ts
index 4d54824fe3..8d30006719 100644
--- a/apps/carbon/app/components/Form/index.ts
+++ b/apps/carbon/app/components/Form/index.ts
@@ -31,7 +31,6 @@ import SelectControlled from "./SelectControlled";
import Sequence from "./Sequence";
import Service from "./Service";
import Shift from "./Shift";
-import Slider from "./Slider";
import Submit from "./Submit";
import Supplier from "./Supplier";
import SupplierContact from "./SupplierContact";
@@ -76,7 +75,6 @@ export {
Sequence,
Service,
Shift,
- Slider,
Submit,
Supplier,
SupplierContact,
diff --git a/apps/carbon/app/components/Selectors/UserSelect/components/Input.tsx b/apps/carbon/app/components/Selectors/UserSelect/components/Input.tsx
index 6237d94532..1751cc0bbc 100644
--- a/apps/carbon/app/components/Selectors/UserSelect/components/Input.tsx
+++ b/apps/carbon/app/components/Selectors/UserSelect/components/Input.tsx
@@ -27,49 +27,48 @@ const Input = () => {
return (
<InputGroup>
- {isMulti ? (
- <InputLeftElement>
- <AvatarGroup size="xs" limit={2}>
+ {!readOnly &&
+ (isMulti ? (
+ <InputLeftElement>
+ <AvatarGroup size="xs" limit={2}>
+ <Avatar size="xs" />
+ <Avatar size="xs" />
+ </AvatarGroup>
+ </InputLeftElement>
+ ) : (
+ <InputLeftElement>
<Avatar size="xs" />
- <Avatar size="xs" />
- </AvatarGroup>
- </InputLeftElement>
- ) : (
- <InputLeftElement>
- <Avatar size="xs" />
- </InputLeftElement>
- )}
+ </InputLeftElement>
+ ))}
<InputBase
{...inputProps}
- readOnly={disabled || readOnly}
+ isReadOnly={disabled || readOnly}
isDisabled={disabled || readOnly}
onBlur={onInputBlur}
onChange={onInputChange}
- onFocus={onInputFocus}
+ onFocus={readOnly || disabled ? undefined : onInputFocus}
placeholder={placeholder}
spellCheck="false"
ref={inputRef}
type="text"
value={inputValue}
-
- // pl={isMulti ? "3.175rem" : undefined}
- // pr="2.5rem"
/>
-
- <InputRightElement>
- <HStack spacing={1}>
- {loading && <Spinner size="sm" />}
- {!loading && !disabled && inputValue.length > 0 && (
- <IconButton
- aria-label="Clear search query"
- icon={<MdOutlineClear />}
- onClick={onClearInput}
- variant="ghost"
- />
- )}
- </HStack>
- </InputRightElement>
+ {!readOnly && !disabled && (
+ <InputRightElement>
+ <HStack spacing={1}>
+ {loading && <Spinner size="sm" />}
+ {!loading && !disabled && inputValue.length > 0 && (
+ <IconButton
+ aria-label="Clear search query"
+ icon={<MdOutlineClear />}
+ onClick={onClearInput}
+ variant="ghost"
+ />
+ )}
+ </HStack>
+ </InputRightElement>
+ )}
</InputGroup>
);
};
diff --git a/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart/AbilityChart.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart/AbilityChart.tsx
index 727ad30a58..a636615a19 100644
--- a/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart/AbilityChart.tsx
+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilityChart/AbilityChart.tsx
@@ -19,6 +19,16 @@ type AbilityChartProps = {
onDataChange?: (data: AbilityDatum[]) => void;
};
+const green = {
+ 300: "rgb(134 239 172)",
+ 500: "rgb(34 197 94)",
+};
+
+const zinc = {
+ 500: "rgb(113 113 122)",
+ 600: "rgb(82 82 91)",
+};
+
const AbilityChart = ({
data,
shadowWeeks,
@@ -105,8 +115,8 @@ const AbilityChart = ({
<LinearGradient
id="fill"
- from="rgb(217 249 157)"
- to="rgb(82 82 91)"
+ from={green[300]}
+ to={zinc[500]}
fromOpacity={0.2}
toOpacity={0}
/>
@@ -115,7 +125,7 @@ const AbilityChart = ({
id="diagonalLines"
height={6}
width={6}
- stroke="rgb(82 82 91)"
+ stroke={zinc[600]}
strokeWidth={1}
orientation={["diagonal"]}
/>
@@ -149,7 +159,7 @@ const AbilityChart = ({
data={data}
y={(d) => yScale(y(d))}
x={(d) => xScale(x(d))}
- stroke="rgb(77 124 15)"
+ stroke={green[500]}
strokeOpacity="0.8"
strokeWidth={2}
curve={curveNatural}
@@ -205,10 +215,8 @@ const AbilityChart = ({
cx={x}
cy={y}
r={isDragging ? 10 : 6}
- fill="rgb(132 204 22)"
transform={`translate(${dx}, ${dy})`}
fillOpacity={0.9}
- stroke="rgb(101 163 13)"
strokeWidth={2}
onMouseMove={dragMove}
onMouseUp={dragEnd}
@@ -216,6 +224,7 @@ const AbilityChart = ({
onTouchStart={dragStart}
onTouchMove={dragMove}
onTouchEnd={dragEnd}
+ className="fill-green-400 stroke-green-600"
/>
)}
</Drag>
diff --git a/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx b/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx
index 4da8c888b1..03e1763c7f 100644
--- a/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx
+++ b/apps/carbon/app/modules/resources/ui/Abilities/AbilityEmployeesTable/AbilityEmployeesTable.tsx
@@ -1,5 +1,5 @@
-import { DropdownMenuIcon, HStack, MenuItem } from "@carbon/react";
-import { Badge, Progress } from "@chakra-ui/react";
+import { Badge, DropdownMenuIcon, HStack, MenuItem } from "@carbon/react";
+import { Progress } from "@chakra-ui/react";
import { useNavigate, useParams } from "@remix-run/react";
import type { ColumnDef } from "@tanstack/react-table";
import { useCallback, useMemo } from "react";
@@ -79,18 +79,12 @@ const AbilityEmployeesTable = ({
const status = row.original.status;
return (
<Badge
- size="sm"
variant={
status === AbilityEmployeeStatus.Complete
- ? undefined
- : "outline"
- }
- colorScheme={
- status === AbilityEmployeeStatus.Complete
- ? "green"
+ ? "default"
: status === AbilityEmployeeStatus.InProgress
- ? "yellow"
- : "gray"
+ ? "outline"
+ : "secondary"
}
>
{status}
diff --git a/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx
index 3d8b483a81..6af1065df4 100644
--- a/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Abilities/EmployeeAbilityForm/EmployeeAbilityForm.tsx
@@ -13,7 +13,7 @@ import {
import { useParams } from "@remix-run/react";
import { useState } from "react";
import { ValidatedForm } from "remix-validated-form";
-import { Employee, Hidden, Select, Slider, Submit } from "~/components/Form";
+import { Employee, Hidden, Number, Select, Submit } from "~/components/Form";
import { usePermissions } from "~/hooks";
import type { Ability } from "~/modules/resources";
import {
@@ -30,7 +30,7 @@ type EmployeeAbilityFormProps = {
onClose: () => void;
};
-const defaultPercent = 50;
+const defaultPercent = 0.5;
const EmployeeAbilityForm = ({
ability,
@@ -45,7 +45,7 @@ const EmployeeAbilityForm = ({
? !permissions.can("update", "resources")
: !permissions.can("create", "resources");
- const days = (percent: number) => weeks * 5 * (percent / 100);
+ const days = (percent: number) => weeks * 5 * percent;
const [trainingDays, setTrainingDays] = useState(
days(initialValues.trainingPercent ?? defaultPercent)
);
@@ -113,14 +113,14 @@ const EmployeeAbilityForm = ({
/>
{inProgress && (
<>
- <Slider
+ <Number
name="trainingPercent"
label="Training Percent"
onChange={(value) => updateTrainingDays(value)}
defaultValue={defaultPercent}
- min={0}
- max={100}
- step={10}
+ formatOptions={{ style: "percent" }}
+ minValue={0}
+ maxValue={1}
/>
<Hidden name="trainingDays" value={trainingDays} />
</>
diff --git a/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx b/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx
index fe5f0deb36..700a0d4003 100644
--- a/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx
+++ b/apps/carbon/app/modules/resources/ui/Partners/PartnerForm/PartnerForm.tsx
@@ -6,6 +6,8 @@ import {
DrawerFooter,
DrawerHeader,
DrawerTitle,
+ FormControl,
+ FormLabel,
HStack,
VStack,
useMount,
@@ -154,13 +156,16 @@ const SupplierLocationsBySupplier = ({
};
return (
- <SelectControlled
- name="id"
- options={supplierLocations}
- value={supplierLocation ?? undefined}
- onChange={onChange}
- isReadOnly={isReadOnly}
- />
+ <FormControl>
+ <FormLabel>Supplier Location</FormLabel>
+ <SelectControlled
+ name="id"
+ options={supplierLocations}
+ value={supplierLocation ?? undefined}
+ onChange={onChange}
+ isReadOnly={isReadOnly}
+ />
+ </FormControl>
);
};
diff --git a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx
index eaca129ce2..2347522dd6 100644
--- a/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx
+++ b/apps/carbon/app/routes/x+/resources+/ability.$abilityId.employee.$id.tsx
@@ -127,5 +127,5 @@ export default function EmployeeAbilityRoute() {
function getTrainingPercent(traniningDays?: number, weeks?: number) {
if (!traniningDays || !weeks) return 0;
- return (traniningDays / 5 / weeks) * 100;
+ return traniningDays / 5 / weeks;
}
diff --git a/package-lock.json b/package-lock.json
index 620914b6c1..683b27fd46 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -4426,88 +4426,6 @@
"@babel/runtime": "^7.13.10"
}
},
- "node_modules/@radix-ui/react-accessible-icon": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-accessible-icon/-/react-accessible-icon-1.0.3.tgz",
- "integrity": "sha512-duVGKeWPSUILr/MdlPxV+GeULTc2rS1aihGdQ3N2qCUPMgxYLxvAsHJM3mCVLF8d5eK+ympmB22mb1F3a5biNw==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/react-visually-hidden": "1.0.3"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
- "node_modules/@radix-ui/react-accordion": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-accordion/-/react-accordion-1.1.2.tgz",
- "integrity": "sha512-fDG7jcoNKVjSK6yfmuAs0EnPDro0WMXIhMtXdTBWqEioVW206ku+4Lw07e+13lUkFkpoEQ2PdeMIAGpdqEAmDg==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/primitive": "1.0.1",
- "@radix-ui/react-collapsible": "1.0.3",
- "@radix-ui/react-collection": "1.0.3",
- "@radix-ui/react-compose-refs": "1.0.1",
- "@radix-ui/react-context": "1.0.1",
- "@radix-ui/react-direction": "1.0.1",
- "@radix-ui/react-id": "1.0.1",
- "@radix-ui/react-primitive": "1.0.3",
- "@radix-ui/react-use-controllable-state": "1.0.1"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
- "node_modules/@radix-ui/react-alert-dialog": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-alert-dialog/-/react-alert-dialog-1.0.5.tgz",
- "integrity": "sha512-OrVIOcZL0tl6xibeuGt5/+UxoT2N27KCFOPjFyfXMnchxSHZ/OW7cCX2nGlIYJrbHK/fczPcFzAwvNBB6XBNMA==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/primitive": "1.0.1",
- "@radix-ui/react-compose-refs": "1.0.1",
- "@radix-ui/react-context": "1.0.1",
- "@radix-ui/react-dialog": "1.0.5",
- "@radix-ui/react-primitive": "1.0.3",
- "@radix-ui/react-slot": "1.0.2"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
"node_modules/@radix-ui/react-arrow": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-arrow/-/react-arrow-1.0.3.tgz",
@@ -4531,29 +4449,6 @@
}
}
},
- "node_modules/@radix-ui/react-aspect-ratio": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-aspect-ratio/-/react-aspect-ratio-1.0.3.tgz",
- "integrity": "sha512-fXR5kbMan9oQqMuacfzlGG/SQMcmMlZ4wrvpckv8SgUulD0MMpspxJrxg/Gp/ISV3JfV1AeSWTYK9GvxA4ySwA==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/react-primitive": "1.0.3"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
"node_modules/@radix-ui/react-avatar": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/@radix-ui/react-avatar/-/react-avatar-1.0.4.tgz",
@@ -4610,36 +4505,6 @@
}
}
},
- "node_modules/@radix-ui/react-collapsible": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-collapsible/-/react-collapsible-1.0.3.tgz",
- "integrity": "sha512-UBmVDkmR6IvDsloHVN+3rtx4Mi5TFvylYXpluuv0f37dtaz3H99bp8No0LGXRigVpl3UAT4l9j6bIchh42S/Gg==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/primitive": "1.0.1",
- "@radix-ui/react-compose-refs": "1.0.1",
- "@radix-ui/react-context": "1.0.1",
- "@radix-ui/react-id": "1.0.1",
- "@radix-ui/react-presence": "1.0.1",
- "@radix-ui/react-primitive": "1.0.3",
- "@radix-ui/react-use-controllable-state": "1.0.1",
- "@radix-ui/react-use-layout-effect": "1.0.1"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
"node_modules/@radix-ui/react-collection": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-collection/-/react-collection-1.0.3.tgz",
@@ -4952,29 +4817,6 @@
}
}
},
- "node_modules/@radix-ui/react-label": {
- "version": "2.0.2",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-label/-/react-label-2.0.2.tgz",
- "integrity": "sha512-N5ehvlM7qoTLx7nWPodsPYPgMzA5WM8zZChQg8nyFJKnDO5WHdba1vv5/H6IO5LtJMfD2Q3wh1qHFGNtK0w3bQ==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/react-primitive": "1.0.3"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
"node_modules/@radix-ui/react-menu": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@radix-ui/react-menu/-/react-menu-2.0.6.tgz",
@@ -5039,74 +4881,6 @@
}
}
},
- "node_modules/@radix-ui/react-menubar": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-menubar/-/react-menubar-1.0.4.tgz",
- "integrity": "sha512-bHgUo9gayKZfaQcWSSLr++LyS0rgh+MvD89DE4fJ6TkGHvjHgPaBZf44hdka7ogOxIOdj9163J+5xL2Dn4qzzg==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/primitive": "1.0.1",
- "@radix-ui/react-collection": "1.0.3",
- "@radix-ui/react-compose-refs": "1.0.1",
- "@radix-ui/react-context": "1.0.1",
- "@radix-ui/react-direction": "1.0.1",
- "@radix-ui/react-id": "1.0.1",
- "@radix-ui/react-menu": "2.0.6",
- "@radix-ui/react-primitive": "1.0.3",
- "@radix-ui/react-roving-focus": "1.0.4",
- "@radix-ui/react-use-controllable-state": "1.0.1"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
- "node_modules/@radix-ui/react-navigation-menu": {
- "version": "1.1.4",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-navigation-menu/-/react-navigation-menu-1.1.4.tgz",
- "integrity": "sha512-Cc+seCS3PmWmjI51ufGG7zp1cAAIRqHVw7C9LOA2TZ+R4hG6rDvHcTqIsEEFLmZO3zNVH72jOOE7kKNy8W+RtA==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/primitive": "1.0.1",
- "@radix-ui/react-collection": "1.0.3",
- "@radix-ui/react-compose-refs": "1.0.1",
- "@radix-ui/react-context": "1.0.1",
- "@radix-ui/react-direction": "1.0.1",
- "@radix-ui/react-dismissable-layer": "1.0.5",
- "@radix-ui/react-id": "1.0.1",
- "@radix-ui/react-presence": "1.0.1",
- "@radix-ui/react-primitive": "1.0.3",
- "@radix-ui/react-use-callback-ref": "1.0.1",
- "@radix-ui/react-use-controllable-state": "1.0.1",
- "@radix-ui/react-use-layout-effect": "1.0.1",
- "@radix-ui/react-use-previous": "1.0.1",
- "@radix-ui/react-visually-hidden": "1.0.3"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
"node_modules/@radix-ui/react-popover": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/@radix-ui/react-popover/-/react-popover-1.0.7.tgz",
@@ -5270,30 +5044,6 @@
}
}
},
- "node_modules/@radix-ui/react-progress": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-progress/-/react-progress-1.0.3.tgz",
- "integrity": "sha512-5G6Om/tYSxjSeEdrb1VfKkfZfn/1IlPWd731h2RfPuSbIfNUgfqAwbKfJCg/PP6nuUCTrYzalwHSpSinoWoCag==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/react-context": "1.0.1",
- "@radix-ui/react-primitive": "1.0.3"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
"node_modules/@radix-ui/react-radio-group": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/@radix-ui/react-radio-group/-/react-radio-group-1.1.3.tgz",
@@ -5357,37 +5107,6 @@
}
}
},
- "node_modules/@radix-ui/react-scroll-area": {
- "version": "1.0.5",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-scroll-area/-/react-scroll-area-1.0.5.tgz",
- "integrity": "sha512-b6PAgH4GQf9QEn8zbT2XUHpW5z8BzqEc7Kl11TwDrvuTrxlkcjTD5qa/bxgKr+nmuXKu4L/W5UZ4mlP/VG/5Gw==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/number": "1.0.1",
- "@radix-ui/primitive": "1.0.1",
- "@radix-ui/react-compose-refs": "1.0.1",
- "@radix-ui/react-context": "1.0.1",
- "@radix-ui/react-direction": "1.0.1",
- "@radix-ui/react-presence": "1.0.1",
- "@radix-ui/react-primitive": "1.0.3",
- "@radix-ui/react-use-callback-ref": "1.0.1",
- "@radix-ui/react-use-layout-effect": "1.0.1"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
"node_modules/@radix-ui/react-select": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/@radix-ui/react-select/-/react-select-2.0.0.tgz",
@@ -5478,39 +5197,6 @@
}
}
},
- "node_modules/@radix-ui/react-slider": {
- "version": "1.1.2",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-slider/-/react-slider-1.1.2.tgz",
- "integrity": "sha512-NKs15MJylfzVsCagVSWKhGGLNR1W9qWs+HtgbmjjVUB3B9+lb3PYoXxVju3kOrpf0VKyVCtZp+iTwVoqpa1Chw==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/number": "1.0.1",
- "@radix-ui/primitive": "1.0.1",
- "@radix-ui/react-collection": "1.0.3",
- "@radix-ui/react-compose-refs": "1.0.1",
- "@radix-ui/react-context": "1.0.1",
- "@radix-ui/react-direction": "1.0.1",
- "@radix-ui/react-primitive": "1.0.3",
- "@radix-ui/react-use-controllable-state": "1.0.1",
- "@radix-ui/react-use-layout-effect": "1.0.1",
- "@radix-ui/react-use-previous": "1.0.1",
- "@radix-ui/react-use-size": "1.0.1"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
"node_modules/@radix-ui/react-slot": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/@radix-ui/react-slot/-/react-slot-1.0.2.tgz",
@@ -5622,60 +5308,6 @@
}
}
},
- "node_modules/@radix-ui/react-toggle": {
- "version": "1.0.3",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle/-/react-toggle-1.0.3.tgz",
- "integrity": "sha512-Pkqg3+Bc98ftZGsl60CLANXQBBQ4W3mTFS9EJvNxKMZ7magklKV69/id1mlAlOFDDfHvlCms0fx8fA4CMKDJHg==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/primitive": "1.0.1",
- "@radix-ui/react-primitive": "1.0.3",
- "@radix-ui/react-use-controllable-state": "1.0.1"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
- "node_modules/@radix-ui/react-toggle-group": {
- "version": "1.0.4",
- "resolved": "https://registry.npmjs.org/@radix-ui/react-toggle-group/-/react-toggle-group-1.0.4.tgz",
- "integrity": "sha512-Uaj/M/cMyiyT9Bx6fOZO0SAG4Cls0GptBWiBmBxofmDbNVnYYoyRWj/2M/6VCi/7qcXFWnHhRUfdfZFvvkuu8A==",
- "dependencies": {
- "@babel/runtime": "^7.13.10",
- "@radix-ui/primitive": "1.0.1",
- "@radix-ui/react-context": "1.0.1",
- "@radix-ui/react-direction": "1.0.1",
- "@radix-ui/react-primitive": "1.0.3",
- "@radix-ui/react-roving-focus": "1.0.4",
- "@radix-ui/react-toggle": "1.0.3",
- "@radix-ui/react-use-controllable-state": "1.0.1"
- },
- "peerDependencies": {
- "@types/react": "*",
- "@types/react-dom": "*",
- "react": "^16.8 || ^17.0 || ^18.0",
- "react-dom": "^16.8 || ^17.0 || ^18.0"
- },
- "peerDependenciesMeta": {
- "@types/react": {
- "optional": true
- },
- "@types/react-dom": {
- "optional": true
- }
- }
- },
"node_modules/@radix-ui/react-tooltip": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/@radix-ui/react-tooltip/-/react-tooltip-1.0.7.tgz",
@@ -30242,33 +29874,20 @@
"version": "0.0.0",
"license": "Apache-2.0",
"dependencies": {
- "@radix-ui/react-accessible-icon": "^1.0.3",
- "@radix-ui/react-accordion": "^1.1.2",
- "@radix-ui/react-alert-dialog": "^1.0.4",
- "@radix-ui/react-aspect-ratio": "^1.0.3",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
- "@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-context-menu": "^2.1.4",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-hover-card": "^1.0.6",
- "@radix-ui/react-label": "^2.0.2",
- "@radix-ui/react-menubar": "^1.0.3",
- "@radix-ui/react-navigation-menu": "^1.1.3",
"@radix-ui/react-popover": "^1.0.6",
- "@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-radio-group": "^1.1.3",
- "@radix-ui/react-scroll-area": "^1.0.4",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-separator": "^1.0.3",
- "@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.4",
- "@radix-ui/react-toggle": "^1.0.3",
- "@radix-ui/react-toggle-group": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.6",
"@react-aria/button": "^3.8.0",
"@react-aria/calendar": "^3.4.0",
diff --git a/packages/react/package.json b/packages/react/package.json
index 00d9a139a3..968ac1e7ad 100644
--- a/packages/react/package.json
+++ b/packages/react/package.json
@@ -21,33 +21,20 @@
"preset": "@carbon/jest/node"
},
"dependencies": {
- "@radix-ui/react-accessible-icon": "^1.0.3",
- "@radix-ui/react-accordion": "^1.1.2",
- "@radix-ui/react-alert-dialog": "^1.0.4",
- "@radix-ui/react-aspect-ratio": "^1.0.3",
"@radix-ui/react-avatar": "^1.0.3",
"@radix-ui/react-checkbox": "^1.0.4",
- "@radix-ui/react-collapsible": "^1.0.3",
"@radix-ui/react-context-menu": "^2.1.4",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-dropdown-menu": "^2.0.5",
"@radix-ui/react-hover-card": "^1.0.6",
- "@radix-ui/react-label": "^2.0.2",
- "@radix-ui/react-menubar": "^1.0.3",
- "@radix-ui/react-navigation-menu": "^1.1.3",
"@radix-ui/react-popover": "^1.0.6",
- "@radix-ui/react-progress": "^1.0.3",
"@radix-ui/react-radio-group": "^1.1.3",
- "@radix-ui/react-scroll-area": "^1.0.4",
"@radix-ui/react-select": "^2.0.0",
"@radix-ui/react-separator": "^1.0.3",
- "@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-slot": "^1.0.2",
"@radix-ui/react-switch": "^1.0.3",
"@radix-ui/react-tabs": "^1.0.4",
"@radix-ui/react-toast": "^1.1.4",
- "@radix-ui/react-toggle": "^1.0.3",
- "@radix-ui/react-toggle-group": "^1.0.4",
"@radix-ui/react-tooltip": "^1.0.6",
"@react-aria/button": "^3.8.0",
"@react-aria/calendar": "^3.4.0",
diff --git a/packages/react/src/Dot.tsx b/packages/react/src/Dot.tsx
deleted file mode 100644
index 1b75bb8708..0000000000
--- a/packages/react/src/Dot.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import type { BoxProps } from "@chakra-ui/react";
-import { Box } from "@chakra-ui/react";
-
-type DotProps = BoxProps & {
- color: string;
- size?: number;
- title?: string;
-};
-
-const Dot = ({ color, size = 3, title, ...props }: DotProps) => {
- return (
- <Box
- as="span"
- title={title}
- display="inline-block"
- bg={color}
- borderRadius="full"
- w={size}
- h={size}
- ml={size / 2}
- {...props}
- />
- );
-};
-
-export { Dot };
diff --git a/packages/react/src/Form/FormLabel.tsx b/packages/react/src/Form/FormLabel.tsx
index 0dd6cd9725..c15719ebe8 100644
--- a/packages/react/src/Form/FormLabel.tsx
+++ b/packages/react/src/Form/FormLabel.tsx
@@ -4,9 +4,9 @@ import { cn } from "~/utils/cn";
import type { FormControlOptions } from "./FormControl";
import { useFormControlContext } from "./FormControl";
-import * as LabelPrimitive from "@radix-ui/react-label";
import type { VariantProps } from "class-variance-authority";
import { cva } from "class-variance-authority";
+import * as ReactAria from "react-aria-components";
const labelVariants = cva(
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70 text-foreground",
@@ -23,12 +23,12 @@ const labelVariants = cva(
);
export interface FormLabelProps
- extends ComponentPropsWithoutRef<typeof LabelPrimitive.Root>,
+ extends ComponentPropsWithoutRef<typeof ReactAria.Label>,
Omit<VariantProps<typeof labelVariants>, "isInvalid">,
FormControlOptions {}
export const FormLabel = forwardRef<
- ElementRef<typeof LabelPrimitive.Root>,
+ ElementRef<typeof ReactAria.Label>,
FormLabelProps
>((props, ref) => {
const { className, children, ...rest } = props;
@@ -37,7 +37,7 @@ export const FormLabel = forwardRef<
const labelProps = field?.getLabelProps(rest, ref) ?? { ref, ...rest };
return (
- <LabelPrimitive.Root
+ <ReactAria.Label
{...labelProps}
ref={ref}
className={cn(labelVariants({ isInvalid: field?.isInvalid }), className)}
@@ -45,7 +45,7 @@ export const FormLabel = forwardRef<
>
{children}
{field?.isRequired && <span className="text-destructive"> *</span>}
- </LabelPrimitive.Root>
+ </ReactAria.Label>
);
});
diff --git a/packages/react/src/Hyperlink.tsx b/packages/react/src/Hyperlink.tsx
index 08fee5173c..8c272f6a01 100644
--- a/packages/react/src/Hyperlink.tsx
+++ b/packages/react/src/Hyperlink.tsx
@@ -3,14 +3,27 @@ import { forwardRef } from "react";
import { cn } from "./utils/cn";
const Hyperlink = forwardRef<ElementRef<"a">, ComponentPropsWithoutRef<"a">>(
- ({ className, ...props }, ref) => (
- // eslint-disable-next-line jsx-a11y/anchor-has-content
- <a
- {...props}
- ref={ref}
- className={cn("text-primary hover:underline cursor-pointer", className)}
- />
- )
+ ({ className, href, children, ...props }, ref) => {
+ const hasHref = !!href;
+ return hasHref ? (
+ <a
+ {...props}
+ href={href}
+ ref={ref}
+ className={cn("text-primary hover:underline cursor-pointer", className)}
+ >
+ {children}
+ </a>
+ ) : (
+ <span
+ {...props}
+ ref={ref}
+ className={cn("text-primary hover:underline cursor-pointer", className)}
+ >
+ {children}
+ </span>
+ );
+ }
);
Hyperlink.displayName = "Hyperlink";
diff --git a/packages/react/src/Submit/BorderFollower.tsx b/packages/react/src/Submit/BorderFollower.tsx
deleted file mode 100644
index c0092674d3..0000000000
--- a/packages/react/src/Submit/BorderFollower.tsx
+++ /dev/null
@@ -1,79 +0,0 @@
-import { chakra } from "@chakra-ui/react";
-import {
- motion,
- useAnimationFrame,
- useMotionTemplate,
- useMotionValue,
- useTransform,
-} from "framer-motion";
-import { useRef } from "react";
-
-const Svg = chakra("svg");
-
-const BorderFollower = ({
- children,
- duration = 2000,
- radius,
- ...otherProps
-}: any) => {
- const pathRef = useRef<SVGRectElement>();
- const progress = useMotionValue<number>(0);
-
- useAnimationFrame((time) => {
- const length = pathRef.current?.getTotalLength();
- if (length) {
- const pxPerMillisecond = length / duration;
- progress.set((time * pxPerMillisecond) % length);
- }
- });
-
- const x = useTransform(
- progress,
- (val) => pathRef.current?.getPointAtLength(val).x
- );
- const y = useTransform(
- progress,
- (val) => pathRef.current?.getPointAtLength(val).y
- );
-
- const transform = useMotionTemplate`translateX(${x}px) translateY(${y}px) translateX(-50%) translateY(-50%)`;
-
- return (
- <>
- <Svg
- xmlns="http://www.w3.org/2000/svg"
- preserveAspectRatio="none"
- pos="absolute"
- width="100%"
- height="100%"
- {...otherProps}
- >
- <rect
- fill="none"
- width="100%"
- height="100%"
- // @ts-ignore
- ref={pathRef}
- rx={radius}
- ry={radius}
- />
- <foreignObject x="0" y="0" width="100%" height="100%">
- <motion.div
- style={{
- position: "absolute",
- top: 0,
- left: 0,
- display: "inline-block",
- transform,
- background: "#002aff",
- }}
- >
- {children}
- </motion.div>
- </foreignObject>
- </Svg>
- </>
- );
-};
-
-export default BorderFollower;
diff --git a/packages/react/src/Submit/BorderMask.tsx b/packages/react/src/Submit/BorderMask.tsx
deleted file mode 100644
index 8b7c5c779e..0000000000
--- a/packages/react/src/Submit/BorderMask.tsx
+++ /dev/null
@@ -1,43 +0,0 @@
-import type { BoxProps } from "@chakra-ui/react";
-import { Box } from "@chakra-ui/react";
-
-interface BorderMaskProps extends BoxProps {
- width: string | number;
- radius?: string | number;
-}
-
-const BorderMask = ({
- width,
- radius = "inherit",
- children,
- ...otherProps
-}: BorderMaskProps) => {
- const widthWithUnit = typeof width === "number" ? width + "px" : width;
- return (
- <Box
- pos="absolute"
- inset={`calc(-1 * ${widthWithUnit})`}
- pointerEvents="none"
- borderWidth={width}
- borderRadius={radius}
- borderColor="transparent"
- style={{
- WebkitMask:
- "linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0)",
- WebkitMaskComposite: "xor",
- maskComposite: "exclude",
- }}
- {...otherProps}
- >
- <Box
- pos="absolute"
- inset={`calc(-2 * ${widthWithUnit})`}
- overflow="hidden"
- >
- {children}
- </Box>
- </Box>
- );
-};
-
-export default BorderMask;
diff --git a/packages/react/src/Submit/Submit.tsx b/packages/react/src/Submit/Submit.tsx
deleted file mode 100644
index bd77485d37..0000000000
--- a/packages/react/src/Submit/Submit.tsx
+++ /dev/null
@@ -1,50 +0,0 @@
-import type { ButtonProps as ChakraButtonProps } from "@chakra-ui/react";
-import { Box, Button as ChakraButton } from "@chakra-ui/react";
-import { AnimatePresence, motion } from "framer-motion";
-import BorderFollower from "./BorderFollower";
-import BorderMask from "./BorderMask";
-
-const MotionBox = motion(Box);
-
-const variants = {
- hidden: {
- opacity: 0,
- },
- visible: {
- opacity: 0.3,
- },
-};
-
-interface ButtonProps extends ChakraButtonProps {}
-
-const Button = ({ isLoading, children, ...props }: ButtonProps) => {
- return (
- <ChakraButton
- {...props}
- isDisabled={isLoading || props.isDisabled}
- borderColor="gray.600"
- borderStyle="solid"
- borderWidth={2}
- >
- <BorderMask width={2}>
- <AnimatePresence>
- {isLoading && (
- <BorderFollower duration={1400} radius="1rem">
- <MotionBox
- w={20}
- h={20}
- variants={variants}
- initial="hidden"
- animate="visible"
- exit="hidden"
- />
- </BorderFollower>
- )}
- </AnimatePresence>
- </BorderMask>
- {children}
- </ChakraButton>
- );
-};
-
-export default Button;
diff --git a/packages/react/src/Submit/index.ts b/packages/react/src/Submit/index.ts
deleted file mode 100644
index eb0ba2d0c6..0000000000
--- a/packages/react/src/Submit/index.ts
+++ /dev/null
@@ -1,3 +0,0 @@
-import Submit from "./Submit";
-
-export default Submit;
diff --git a/packages/react/src/index.tsx b/packages/react/src/index.tsx
index c92efcb7e9..ab29b4248c 100644
--- a/packages/react/src/index.tsx
+++ b/packages/react/src/index.tsx
@@ -58,7 +58,6 @@ import {
DateTimePicker,
TimePicker,
} from "./Date";
-import { Dot } from "./Dot";
import {
Drawer,
DrawerBody,
@@ -169,7 +168,6 @@ import {
SelectValue,
} from "./Select";
import { Status } from "./Status";
-import Submit from "./Submit";
import { Switch } from "./Switch";
import { Table, TableCaption, Tbody, Td, Tfoot, Th, Thead, Tr } from "./Table";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "./Tabs";
@@ -243,7 +241,6 @@ export {
DatePicker,
DateRangePicker,
DateTimePicker,
- Dot,
Drawer,
DrawerBody,
DrawerCloseButton,
@@ -338,7 +335,6 @@ export {
SelectTrigger,
SelectValue,
Status,
- Submit,
Switch,
Table,
TableCaption,