dirk-cfx-react 1.0.36 → 1.0.38

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.
@@ -1,5 +1,5 @@
1
1
  import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
2
- import { Flex, Text, Image, useMantineTheme } from '@mantine/core';
2
+ import { Flex, Text, Image, useMantineTheme, alpha } from '@mantine/core';
3
3
  import '@mantine/core/styles.css';
4
4
  import '@mantine/notifications/styles.css';
5
5
  import './styles/fonts.css';
@@ -15,6 +15,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
15
15
  import { motion, AnimatePresence, useMotionValue } from 'framer-motion';
16
16
  import clickSoundUrl from '../click_sound-PNCRRTM4.mp3';
17
17
  import hoverSoundUrl from '../hover_sound-NBUA222C.mp3';
18
+ import { useClickOutside } from '@mantine/hooks';
18
19
 
19
20
  // src/components/BorderedIcon.tsx
20
21
 
@@ -163,11 +164,11 @@ var colorNames = {
163
164
  Yellow: { r: 255, g: 255, b: 0 },
164
165
  YellowGreen: { r: 154, g: 205, b: 50 }
165
166
  };
166
- function colorWithAlpha(color, alpha) {
167
+ function colorWithAlpha(color, alpha2) {
167
168
  const lowerCasedColor = color.toLowerCase();
168
169
  if (colorNames[lowerCasedColor]) {
169
170
  const rgb = colorNames[lowerCasedColor];
170
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
171
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha2})`;
171
172
  }
172
173
  if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
173
174
  const hex = color.slice(1);
@@ -175,12 +176,12 @@ function colorWithAlpha(color, alpha) {
175
176
  const r = bigint >> 16 & 255;
176
177
  const g = bigint >> 8 & 255;
177
178
  const b = bigint & 255;
178
- return `rgba(${r}, ${g}, ${b}, ${alpha})`;
179
+ return `rgba(${r}, ${g}, ${b}, ${alpha2})`;
179
180
  }
180
181
  if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
181
182
  const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
182
183
  if (result) {
183
- return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha})`;
184
+ return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha2})`;
184
185
  }
185
186
  }
186
187
  return color;
@@ -638,7 +639,7 @@ function SegmentedControl(props) {
638
639
  bg: "rgba(33, 33, 33, 0.6)",
639
640
  w: props.w || "fit-content",
640
641
  style: {
641
- borderRadius: theme.radius.xs,
642
+ borderRadius: props.enableRadius !== false ? theme.radius.xs : 0,
642
643
  overflow: "hidden"
643
644
  },
644
645
  ...props,
@@ -662,6 +663,7 @@ function SegmentedControl(props) {
662
663
  icon: item.icon,
663
664
  rightSection: item.rightSection,
664
665
  fz: props.fz,
666
+ color: props.color,
665
667
  selected: !props.multi ? props.value === item.value : Array.isArray(props.value) && props.value.includes(item.value),
666
668
  onClick: () => {
667
669
  if (props.multi) {
@@ -690,7 +692,7 @@ function Segment(props) {
690
692
  direction: "column",
691
693
  align: "center",
692
694
  h: "100%",
693
- bg: props.selected ? colorWithAlpha(theme.colors[theme.primaryColor][theme.primaryShade], 0.2) : "transparent",
695
+ bg: props.selected ? props.color ? alpha(props.color, 0.2) : colorWithAlpha(theme.colors[theme.primaryColor][theme.primaryShade], 0.2) : "transparent",
694
696
  pos: "relative",
695
697
  style: {
696
698
  // position: "relative",
@@ -712,10 +714,10 @@ function Segment(props) {
712
714
  {
713
715
  icon: props.icon,
714
716
  initial: {
715
- color: props.selected ? theme.colors[theme.primaryColor][5] : "inherit"
717
+ color: props.selected ? props.color || theme.colors[theme.primaryColor][5] : "inherit"
716
718
  },
717
719
  animate: {
718
- color: props.selected ? theme.colors[theme.primaryColor][5] : "inherit"
720
+ color: props.selected ? props.color || theme.colors[theme.primaryColor][5] : "inherit"
719
721
  },
720
722
  exit: {
721
723
  color: "inherit"
@@ -731,10 +733,10 @@ function Segment(props) {
731
733
  {
732
734
  size: props.fz || "xs",
733
735
  initial: {
734
- color: props.selected ? theme.colors[theme.primaryColor][5] : "inherit"
736
+ color: props.selected ? props.color || theme.colors[theme.primaryColor][5] : "inherit"
735
737
  },
736
738
  animate: {
737
- color: props.selected ? theme.colors[theme.primaryColor][5] : "inherit"
739
+ color: props.selected ? props.color || theme.colors[theme.primaryColor][5] : "inherit"
738
740
  },
739
741
  exit: {
740
742
  color: "inherit"
@@ -770,7 +772,7 @@ function Segment(props) {
770
772
  left: 0,
771
773
  right: 0,
772
774
  height: "0.2vh",
773
- backgroundColor: theme.colors[theme.primaryColor][5],
775
+ backgroundColor: props.color || theme.colors[theme.primaryColor][5],
774
776
  transformOrigin: "center"
775
777
  }
776
778
  }
@@ -972,7 +974,156 @@ function Title(props) {
972
974
  }
973
975
  );
974
976
  }
977
+ function Modal() {
978
+ const active = useModal((state) => state.active);
979
+ const { hideModal } = useModalActions();
980
+ const ref = useClickOutside(() => {
981
+ if (!active) return;
982
+ if (active.clickOutside == false) return;
983
+ if (active) {
984
+ hideModal();
985
+ }
986
+ });
987
+ const theme = useMantineTheme();
988
+ return /* @__PURE__ */ jsx(AnimatePresence, { children: active && /* @__PURE__ */ jsx(
989
+ MotionFlex,
990
+ {
991
+ h: "100%",
992
+ w: "100%",
993
+ bg: "rgba(0, 0, 0, 0.3)",
994
+ pos: "absolute",
995
+ style: {
996
+ zIndex: 2e3,
997
+ filter: "drop-shadow(0 0 2vh black)"
998
+ },
999
+ initial: { opacity: 0 },
1000
+ animate: { opacity: 1 },
1001
+ exit: { opacity: 0 },
1002
+ align: "center",
1003
+ justify: "center",
1004
+ children: /* @__PURE__ */ jsxs(
1005
+ MotionFlex,
1006
+ {
1007
+ pos: "absolute",
1008
+ top: "50%",
1009
+ left: "50%",
1010
+ ref,
1011
+ w: active.width || "40%",
1012
+ style: {
1013
+ transform: "translate(-50%, -50%)",
1014
+ borderRadius: theme.radius.xs,
1015
+ boxShadow: theme.shadows.xl,
1016
+ zIndex: 2100
1017
+ },
1018
+ bg: "rgba(48, 48, 48, 0.84)",
1019
+ initial: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
1020
+ animate: { scale: 1, opacity: 1, transform: "translate(-50%, -50%)" },
1021
+ exit: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
1022
+ p: "sm",
1023
+ direction: "column",
1024
+ maw: "70%",
1025
+ gap: "xs",
1026
+ children: [
1027
+ /* @__PURE__ */ jsxs(
1028
+ Flex,
1029
+ {
1030
+ direction: "column",
1031
+ w: "100%",
1032
+ children: [
1033
+ /* @__PURE__ */ jsxs(
1034
+ Flex,
1035
+ {
1036
+ w: "100%",
1037
+ align: "center",
1038
+ gap: "xs",
1039
+ children: [
1040
+ active.icon && /* @__PURE__ */ jsx(
1041
+ FontAwesomeIcon,
1042
+ {
1043
+ icon: active.icon,
1044
+ style: {
1045
+ fontSize: theme.fontSizes.xs
1046
+ }
1047
+ }
1048
+ ),
1049
+ /* @__PURE__ */ jsx(
1050
+ Text,
1051
+ {
1052
+ size: "sm",
1053
+ children: active.title
1054
+ }
1055
+ ),
1056
+ /* @__PURE__ */ jsx(
1057
+ MotionIcon,
1058
+ {
1059
+ icon: "times",
1060
+ color: "rgba(255, 255, 255, 0.7)",
1061
+ whileHover: {
1062
+ scale: 1.1,
1063
+ filter: "brightness(1.2)"
1064
+ },
1065
+ style: {
1066
+ marginLeft: "auto",
1067
+ cursor: "pointer",
1068
+ fontSize: theme.fontSizes.sm
1069
+ },
1070
+ onClick: () => {
1071
+ hideModal();
1072
+ }
1073
+ }
1074
+ )
1075
+ ]
1076
+ }
1077
+ ),
1078
+ active.description && /* @__PURE__ */ jsx(
1079
+ Text,
1080
+ {
1081
+ size: "xs",
1082
+ c: "rgba(255, 255, 255, 0.7)",
1083
+ children: active.description
1084
+ }
1085
+ )
1086
+ ]
1087
+ }
1088
+ ),
1089
+ active.children
1090
+ ]
1091
+ }
1092
+ )
1093
+ }
1094
+ ) });
1095
+ }
1096
+ var ModalContext = createContext(null);
1097
+ function useModal(selector) {
1098
+ const modal = useContext(ModalContext);
1099
+ if (!modal) {
1100
+ throw new Error("useModal must be used within a ModalProvider");
1101
+ }
1102
+ return useStore(modal, selector);
1103
+ }
1104
+ function ModalProvider({ children, defaultPage }) {
1105
+ const storeRef = useRef(
1106
+ create(() => ({
1107
+ active: null
1108
+ }))
1109
+ );
1110
+ return /* @__PURE__ */ jsxs(ModalContext.Provider, { value: storeRef.current, children: [
1111
+ /* @__PURE__ */ jsx(Modal, {}),
1112
+ children
1113
+ ] });
1114
+ }
1115
+ function useModalActions() {
1116
+ const modal = useContext(ModalContext);
1117
+ if (!modal) throw new Error("useModalActions must be used within a ModalProvider");
1118
+ const showModal = (openModal) => {
1119
+ modal.setState({ active: openModal });
1120
+ };
1121
+ const hideModal = () => {
1122
+ modal.setState({ active: null });
1123
+ };
1124
+ return { showModal, hideModal };
1125
+ }
975
1126
 
976
- export { BorderedIcon, Counter, FloatingParticles, InfoBox, InputContainer, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, Segment, SegmentedControl, SegmentedProgress, Title, useNavigation, useNavigationStore };
1127
+ export { BorderedIcon, Counter, FloatingParticles, InfoBox, InputContainer, ModalContext, ModalProvider, MotionFlex, MotionIcon, MotionImage, MotionText, NavBar, NavigationContext, NavigationProvider, SegmentedControl, SegmentedProgress, Title, useModal, useModalActions, useNavigation, useNavigationStore };
977
1128
  //# sourceMappingURL=index.js.map
978
1129
  //# sourceMappingURL=index.js.map