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.
@@ -17,6 +17,7 @@ var jsxRuntime = require('react/jsx-runtime');
17
17
  var framerMotion = require('framer-motion');
18
18
  var clickSoundUrl = require('../click_sound-PNCRRTM4.mp3');
19
19
  var hoverSoundUrl = require('../hover_sound-NBUA222C.mp3');
20
+ var hooks = require('@mantine/hooks');
20
21
 
21
22
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
22
23
 
@@ -170,11 +171,11 @@ var colorNames = {
170
171
  Yellow: { r: 255, g: 255, b: 0 },
171
172
  YellowGreen: { r: 154, g: 205, b: 50 }
172
173
  };
173
- function colorWithAlpha(color, alpha) {
174
+ function colorWithAlpha(color, alpha2) {
174
175
  const lowerCasedColor = color.toLowerCase();
175
176
  if (colorNames[lowerCasedColor]) {
176
177
  const rgb = colorNames[lowerCasedColor];
177
- return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha})`;
178
+ return `rgba(${rgb.r}, ${rgb.g}, ${rgb.b}, ${alpha2})`;
178
179
  }
179
180
  if (/^#([A-Fa-f0-9]{6})$/.test(color)) {
180
181
  const hex = color.slice(1);
@@ -182,12 +183,12 @@ function colorWithAlpha(color, alpha) {
182
183
  const r = bigint >> 16 & 255;
183
184
  const g = bigint >> 8 & 255;
184
185
  const b = bigint & 255;
185
- return `rgba(${r}, ${g}, ${b}, ${alpha})`;
186
+ return `rgba(${r}, ${g}, ${b}, ${alpha2})`;
186
187
  }
187
188
  if (/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/.test(color)) {
188
189
  const result = color.match(/^rgb\((\d{1,3}), (\d{1,3}), (\d{1,3})\)$/);
189
190
  if (result) {
190
- return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha})`;
191
+ return `rgba(${result[1]}, ${result[2]}, ${result[3]}, ${alpha2})`;
191
192
  }
192
193
  }
193
194
  return color;
