@allxsmith/bestax-bulma 5.2.1 → 5.4.1

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.
package/dist/index.esm.js CHANGED
@@ -705,6 +705,195 @@ const Columns = ({ className, textColor, color: _fieldColor, bgColor, isCentered
705
705
  return (jsx("div", { className: columnsClasses, ...rest, children: children }));
706
706
  };
707
707
 
708
+ const avatarColors = [
709
+ 'primary',
710
+ 'link',
711
+ 'info',
712
+ 'success',
713
+ 'warning',
714
+ 'danger',
715
+ 'black',
716
+ 'dark',
717
+ 'light',
718
+ 'white',
719
+ ];
720
+ const autoAvatarColors = [
721
+ 'primary',
722
+ 'link',
723
+ 'info',
724
+ 'success',
725
+ 'warning',
726
+ 'danger',
727
+ ];
728
+ const avatarSizes = [
729
+ '16x16',
730
+ '24x24',
731
+ '32x32',
732
+ '48x48',
733
+ '64x64',
734
+ '96x96',
735
+ '128x128',
736
+ ];
737
+ function getInitialsFromName(name) {
738
+ const words = name.trim().split(/\s+/).filter(Boolean);
739
+ if (words.length === 0)
740
+ return '';
741
+ if (words.length === 1) {
742
+ return Array.from(words[0]).slice(0, 2).join('').toUpperCase();
743
+ }
744
+ const first = Array.from(words[0])[0];
745
+ const last = Array.from(words[words.length - 1])[0];
746
+ return (first + last).toUpperCase();
747
+ }
748
+ function getAutoColor(name) {
749
+ let hash = 0;
750
+ for (let i = 0; i < name.length; i++) {
751
+ hash = (hash << 5) - hash + name.charCodeAt(i);
752
+ hash |= 0;
753
+ }
754
+ const index = Math.abs(hash) % autoAvatarColors.length;
755
+ return autoAvatarColors[index];
756
+ }
757
+ function DefaultAvatarIcon() {
758
+ return (jsx("svg", { viewBox: "0 0 24 24", width: "60%", height: "60%", "aria-hidden": "true", children: jsx("path", { fill: "currentColor", d: "M12 12a5 5 0 1 0 0-10 5 5 0 0 0 0 10Zm0 2c-4.42 0-9 2.24-9 5v2a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1v-2c0-2.76-4.58-5-9-5Z" }) }));
759
+ }
760
+ const Avatar = ({ className, src, alt, name, initials, icon, size, shape = 'circle', color, as, href, target, rel, imageProps, style, ...props }) => {
761
+ const [erroredSrc, setErroredSrc] = useState(undefined);
762
+ const imgRef = useRef(null);
763
+ const { bulmaHelperClasses, rest } = useBulmaClasses(props);
764
+ const showImage = !!src && src !== erroredSrc;
765
+ useEffect(() => {
766
+ const img = imgRef.current;
767
+ if (img && img.complete && img.naturalWidth === 0) {
768
+ setErroredSrc(src);
769
+ }
770
+ }, [src]);
771
+ const resolvedInitials = initials
772
+ ? initials.toUpperCase()
773
+ : name
774
+ ? getInitialsFromName(name)
775
+ : '';
776
+ const showInitials = !showImage && !!resolvedInitials;
777
+ const showIcon = !showImage && !showInitials && !!icon;
778
+ const showDefaultIcon = !showImage && !showInitials && !showIcon;
779
+ const resolvedColor = color ?? (name ? getAutoColor(name) : undefined);
780
+ const isPresetSize = typeof size === 'string' && avatarSizes.includes(size);
781
+ const sizeStyle = typeof size === 'number'
782
+ ? { width: size, height: size, fontSize: size / 2.5 }
783
+ : undefined;
784
+ const avatarClasses = usePrefixedClassNames('avatar', {
785
+ [`is-${size}`]: isPresetSize,
786
+ [`is-${shape}`]: shape,
787
+ [`is-${resolvedColor}`]: resolvedColor && !showImage && avatarColors.includes(resolvedColor),
788
+ });
789
+ const combinedClasses = classNames(avatarClasses, bulmaHelperClasses, className);
790
+ const initialsClass = usePrefixedClassNames('avatar-initials');
791
+ const Tag = as ?? (href ? 'a' : 'figure');
792
+ const isInteractive = Tag === 'a' || Tag === 'button';
793
+ const isLinkLike = Tag === 'a' || typeof Tag !== 'string';
794
+ const linkProps = isLinkLike ? { href, target, rel } : {};
795
+ const a11yProps = showImage
796
+ ? {}
797
+ : {
798
+ ...(isInteractive ? {} : { role: 'img' }),
799
+ 'aria-label': alt || name || 'Avatar',
800
+ };
801
+ return (jsxs(Tag, { className: combinedClasses, style: { ...sizeStyle, ...style }, ...linkProps, ...a11yProps, ...rest, children: [showImage && (jsx("img", { ...imageProps, ref: imgRef, src: src, alt: alt || name || '', onError: e => {
802
+ imageProps?.onError?.(e);
803
+ setErroredSrc(src);
804
+ } })), showInitials && (jsx("span", { className: initialsClass, children: resolvedInitials })), showIcon && icon, showDefaultIcon && jsx(DefaultAvatarIcon, {})] }));
805
+ };
806
+ Avatar.displayName = 'Avatar';
807
+
808
+ const Avatars = ({ className, max, size, shape, spacing = 'md', spaced = false, style, children, ...props }) => {
809
+ const { bulmaHelperClasses, rest } = useBulmaClasses({ ...props });
810
+ const isPresetSpacing = typeof spacing === 'string';
811
+ const avatarsClasses = usePrefixedClassNames('avatars', {
812
+ [`is-spacing-${spacing}`]: isPresetSpacing,
813
+ 'is-spaced': spaced,
814
+ });
815
+ const spacingStyle = typeof spacing === 'number'
816
+ ? { '--bulma-avatars-spacing': `${spacing}px` }
817
+ : undefined;
818
+ const surplusClass = usePrefixedClassNames('is-surplus');
819
+ const combinedClasses = classNames(avatarsClasses, bulmaHelperClasses, className);
820
+ const childArray = React.Children.toArray(children).filter(React.isValidElement);
821
+ const maxCount = typeof max === 'number' && Number.isInteger(max) && max >= 0
822
+ ? max
823
+ : undefined;
824
+ const overshoot = maxCount !== undefined ? childArray.length - maxCount : 0;
825
+ const clamp = maxCount !== undefined && overshoot >= 2;
826
+ const visibleChildren = clamp ? childArray.slice(0, maxCount) : childArray;
827
+ const overflowCount = clamp ? overshoot : 0;
828
+ return (jsxs("div", { className: combinedClasses, style: { ...spacingStyle, ...style }, ...rest, children: [visibleChildren.map(child => React.cloneElement(child, {
829
+ ...(size !== undefined ? { size } : {}),
830
+ ...(shape !== undefined ? { shape } : {}),
831
+ })), overflowCount > 0 && (jsx(Avatar, { initials: `+${overflowCount}`, alt: `${overflowCount} more`, size: size, shape: shape, className: surplusClass }))] }));
832
+ };
833
+ Avatars.displayName = 'Avatars';
834
+ Avatars.Avatar = Avatar;
835
+
836
+ const badgeColors = [
837
+ 'primary',
838
+ 'link',
839
+ 'info',
840
+ 'success',
841
+ 'warning',
842
+ 'danger',
843
+ 'black',
844
+ 'dark',
845
+ 'light',
846
+ 'white',
847
+ ];
848
+ const Badge = ({ className, badgeClassName, content, max = 99, dot = false, showZero = false, color = 'danger', position = 'top-right', overlap = 'square', pulse = false, invisible = false, children, ...props }) => {
849
+ const { bulmaHelperClasses, rest } = useBulmaClasses(props);
850
+ const hasChildren = children != null && children !== false;
851
+ const isZero = typeof content === 'number' && content === 0;
852
+ const hasContent = content != null &&
853
+ content !== false &&
854
+ content !== true &&
855
+ content !== '' &&
856
+ (!isZero || showZero);
857
+ const shouldRender = dot || hasContent || invisible;
858
+ const sanitizedMax = Number.isInteger(max) && max >= 0 ? max : 99;
859
+ const displayValue = useMemo(() => {
860
+ if (dot || !hasContent)
861
+ return undefined;
862
+ if (typeof content === 'number') {
863
+ return content > sanitizedMax ? `${sanitizedMax}+` : String(content);
864
+ }
865
+ return content;
866
+ }, [dot, hasContent, content, sanitizedMax]);
867
+ const ariaLabel = typeof displayValue === 'string' || typeof displayValue === 'number'
868
+ ? String(displayValue)
869
+ : undefined;
870
+ const wrapperClass = usePrefixedClassNames('badge-wrapper');
871
+ const badgeClasses = usePrefixedClassNames('badge', {
872
+ [`is-${color}`]: !!color && badgeColors.includes(color),
873
+ [`is-${position}`]: !!position && hasChildren,
874
+ [`is-overlap-${overlap}`]: !!overlap && hasChildren,
875
+ 'is-standalone': !hasChildren,
876
+ 'is-dot': dot,
877
+ 'is-pulse': pulse,
878
+ 'is-invisible': invisible,
879
+ });
880
+ const pillClass = hasChildren
881
+ ? classNames(badgeClasses, badgeClassName)
882
+ : classNames(badgeClasses, badgeClassName, bulmaHelperClasses, className);
883
+ const a11yProps = dot
884
+ ? { 'aria-hidden': true }
885
+ : {
886
+ role: 'status',
887
+ ...(ariaLabel !== undefined ? { 'aria-label': ariaLabel } : {}),
888
+ };
889
+ const indicator = shouldRender ? (jsx("span", { className: pillClass, ...a11yProps, ...(hasChildren ? {} : rest), children: !dot && displayValue })) : null;
890
+ if (!hasChildren) {
891
+ return indicator;
892
+ }
893
+ return (jsxs("span", { className: classNames(wrapperClass, bulmaHelperClasses, className), ...rest, children: [children, indicator] }));
894
+ };
895
+ Badge.displayName = 'Badge';
896
+
708
897
  const validBreadcrumbAlignments = ['centered', 'right'];
709
898
  const validBreadcrumbSeparators = [
710
899
  'arrow',
@@ -2522,6 +2711,99 @@ const Carousel = forwardRef(({ value: controlledValue, autoplay = false, interva
2522
2711
  });
2523
2712
  Carousel.displayName = 'Carousel';
2524
2713
 
2714
+ function usePrefersReducedMotion() {
2715
+ const [prefersReducedMotion, setPrefersReducedMotion] = useState(false);
2716
+ useEffect(() => {
2717
+ if (typeof window === 'undefined' || !window.matchMedia)
2718
+ return undefined;
2719
+ const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
2720
+ setPrefersReducedMotion(mediaQuery.matches);
2721
+ const handleChange = (event) => {
2722
+ setPrefersReducedMotion(event.matches);
2723
+ };
2724
+ mediaQuery.addEventListener('change', handleChange);
2725
+ return () => mediaQuery.removeEventListener('change', handleChange);
2726
+ }, []);
2727
+ return prefersReducedMotion;
2728
+ }
2729
+ const Reveal = ({ animation = 'fade-up', delay = 0, duration = 600, threshold = 0.15, once = true, as: Component = 'div', cascade = false, cascadeInterval = 80, className, style, children, ...props }) => {
2730
+ const { bulmaHelperClasses, rest } = useBulmaClasses(props);
2731
+ const classPrefix = useClassPrefix();
2732
+ const prefersReducedMotion = usePrefersReducedMotion();
2733
+ const [node, setNode] = useState(null);
2734
+ const [isMounted, setIsMounted] = useState(false);
2735
+ const [isRevealed, setIsRevealed] = useState(false);
2736
+ const observerThreshold = Number.isFinite(threshold)
2737
+ ? Math.min(Math.max(threshold, 0), 1)
2738
+ : 0.15;
2739
+ useEffect(() => {
2740
+ setIsMounted(true);
2741
+ }, []);
2742
+ useEffect(() => {
2743
+ if (prefersReducedMotion) {
2744
+ setIsRevealed(true);
2745
+ return undefined;
2746
+ }
2747
+ if (typeof IntersectionObserver === 'undefined') {
2748
+ setIsRevealed(true);
2749
+ return undefined;
2750
+ }
2751
+ if (!node)
2752
+ return undefined;
2753
+ const observer = new IntersectionObserver(([entry]) => {
2754
+ if (entry.isIntersecting) {
2755
+ setIsRevealed(true);
2756
+ if (once)
2757
+ observer.unobserve(node);
2758
+ }
2759
+ else if (!once) {
2760
+ setIsRevealed(false);
2761
+ }
2762
+ }, { threshold: observerThreshold });
2763
+ observer.observe(node);
2764
+ return () => observer.disconnect();
2765
+ }, [node, prefersReducedMotion, once, observerThreshold]);
2766
+ const isAnimated = isMounted && !prefersReducedMotion;
2767
+ const revealed = !isAnimated || isRevealed;
2768
+ const itemAnimationClasses = prefixedClassNames(classPrefix, {
2769
+ [`reveal-${animation}`]: isAnimated,
2770
+ 'is-revealed': revealed,
2771
+ });
2772
+ const combinedClasses = classNames(usePrefixedClassNames('reveal', { 'is-cascade': cascade }), !cascade && itemAnimationClasses, bulmaHelperClasses, className);
2773
+ const wrapperStyle = cascade
2774
+ ? { ...style }
2775
+ : {
2776
+ ...style,
2777
+ transitionDelay: `${delay}ms`,
2778
+ transitionDuration: `${duration}ms`,
2779
+ };
2780
+ const content = cascade
2781
+ ? Children.toArray(children).map((child, index) => {
2782
+ const itemStyle = {
2783
+ transitionDelay: `${delay + index * cascadeInterval}ms`,
2784
+ transitionDuration: `${duration}ms`,
2785
+ };
2786
+ if (isValidElement(child)) {
2787
+ return cloneElement(child, {
2788
+ key: child.key,
2789
+ className: classNames(itemAnimationClasses, child.props.className),
2790
+ style: { ...itemStyle, ...child.props.style },
2791
+ });
2792
+ }
2793
+ return (jsx("span", { className: itemAnimationClasses, style: itemStyle, children: child }, index));
2794
+ })
2795
+ : children;
2796
+ if (typeof Component === 'string') {
2797
+ return React.createElement(Component, {
2798
+ ...rest,
2799
+ ref: setNode,
2800
+ className: combinedClasses,
2801
+ style: wrapperStyle,
2802
+ }, content);
2803
+ }
2804
+ return (jsx("div", { ref: setNode, className: combinedClasses, style: wrapperStyle, children: jsx(Component, { ...rest, children: content }) }));
2805
+ };
2806
+
2525
2807
  const Block = ({ className, textColor, bgColor, children, ...props }) => {
2526
2808
  const { bulmaHelperClasses, rest } = useBulmaClasses({
2527
2809
  color: textColor,
@@ -8111,5 +8393,5 @@ const Section = ({ size, className, children, color, bgColor, textColor, ...prop
8111
8393
  return (jsx("section", { className: sectionClasses, ...rest, children: children }));
8112
8394
  };
8113
8395
 
8114
- export { Autocomplete, Block, Box, Breadcrumb, Button, Buttons, CardWithSubComponents as Card, Carousel, CarouselItem, Cell, Checkbox, Checkboxes, Code, Collapse, Column, Columns, ConfigProvider, Container, Content, Control, DateInput, DateInputBase, DateTimeInput, DateTimeInputBase, Delete, Dialog, DialogContainer, Divider, Dropdown, DropdownDivider, DropdownItem, Emphasis, Field, FieldBody, FieldLabel, Figure, File, Footer, Grid, Hero, HeroBody, HeroFoot, HeroHead, Icon, IconText, Image, Input, InputBase, Level, LevelItem, LevelLeft, LevelRight, Link, LinkButton, ListItem, Loading, Media, MediaContent, MediaLeft, MediaRight, Menu, MenuItem, MenuLabel, MenuList, MessageWithSubComponents as Message, Modal, Navbar, NavbarBrand, NavbarBurger, NavbarDivider, NavbarDropdown, NavbarDropdownMenu, NavbarEnd, NavbarItem, NavbarLink, NavbarMenu, NavbarStart, Notification, NotificationContainer, Numberinput, OrderedList, Pagination, PaginationEllipsis, PaginationLink, PaginationList, PaginationNext, PaginationPrevious, Panel, PanelBlock, PanelButtonBlock, PanelCheckboxBlock, PanelHeading, PanelIcon, PanelInputBlock, PanelTabs, Paragraph, Pre, Progress, Radio, Radios, Rate, Section, Select, SelectBase, Sidebar, Skeleton, Slider, Span, Step, Steps, Strong, SubTitle, Switch, Tab, TabContentItem, TabItem, TabList, Table, Tabs, TabsContent, Tag, Taginput, Tags, Tbody, Td, TextArea, TextAreaBase, Tfoot, Th, Thead, Theme, TimeInput, TimeInputBase, Title, Toast, ToastContainer, Tooltip, Tr, UnorderedList, __test_exports__, checkboxColors, checkboxSizes, classNames, createPrefixedClassNames, dialog, isBrowser$1 as isBrowser, notification, prefixedClassNames, radioColors, radioSizes, switchColors, switchSizes, toast, useBulmaClasses, useClassPrefix, useColorClasses, useConfig, useFlexboxClasses, useIconLibrary, useInsideControl, useInsideField, useOtherClasses, usePrefixedClass, usePrefixedClassNames, useSpacingClasses, useTypographyClasses, useVisibilityClasses, validAlignContents, validAlignItems, validAlignSelfs, validAlignments$1 as validAlignments, validColorShades, validColors, validDisplays, validFlexDirections, validFlexGrowShrink, validFlexWraps, validFontFamilies, validJustifyContents, validSizes$1 as validSizes, validTableColors, validTextSizes, validTextTransforms, validTextWeights, validViewports, validVisibilities };
8396
+ export { Autocomplete, Avatar, Avatars, Badge, Block, Box, Breadcrumb, Button, Buttons, CardWithSubComponents as Card, Carousel, CarouselItem, Cell, Checkbox, Checkboxes, Code, Collapse, Column, Columns, ConfigProvider, Container, Content, Control, DateInput, DateInputBase, DateTimeInput, DateTimeInputBase, Delete, Dialog, DialogContainer, Divider, Dropdown, DropdownDivider, DropdownItem, Emphasis, Field, FieldBody, FieldLabel, Figure, File, Footer, Grid, Hero, HeroBody, HeroFoot, HeroHead, Icon, IconText, Image, Input, InputBase, Level, LevelItem, LevelLeft, LevelRight, Link, LinkButton, ListItem, Loading, Media, MediaContent, MediaLeft, MediaRight, Menu, MenuItem, MenuLabel, MenuList, MessageWithSubComponents as Message, Modal, Navbar, NavbarBrand, NavbarBurger, NavbarDivider, NavbarDropdown, NavbarDropdownMenu, NavbarEnd, NavbarItem, NavbarLink, NavbarMenu, NavbarStart, Notification, NotificationContainer, Numberinput, OrderedList, Pagination, PaginationEllipsis, PaginationLink, PaginationList, PaginationNext, PaginationPrevious, Panel, PanelBlock, PanelButtonBlock, PanelCheckboxBlock, PanelHeading, PanelIcon, PanelInputBlock, PanelTabs, Paragraph, Pre, Progress, Radio, Radios, Rate, Reveal, Section, Select, SelectBase, Sidebar, Skeleton, Slider, Span, Step, Steps, Strong, SubTitle, Switch, Tab, TabContentItem, TabItem, TabList, Table, Tabs, TabsContent, Tag, Taginput, Tags, Tbody, Td, TextArea, TextAreaBase, Tfoot, Th, Thead, Theme, TimeInput, TimeInputBase, Title, Toast, ToastContainer, Tooltip, Tr, UnorderedList, __test_exports__, checkboxColors, checkboxSizes, classNames, createPrefixedClassNames, dialog, isBrowser$1 as isBrowser, notification, prefixedClassNames, radioColors, radioSizes, switchColors, switchSizes, toast, useBulmaClasses, useClassPrefix, useColorClasses, useConfig, useFlexboxClasses, useIconLibrary, useInsideControl, useInsideField, useOtherClasses, usePrefixedClass, usePrefixedClassNames, useSpacingClasses, useTypographyClasses, useVisibilityClasses, validAlignContents, validAlignItems, validAlignSelfs, validAlignments$1 as validAlignments, validColorShades, validColors, validDisplays, validFlexDirections, validFlexGrowShrink, validFlexWraps, validFontFamilies, validJustifyContents, validSizes$1 as validSizes, validTableColors, validTextSizes, validTextTransforms, validTextWeights, validViewports, validVisibilities };
8115
8397
  //# sourceMappingURL=index.esm.js.map