@@ -645,7 +646,7 @@ function SegmentedControl(props) {
645
646
  bg: "rgba(33, 33, 33, 0.6)",
646
647
  w: props.w || "fit-content",
647
648
  style: {
648
- borderRadius: theme.radius.xs,
649
+ borderRadius: props.enableRadius !== false ? theme.radius.xs : 0,
649
650
  overflow: "hidden"
650
651
  },
651
652
  ...props,
@@ -669,6 +670,7 @@ function SegmentedControl(props) {
669
670
  icon: item.icon,
670
671
  rightSection: item.rightSection,
671
672
  fz: props.fz,
673
+ color: props.color,
672
674
  selected: !props.multi ? props.value === item.value : Array.isArray(props.value) && props.value.includes(item.value),
673
675
  onClick: () => {
674
676
  if (props.multi) {
@@ -697,7 +699,7 @@ function Segment(props) {
697
699
  direction: "column",
698
700
  align: "center",
699
701
  h: "100%",
700
- bg: props.selected ? colorWithAlpha(theme.colors[theme.primaryColor][theme.primaryShade], 0.2) : "transparent",
702
+ bg: props.selected ? props.color ? core.alpha(props.color, 0.2) : colorWithAlpha(theme.colors[theme.primaryColor][theme.primaryShade], 0.2) : "transparent",
701
703
  pos: "relative",
702
704
  style: {
703
705
  // position: "relative",
@@ -719,10 +721,10 @@ function Segment(props) {
719
721
  {
720
722
  icon: props.icon,
721
723
  initial: {
722
- color: props.selected ? theme.colors[theme.primaryColor][5] : "inherit"
724
+ color: props.selected ? props.color || theme.colors[theme.primaryColor][5] : "inherit"
723
725
  },
724
726
  animate: {
725
- color: props.selected ? theme.colors[theme.primaryColor][5] : "inherit"
727
+ color: props.selected ? props.color || theme.colors[theme.primaryColor][5] : "inherit"
726
728
  },
727
729
  exit: {
728
730
  color: "inherit"
@@ -738,10 +740,10 @@ function Segment(props) {
738
740
  {
739
741
  size: props.fz || "xs",
740
742
  initial: {
741
- color: props.selected ? theme.colors[theme.primaryColor][5] : "inherit"
743
+ color: props.selected ? props.color || theme.colors[theme.primaryColor][5] : "inherit"
742
744
  },
743
745
  animate: {
744
- color: props.selected ? theme.colors[theme.primaryColor][5] : "inherit"
746
+ color: props.selected ? props.color || theme.colors[theme.primaryColor][5] : "inherit"
745
747
  },
746
748
  exit: {
747
749
  color: "inherit"
@@ -777,7 +779,7 @@ function Segment(props) {
777
779
  left: 0,
778
780
  right: 0,
779
781
  height: "0.2vh",
780
- backgroundColor: theme.colors[theme.primaryColor][5],
782
+ backgroundColor: props.color || theme.colors[theme.primaryColor][5],
781
783
  transformOrigin: "center"
782
784
  }
783
785
  }
@@ -979,12 +981,163 @@ function Title(props) {
979
981
  }
980
982
  );
981
983
  }
984
+ function Modal() {
985
+ const active = useModal((state) => state.active);
986
+ const { hideModal } = useModalActions();
987
+ const ref = hooks.useClickOutside(() => {
988
+ if (!active) return;
989
+ if (active.clickOutside == false) return;
990
+ if (active) {
991
+ hideModal();
992
+ }
993
+ });
994
+ const theme = core.useMantineTheme();
995
+ return /* @__PURE__ */ jsxRuntime.jsx(framerMotion.AnimatePresence, { children: active && /* @__PURE__ */ jsxRuntime.jsx(
996
+ MotionFlex,
997
+ {
998
+ h: "100%",
999
+ w: "100%",
1000
+ bg: "rgba(0, 0, 0, 0.3)",
1001
+ pos: "absolute",
1002
+ style: {
1003
+ zIndex: 2e3,
1004
+ filter: "drop-shadow(0 0 2vh black)"
1005
+ },
1006
+ initial: { opacity: 0 },
1007
+ animate: { opacity: 1 },
1008
+ exit: { opacity: 0 },
1009
+ align: "center",
1010
+ justify: "center",
1011
+ children: /* @__PURE__ */ jsxRuntime.jsxs(
1012
+ MotionFlex,
1013
+ {
1014
+ pos: "absolute",
1015
+ top: "50%",
1016
+ left: "50%",
1017
+ ref,
1018
+ w: active.width || "40%",
1019
+ style: {
1020
+ transform: "translate(-50%, -50%)",
1021
+ borderRadius: theme.radius.xs,
1022
+ boxShadow: theme.shadows.xl,
1023
+ zIndex: 2100
1024
+ },
1025
+ bg: "rgba(48, 48, 48, 0.84)",
1026
+ initial: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
1027
+ animate: { scale: 1, opacity: 1, transform: "translate(-50%, -50%)" },
1028
+ exit: { scale: 0.8, opacity: 0, transform: "translate(-50%, -50%)" },
1029
+ p: "sm",
1030
+ direction: "column",
1031
+ maw: "70%",
1032
+ gap: "xs",
1033
+ children: [
1034
+ /* @__PURE__ */ jsxRuntime.jsxs(
1035
+ core.Flex,
1036
+ {
1037
+ direction: "column",
1038
+ w: "100%",
1039
+ children: [
1040
+ /* @__PURE__ */ jsxRuntime.jsxs(
1041
+ core.Flex,
1042
+ {
1043
+ w: "100%",
1044
+ align: "center",
1045
+ gap: "xs",
1046
+ children: [
1047
+ active.icon && /* @__PURE__ */ jsxRuntime.jsx(
1048
+ reactFontawesome.FontAwesomeIcon,
1049
+ {
1050
+ icon: active.icon,
1051
+ style: {
1052
+ fontSize: theme.fontSizes.xs
1053
+ }
1054
+ }
1055
+ ),
1056
+ /* @__PURE__ */ jsxRuntime.jsx(
1057
+ core.Text,
1058
+ {
1059
+ size: "sm",
1060
+ children: active.title
1061
+ }
1062
+ ),
1063
+ /* @__PURE__ */ jsxRuntime.jsx(
1064
+ MotionIcon,
1065
+ {
1066
+ icon: "times",
1067
+ color: "rgba(255, 255, 255, 0.7)",
1068
+ whileHover: {
1069
+ scale: 1.1,
1070
+ filter: "brightness(1.2)"
1071
+ },
1072
+ style: {
1073
+ marginLeft: "auto",
1074
+ cursor: "pointer",
1075
+ fontSize: theme.fontSizes.sm
1076
+ },
1077
+ onClick: () => {
1078
+ hideModal();
1079
+ }
1080
+ }
1081
+ )
1082
+ ]
1083
+ }
1084
+ ),
1085
+ active.description && /* @__PURE__ */ jsxRuntime.jsx(
1086
+ core.Text,
1087
+ {
1088
+ size: "xs",
1089
+ c: "rgba(255, 255, 255, 0.7)",
1090
+ children: active.description
1091
+ }
1092
+ )
1093
+ ]
1094
+ }
1095
+ ),
1096
+ active.children
1097
+ ]
1098
+ }
1099
+ )
1100
+ }
1101
+ ) });
1102
+ }
1103
+ var ModalContext = react.createContext(null);
1104
+ function useModal(selector) {
1105
+ const modal = react.useContext(ModalContext);
1106
+ if (!modal) {
1107
+ throw new Error("useModal must be used within a ModalProvider");
1108
+ }
1109
+ return zustand.useStore(modal, selector);
1110
+ }
1111
+ function ModalProvider({ children, defaultPage }) {
1112
+ const storeRef = react.useRef(
1113
+ zustand.create(() => ({
1114
+ active: null
1115
+ }))
1116
+ );
1117
+ return /* @__PURE__ */ jsxRuntime.jsxs(ModalContext.Provider, { value: storeRef.current, children: [
1118
+ /* @__PURE__ */ jsxRuntime.jsx(Modal, {}),
1119
+ children
1120
+ ] });
1121
+ }
1122
+ function useModalActions() {
1123
+ const modal = react.useContext(ModalContext);
1124
+ if (!modal) throw new Error("useModalActions must be used within a ModalProvider");
1125
+ const showModal = (openModal) => {
1126
+ modal.setState({ active: openModal });
1127
+ };
1128
+ const hideModal = () => {
1129
+ modal.setState({ active: null });
1130
+ };
1131
+ return { showModal, hideModal };
1132
+ }
982
1133
 
983
1134
  exports.BorderedIcon = BorderedIcon;
984
1135
  exports.Counter = Counter;
985
1136
  exports.FloatingParticles = FloatingParticles;
986
1137
  exports.InfoBox = InfoBox;
987
1138
  exports.InputContainer = InputContainer;
1139
+ exports.ModalContext = ModalContext;
1140
+ exports.ModalProvider = ModalProvider;
988
1141
  exports.MotionFlex = MotionFlex;
989
1142
  exports.MotionIcon = MotionIcon;
990
1143
  exports.MotionImage = MotionImage;
@@ -992,10 +1145,11 @@ exports.MotionText = MotionText;
992
1145
  exports.NavBar = NavBar;
993
1146
  exports.NavigationContext = NavigationContext;
994
1147
  exports.NavigationProvider = NavigationProvider;
995
- exports.Segment = Segment;
996
1148
  exports.SegmentedControl = SegmentedControl;
997
1149
  exports.SegmentedProgress = SegmentedProgress;
998
1150
  exports.Title = Title;
1151
+ exports.useModal = useModal;
1152
+ exports.useModalActions = useModalActions;
999
1153
  exports.useNavigation = useNavigation;
1000
1154
  exports.useNavigationStore = useNavigationStore;
1001
1155
  //# sourceMappingURL=index.cjs.map