@lowdefy/blocks-native 0.0.0-experimental-20261019052246
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/LICENSE +201 -0
- package/README.md +10 -0
- package/dist/blocks/ActivityTimeline/ActivityTimeline.js +477 -0
- package/dist/blocks/ActivityTimeline/CommentBody.js +174 -0
- package/dist/blocks/ActivityTimeline/CommentItem.js +300 -0
- package/dist/blocks/ActivityTimeline/EditBox.js +143 -0
- package/dist/blocks/ActivityTimeline/LineText.js +71 -0
- package/dist/blocks/ActivityTimeline/RailIcon.js +41 -0
- package/dist/blocks/ActivityTimeline/RailRow.js +74 -0
- package/dist/blocks/ActivityTimeline/ReactionPicker.js +68 -0
- package/dist/blocks/ActivityTimeline/ReactionPills.js +112 -0
- package/dist/blocks/ActivityTimeline/ThreadCard.js +159 -0
- package/dist/blocks/ActivityTimeline/TimelineMarkdownRenderer.js +48 -0
- package/dist/blocks/ActivityTimeline/buildTimelineRows.js +194 -0
- package/dist/blocks/ActivityTimeline/describeEvent.js +61 -0
- package/dist/blocks/ActivityTimeline/describeGap.js +71 -0
- package/dist/blocks/ActivityTimeline/fillTemplate.js +84 -0
- package/dist/blocks/ActivityTimeline/fillText.js +38 -0
- package/dist/blocks/ActivityTimeline/formatRelativeTime.js +68 -0
- package/dist/blocks/ActivityTimeline/getActor.js +41 -0
- package/dist/blocks/ActivityTimeline/getCommentMenuActions.js +85 -0
- package/dist/blocks/ActivityTimeline/getCommentView.js +72 -0
- package/dist/blocks/ActivityTimeline/getTimelineColors.js +71 -0
- package/dist/blocks/ActivityTimeline/getToneColor.js +49 -0
- package/dist/blocks/ActivityTimeline/getVisibleReplies.js +36 -0
- package/dist/blocks/ActivityTimeline/isThreadShown.js +28 -0
- package/dist/blocks/ActivityTimeline/joinList.js +21 -0
- package/dist/blocks/ActivityTimeline/meta.js +314 -0
- package/dist/blocks/ActivityTimeline/parseTimelineHref.js +43 -0
- package/dist/blocks/ActivityTimeline/selectEventRule.js +69 -0
- package/dist/blocks/ActivityTimeline/summariseEvents.js +51 -0
- package/dist/blocks/ActivityTimeline/toPlainText.js +32 -0
- package/dist/blocks/ActivityTimeline/toTime.js +36 -0
- package/dist/blocks/ActivityTimeline/toTimelineMarkdown.js +57 -0
- package/dist/blocks/ActivityTimeline/toggleReaction.js +74 -0
- package/dist/blocks/ActivityTimeline/useNow.js +24 -0
- package/dist/blocks/AgentChat/AgentChat.js +726 -0
- package/dist/blocks/AgentChat/AssistantMessage.js +243 -0
- package/dist/blocks/AgentChat/ChatComposer.js +401 -0
- package/dist/blocks/AgentChat/ChatError.js +129 -0
- package/dist/blocks/AgentChat/ChatSkeleton.js +97 -0
- package/dist/blocks/AgentChat/ReasoningDisclosure.js +125 -0
- package/dist/blocks/AgentChat/ThinkingIndicator.js +103 -0
- package/dist/blocks/AgentChat/ThreadsSheet.js +347 -0
- package/dist/blocks/AgentChat/ToolApprovalCard.js +190 -0
- package/dist/blocks/AgentChat/ToolCallRow.js +187 -0
- package/dist/blocks/AgentChat/ToolDetail.js +137 -0
- package/dist/blocks/AgentChat/UserMessage.js +84 -0
- package/dist/blocks/AgentChat/WelcomeView.js +100 -0
- package/dist/blocks/AgentChat/createAgentTransport.js +74 -0
- package/dist/blocks/AgentChat/describeToolPart.js +133 -0
- package/dist/blocks/AgentChat/getChatSeed.js +44 -0
- package/dist/blocks/AgentChat/getFirstExchange.js +43 -0
- package/dist/blocks/AgentChat/getMessageSegments.js +73 -0
- package/dist/blocks/AgentChat/getMessageText.js +25 -0
- package/dist/blocks/AgentChat/getPageStateUpdates.js +47 -0
- package/dist/blocks/AgentChat/getProvisionalTitle.js +32 -0
- package/dist/blocks/AgentChat/getReadableRows.js +157 -0
- package/dist/blocks/AgentChat/getThreadEndpoints.js +54 -0
- package/dist/blocks/AgentChat/getToolIcon.js +110 -0
- package/dist/blocks/AgentChat/humanizeToolName.js +30 -0
- package/dist/blocks/AgentChat/messageParts.js +86 -0
- package/dist/blocks/AgentChat/meta.js +530 -0
- package/dist/blocks/AgentChat/mintConversationId.js +29 -0
- package/dist/blocks/AgentChat/replayableMessages.js +62 -0
- package/dist/blocks/AgentChat/showMessageMenu.js +49 -0
- package/dist/blocks/AgentChat/summarizeToolInput.js +36 -0
- package/dist/blocks/AgentChat/summarizeToolOutput.js +49 -0
- package/dist/blocks/AgentChat/useAgentEvents.js +218 -0
- package/dist/blocks/AgentChat/useChatDictation.js +151 -0
- package/dist/blocks/AgentChat/useChatThreads.js +450 -0
- package/dist/blocks/AgentChat/useFollowScroll.js +80 -0
- package/dist/blocks/AgentChat/useThinkingMessage.js +77 -0
- package/dist/blocks/Alert/Alert.js +167 -0
- package/dist/blocks/Alert/meta.js +200 -0
- package/dist/blocks/Avatar/Avatar.js +49 -0
- package/dist/blocks/Avatar/AvatarCircle.js +111 -0
- package/dist/blocks/Avatar/AvatarPhoto.js +70 -0
- package/dist/blocks/Avatar/AvatarStack.js +87 -0
- package/dist/blocks/Avatar/getAvatarColor.js +84 -0
- package/dist/blocks/Avatar/getAvatarImage.js +95 -0
- package/dist/blocks/Avatar/getInitials.js +51 -0
- package/dist/blocks/Avatar/meta.js +57 -0
- package/dist/blocks/Box/Box.js +118 -0
- package/dist/blocks/Box/getRubberBand.js +29 -0
- package/dist/blocks/Box/getSwipeDirection.js +45 -0
- package/dist/blocks/Box/isSwipeGesture.js +41 -0
- package/dist/blocks/Box/meta.js +46 -0
- package/dist/blocks/Box/useSwipeGesture.js +113 -0
- package/dist/blocks/Button/Button.js +136 -0
- package/dist/blocks/Button/getButtonColors.js +216 -0
- package/dist/blocks/Button/meta.js +137 -0
- package/dist/blocks/Card/Card.js +185 -0
- package/dist/blocks/Card/meta.js +203 -0
- package/dist/blocks/ChipSelector/Chip.js +178 -0
- package/dist/blocks/ChipSelector/ChipSelector.js +311 -0
- package/dist/blocks/ChipSelector/EdgeFade.js +68 -0
- package/dist/blocks/ChipSelector/getChipColors.js +88 -0
- package/dist/blocks/ChipSelector/getFadeRanges.js +55 -0
- package/dist/blocks/ChipSelector/getOverscrollSwipe.js +44 -0
- package/dist/blocks/ChipSelector/getScrollTarget.js +41 -0
- package/dist/blocks/ChipSelector/meta.js +156 -0
- package/dist/blocks/Composer/Composer.js +501 -0
- package/dist/blocks/Composer/MentionTextInput.js +91 -0
- package/dist/blocks/Composer/SuggestionList.js +163 -0
- package/dist/blocks/Composer/applyDisplayEdit.js +81 -0
- package/dist/blocks/Composer/convertSpokenMentions.js +234 -0
- package/dist/blocks/Composer/createMentionPattern.js +40 -0
- package/dist/blocks/Composer/findTrigger.js +51 -0
- package/dist/blocks/Composer/getSendState.js +38 -0
- package/dist/blocks/Composer/getSpokenMentionWords.js +35 -0
- package/dist/blocks/Composer/indexSpokenNames.js +50 -0
- package/dist/blocks/Composer/insertLink.js +36 -0
- package/dist/blocks/Composer/insertMention.js +43 -0
- package/dist/blocks/Composer/matchSpokenName.js +88 -0
- package/dist/blocks/Composer/meta.js +212 -0
- package/dist/blocks/Composer/parseMentionValue.js +55 -0
- package/dist/blocks/Composer/placeDictation.js +51 -0
- package/dist/blocks/Composer/rankMentions.js +51 -0
- package/dist/blocks/Composer/replaceRange.js +48 -0
- package/dist/blocks/Composer/segmentText.js +78 -0
- package/dist/blocks/Composer/shiftOffset.js +37 -0
- package/dist/blocks/Composer/snapSelection.js +37 -0
- package/dist/blocks/Composer/useMentionEditor.js +381 -0
- package/dist/blocks/Composer/withPartial.js +50 -0
- package/dist/blocks/DateSelector/DateSelector.js +250 -0
- package/dist/blocks/DateSelector/formatDateValue.js +34 -0
- package/dist/blocks/DateSelector/getDateMenuActions.js +96 -0
- package/dist/blocks/DateSelector/meta.js +109 -0
- package/dist/blocks/DateSelector/toBoundDate.js +40 -0
- package/dist/blocks/DateSelector/toPickerDate.js +31 -0
- package/dist/blocks/DateSelector/toUtcDay.js +25 -0
- package/dist/blocks/Divider/Divider.js +159 -0
- package/dist/blocks/Divider/meta.js +108 -0
- package/dist/blocks/Empty/Empty.js +107 -0
- package/dist/blocks/Empty/meta.js +61 -0
- package/dist/blocks/Icon/Icon.js +41 -0
- package/dist/blocks/Icon/meta.js +80 -0
- package/dist/blocks/Illustration/Illustration.js +154 -0
- package/dist/blocks/Illustration/IllustrationLayer.js +105 -0
- package/dist/blocks/Illustration/colorNodes.js +72 -0
- package/dist/blocks/Illustration/createIllustrationMotion.js +172 -0
- package/dist/blocks/Illustration/getIllustrationBox.js +54 -0
- package/dist/blocks/Illustration/getIllustrationColors.js +48 -0
- package/dist/blocks/Illustration/getKeyframeRange.js +99 -0
- package/dist/blocks/Illustration/getLayerBounds.js +74 -0
- package/dist/blocks/Illustration/getLayers.js +113 -0
- package/dist/blocks/Illustration/getNodePoints.js +210 -0
- package/dist/blocks/Illustration/meta.js +196 -0
- package/dist/blocks/Illustration/parseIllustration.js +84 -0
- package/dist/blocks/Illustration/toBoundingBoxGradients.js +188 -0
- package/dist/blocks/Illustration/useIllustrationMotion.js +75 -0
- package/dist/blocks/Label/Label.js +111 -0
- package/dist/blocks/Label/getLabelProperties.js +38 -0
- package/dist/blocks/Label/getLabelState.js +59 -0
- package/dist/blocks/List/List.js +159 -0
- package/dist/blocks/List/ListRow.js +74 -0
- package/dist/blocks/List/ListRowContext.js +20 -0
- package/dist/blocks/List/SectionHeader.js +119 -0
- package/dist/blocks/List/getSections.js +161 -0
- package/dist/blocks/List/meta.js +190 -0
- package/dist/blocks/ListItem/ListItem.js +418 -0
- package/dist/blocks/ListItem/ListItemContextMenu.js +58 -0
- package/dist/blocks/ListItem/getListItemParts.js +101 -0
- package/dist/blocks/ListItem/getSfSymbol.js +33 -0
- package/dist/blocks/ListItem/meta.js +284 -0
- package/dist/blocks/ListItem/showContextMenuAlert.js +36 -0
- package/dist/blocks/Markdown/ChipWidthContext.js +20 -0
- package/dist/blocks/Markdown/ChipWidthView.js +40 -0
- package/dist/blocks/Markdown/LinkChip.js +151 -0
- package/dist/blocks/Markdown/Markdown.js +42 -0
- package/dist/blocks/Markdown/MarkdownCode.js +67 -0
- package/dist/blocks/Markdown/MarkdownContent.js +101 -0
- package/dist/blocks/Markdown/MarkdownList.js +97 -0
- package/dist/blocks/Markdown/MarkdownListContext.js +22 -0
- package/dist/blocks/Markdown/MarkdownRenderer.js +223 -0
- package/dist/blocks/Markdown/MarkdownTable.js +96 -0
- package/dist/blocks/Markdown/MarkdownTokenizer.js +43 -0
- package/dist/blocks/Markdown/TaskBox.js +58 -0
- package/dist/blocks/Markdown/TaskMark.js +37 -0
- package/dist/blocks/Markdown/getChipMaxWidth.js +33 -0
- package/dist/blocks/Markdown/getLinkChip.js +95 -0
- package/dist/blocks/Markdown/getLinkChipColors.js +51 -0
- package/dist/blocks/Markdown/getListMarker.js +116 -0
- package/dist/blocks/Markdown/getMarkdownStyles.js +206 -0
- package/dist/blocks/Markdown/getNodeText.js +37 -0
- package/dist/blocks/Markdown/layoutLinkChips.js +209 -0
- package/dist/blocks/Markdown/matchLinkChip.js +82 -0
- package/dist/blocks/Markdown/meta.js +50 -0
- package/dist/blocks/Markdown/restyleText.js +40 -0
- package/dist/blocks/Markdown/trimOuterSpace.js +42 -0
- package/dist/blocks/Menu/Menu.js +96 -0
- package/dist/blocks/Menu/getMenuActions.js +66 -0
- package/dist/blocks/Menu/meta.js +159 -0
- package/dist/blocks/MultipleSelector/MultipleSelector.js +288 -0
- package/dist/blocks/MultipleSelector/MultipleSelectorRow.js +71 -0
- package/dist/blocks/MultipleSelector/ValueSummary.js +130 -0
- package/dist/blocks/MultipleSelector/getOptionIndices.js +30 -0
- package/dist/blocks/MultipleSelector/getSessionOptions.js +38 -0
- package/dist/blocks/MultipleSelector/getSummaryCount.js +35 -0
- package/dist/blocks/MultipleSelector/meta.js +284 -0
- package/dist/blocks/MultipleSelector/toggleValue.js +50 -0
- package/dist/blocks/NumberInput/NumberInput.js +251 -0
- package/dist/blocks/NumberInput/StepButton.js +46 -0
- package/dist/blocks/NumberInput/formatNumber.js +35 -0
- package/dist/blocks/NumberInput/getNumberKeyboardType.js +32 -0
- package/dist/blocks/NumberInput/meta.js +123 -0
- package/dist/blocks/NumberInput/normalizeNumber.js +38 -0
- package/dist/blocks/NumberInput/parseNumberText.js +46 -0
- package/dist/blocks/PageDots/PageDots.js +131 -0
- package/dist/blocks/PageDots/meta.js +48 -0
- package/dist/blocks/Paragraph/Paragraph.js +52 -0
- package/dist/blocks/Paragraph/meta.js +295 -0
- package/dist/blocks/Screen/meta.js +197 -0
- package/dist/blocks/SegmentedControl/SegmentedControl.js +75 -0
- package/dist/blocks/SegmentedControl/meta.js +78 -0
- package/dist/blocks/Selector/NoValueAvatar.js +42 -0
- package/dist/blocks/Selector/PickerOptionRow.js +130 -0
- package/dist/blocks/Selector/PickerRowLeading.js +57 -0
- package/dist/blocks/Selector/PickerSearchField.js +85 -0
- package/dist/blocks/Selector/PickerSheet.js +239 -0
- package/dist/blocks/Selector/Selector.js +120 -0
- package/dist/blocks/Selector/SelectorMenu.js +97 -0
- package/dist/blocks/Selector/SelectorRow.js +86 -0
- package/dist/blocks/Selector/SelectorSheet.js +131 -0
- package/dist/blocks/Selector/getOptionIndex.js +39 -0
- package/dist/blocks/Selector/getOptionLabel.js +32 -0
- package/dist/blocks/Selector/getOptionValue.js +20 -0
- package/dist/blocks/Selector/getPickerSheetDetents.js +45 -0
- package/dist/blocks/Selector/getPickerSheetRows.js +174 -0
- package/dist/blocks/Selector/getPickerSheetScrollIndex.js +35 -0
- package/dist/blocks/Selector/getSelectorMenuActions.js +61 -0
- package/dist/blocks/Selector/meta.js +195 -0
- package/dist/blocks/Selector/normalizeSearchText.js +27 -0
- package/dist/blocks/Selector/setSelectorValue.js +52 -0
- package/dist/blocks/Sheet/Sheet.js +174 -0
- package/dist/blocks/Sheet/getSheetDetents.js +56 -0
- package/dist/blocks/Sheet/meta.js +72 -0
- package/dist/blocks/Skeleton/Skeleton.js +131 -0
- package/dist/blocks/Skeleton/SkeletonCard.js +42 -0
- package/dist/blocks/Skeleton/SkeletonHero.js +72 -0
- package/dist/blocks/Skeleton/SkeletonInsetGroup.js +82 -0
- package/dist/blocks/Skeleton/SkeletonListRow.js +90 -0
- package/dist/blocks/Skeleton/SkeletonParagraph.js +36 -0
- package/dist/blocks/Skeleton/SkeletonRows.js +58 -0
- package/dist/blocks/Skeleton/SkeletonTimeline.js +88 -0
- package/dist/blocks/Skeleton/getBarWidth.js +45 -0
- package/dist/blocks/Skeleton/getParagraphWidths.js +56 -0
- package/dist/blocks/Skeleton/getSectionCounts.js +33 -0
- package/dist/blocks/Skeleton/getSkeletonVariant.js +27 -0
- package/dist/blocks/Skeleton/meta.js +98 -0
- package/dist/blocks/Spinner/Spinner.js +68 -0
- package/dist/blocks/Spinner/meta.js +35 -0
- package/dist/blocks/StatusIcon/StatusGlyph.js +247 -0
- package/dist/blocks/StatusIcon/StatusIcon.js +34 -0
- package/dist/blocks/StatusIcon/StatusMark.js +87 -0
- package/dist/blocks/StatusIcon/getPiePath.js +41 -0
- package/dist/blocks/StatusIcon/getStatusColor.js +61 -0
- package/dist/blocks/StatusIcon/meta.js +38 -0
- package/dist/blocks/StatusIcon/statusLabels.js +33 -0
- package/dist/blocks/Switch/Switch.js +83 -0
- package/dist/blocks/Switch/meta.js +78 -0
- package/dist/blocks/Tabs/Tabs.js +269 -0
- package/dist/blocks/Tabs/meta.js +305 -0
- package/dist/blocks/Tag/TONE_PALETTES.js +34 -0
- package/dist/blocks/Tag/Tag.js +173 -0
- package/dist/blocks/Tag/getTagColors.js +120 -0
- package/dist/blocks/Tag/getTagDotColor.js +32 -0
- package/dist/blocks/Tag/meta.js +131 -0
- package/dist/blocks/TextArea/ComposerSendButton.js +69 -0
- package/dist/blocks/TextArea/TextArea.js +167 -0
- package/dist/blocks/TextArea/meta.js +96 -0
- package/dist/blocks/TextInput/TextInput.js +253 -0
- package/dist/blocks/TextInput/applyReplaceInput.js +30 -0
- package/dist/blocks/TextInput/getKeyboardProps.js +64 -0
- package/dist/blocks/TextInput/getSearchBoxStyle.js +39 -0
- package/dist/blocks/TextInput/meta.js +113 -0
- package/dist/blocks/Title/Title.js +62 -0
- package/dist/blocks/Title/meta.js +355 -0
- package/dist/blocks.js +48 -0
- package/dist/dictation.js +17 -0
- package/dist/htmlToText.js +32 -0
- package/dist/metas.js +49 -0
- package/dist/schemas/avatar.js +40 -0
- package/dist/schemas/icon.js +65 -0
- package/dist/schemas/inputLabel.js +96 -0
- package/dist/schemas/inputProperties.js +92 -0
- package/dist/schemas/linkChips.js +85 -0
- package/dist/schemas/status.js +75 -0
- package/dist/schemas/textStyle.js +33 -0
- package/dist/schemas/tone.js +28 -0
- package/dist/shared/ClearButton.js +53 -0
- package/dist/shared/CountText.js +38 -0
- package/dist/shared/NativeMenu.js +66 -0
- package/dist/shared/OptionGlyph.js +58 -0
- package/dist/shared/PropertyRow.js +89 -0
- package/dist/shared/SheetCloseButton.js +51 -0
- package/dist/shared/SheetDoneButton.js +44 -0
- package/dist/shared/SwipeContext.js +20 -0
- package/dist/shared/SwipeableRow.js +292 -0
- package/dist/shared/SystemIcon.js +72 -0
- package/dist/shared/dictation/DictationButton.js +77 -0
- package/dist/shared/dictation/DictationWarning.js +89 -0
- package/dist/shared/dictation/LevelMeter.js +57 -0
- package/dist/shared/dictation/ListeningRow.js +100 -0
- package/dist/shared/dictation/PartialSpans.js +50 -0
- package/dist/shared/dictation/checkDictationAvailable.js +65 -0
- package/dist/shared/dictation/claimMic.js +68 -0
- package/dist/shared/dictation/createQueuedRecognizer.js +213 -0
- package/dist/shared/dictation/getDictationLevel.js +30 -0
- package/dist/shared/dictation/getDictationWarning.js +40 -0
- package/dist/shared/dictation/getLevelBars.js +38 -0
- package/dist/shared/dictation/getRecognizer.js +46 -0
- package/dist/shared/dictation/getStartOptions.js +42 -0
- package/dist/shared/dictation/insertAtSelection.js +48 -0
- package/dist/shared/dictation/pickRecognitionLocale.js +37 -0
- package/dist/shared/dictation/useDictation.js +299 -0
- package/dist/shared/getControlSize.js +50 -0
- package/dist/shared/getInputBoxStyle.js +93 -0
- package/dist/shared/getPropertyRowTextStyles.js +40 -0
- package/dist/shared/getSemanticColors.js +96 -0
- package/dist/shared/getToneColor.js +51 -0
- package/dist/shared/iosTextStyles.js +49 -0
- package/dist/shared/useBlockTokens.js +41 -0
- package/dist/skeleton/SkeletonFrameContext.js +21 -0
- package/dist/skeleton/SkeletonLine.js +46 -0
- package/dist/skeleton/SkeletonShape.js +140 -0
- package/dist/skeleton/createShimmerClock.js +57 -0
- package/dist/skeleton/shimmerClock.js +20 -0
- package/dist/skeleton/skeletonText.js +44 -0
- package/dist/skeleton/useShimmer.js +34 -0
- package/dist/types.js +17 -0
- package/dist/typography/TITLE_LEVEL_STYLES.js +24 -0
- package/dist/typography/TypographyText.js +78 -0
- package/dist/typography/getIosTextStyle.js +33 -0
- package/dist/typography/getTextStyle.js +94 -0
- package/dist/useComponentTokens.js +38 -0
- package/package.json +94 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React, { useState } from 'react';
|
|
16
|
+
import { Pressable, Text, View } from 'react-native';
|
|
17
|
+
import { type } from '@lowdefy/helpers';
|
|
18
|
+
import { withAlpha } from '@lowdefy/client-native';
|
|
19
|
+
import { convertStyle } from '@lowdefy/style-native';
|
|
20
|
+
import getIosTextStyle from '../../typography/getIosTextStyle.js';
|
|
21
|
+
import htmlToText from '../../htmlToText.js';
|
|
22
|
+
import meta from './meta.js';
|
|
23
|
+
import useComponentTokens from '../../useComponentTokens.js';
|
|
24
|
+
// The colour each type tints the callout with; info takes the app's tint.
|
|
25
|
+
const typeTokens = {
|
|
26
|
+
error: 'colorError',
|
|
27
|
+
info: 'colorTint',
|
|
28
|
+
success: 'colorSuccess',
|
|
29
|
+
warning: 'colorWarning'
|
|
30
|
+
};
|
|
31
|
+
// antd's Alert as an iOS callout: a rounded box tinted in the type's colour with its icon, the
|
|
32
|
+
// message (a headline over a description, when it has one), an action slot and a close button.
|
|
33
|
+
// `variant: outlined` adds a border of the type colour. A closable alert fires onClose, hides,
|
|
34
|
+
// then fires afterClose.
|
|
35
|
+
function Alert({ blockId, components, content, methods, properties, styles = {} }) {
|
|
36
|
+
const { isDark, tokens } = useComponentTokens(properties.theme);
|
|
37
|
+
const [closed, setClosed] = useState(false);
|
|
38
|
+
if (closed) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const banner = properties.banner === true;
|
|
42
|
+
// antd's default type: a banner warns, anything else informs.
|
|
43
|
+
const alertType = properties.type ?? (banner ? 'warning' : 'info');
|
|
44
|
+
const typeColor = tokens[typeTokens[alertType]];
|
|
45
|
+
const description = htmlToText(properties.description);
|
|
46
|
+
const hasDescription = type.isString(description) && description !== '';
|
|
47
|
+
const message = htmlToText(properties.message);
|
|
48
|
+
const hasCloseText = !type.isNone(properties.closeText) && properties.closeText !== '';
|
|
49
|
+
const closable = properties.closable === true || hasCloseText;
|
|
50
|
+
// The global colorIcon is antd's grey for icons; only the block's own colorIcon replaces the
|
|
51
|
+
// type colour.
|
|
52
|
+
const iconColor = properties.theme?.colorIcon ?? typeColor;
|
|
53
|
+
const padding = convertStyle({
|
|
54
|
+
padding: hasDescription ? tokens.withDescriptionPadding ?? '14px 16px' : tokens.defaultPadding ?? '12px 14px'
|
|
55
|
+
}).style;
|
|
56
|
+
const outlined = properties.variant === 'outlined' && !banner;
|
|
57
|
+
const close = async ()=>{
|
|
58
|
+
setClosed(true);
|
|
59
|
+
await methods.triggerEvent({
|
|
60
|
+
name: 'onClose'
|
|
61
|
+
});
|
|
62
|
+
methods.triggerEvent({
|
|
63
|
+
name: 'afterClose'
|
|
64
|
+
});
|
|
65
|
+
};
|
|
66
|
+
return /*#__PURE__*/ React.createElement(View, {
|
|
67
|
+
accessibilityRole: "alert",
|
|
68
|
+
style: [
|
|
69
|
+
{
|
|
70
|
+
alignItems: 'flex-start',
|
|
71
|
+
backgroundColor: withAlpha({
|
|
72
|
+
alpha: isDark ? 0.2 : 0.1,
|
|
73
|
+
color: typeColor
|
|
74
|
+
}),
|
|
75
|
+
borderColor: withAlpha({
|
|
76
|
+
alpha: 0.4,
|
|
77
|
+
color: typeColor
|
|
78
|
+
}),
|
|
79
|
+
borderRadius: banner ? 0 : 12,
|
|
80
|
+
borderWidth: outlined ? tokens.lineWidth : 0,
|
|
81
|
+
flexDirection: 'row',
|
|
82
|
+
gap: 10
|
|
83
|
+
},
|
|
84
|
+
padding,
|
|
85
|
+
styles.element
|
|
86
|
+
]
|
|
87
|
+
}, properties.showIcon === false ? null : /*#__PURE__*/ React.createElement(components.Icon, {
|
|
88
|
+
properties: properties.icon ?? {
|
|
89
|
+
name: alertType,
|
|
90
|
+
title: ''
|
|
91
|
+
},
|
|
92
|
+
styles: {
|
|
93
|
+
element: [
|
|
94
|
+
{
|
|
95
|
+
color: iconColor,
|
|
96
|
+
fontSize: hasDescription ? tokens.withDescriptionIconSize ?? 22 : 20,
|
|
97
|
+
marginTop: 1
|
|
98
|
+
},
|
|
99
|
+
styles.icon
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
testID: `${blockId}_icon`
|
|
103
|
+
}), /*#__PURE__*/ React.createElement(View, {
|
|
104
|
+
style: {
|
|
105
|
+
flex: 1
|
|
106
|
+
}
|
|
107
|
+
}, type.isNone(message) ? null : /*#__PURE__*/ React.createElement(Text, {
|
|
108
|
+
style: [
|
|
109
|
+
getIosTextStyle({
|
|
110
|
+
textStyle: hasDescription ? 'headline' : 'subheadline',
|
|
111
|
+
tokens
|
|
112
|
+
}),
|
|
113
|
+
{
|
|
114
|
+
marginBottom: hasDescription ? 2 : 0,
|
|
115
|
+
marginTop: hasDescription ? 0 : 1
|
|
116
|
+
},
|
|
117
|
+
styles.message
|
|
118
|
+
]
|
|
119
|
+
}, message), hasDescription ? /*#__PURE__*/ React.createElement(Text, {
|
|
120
|
+
style: [
|
|
121
|
+
getIosTextStyle({
|
|
122
|
+
color: tokens.colorSecondaryLabel,
|
|
123
|
+
textStyle: 'subheadline',
|
|
124
|
+
tokens
|
|
125
|
+
}),
|
|
126
|
+
styles.description
|
|
127
|
+
]
|
|
128
|
+
}, description) : null, content.action ? /*#__PURE__*/ React.createElement(View, {
|
|
129
|
+
style: [
|
|
130
|
+
{
|
|
131
|
+
marginTop: hasDescription ? 10 : 6
|
|
132
|
+
},
|
|
133
|
+
styles.action
|
|
134
|
+
]
|
|
135
|
+
}, content.action()) : null), closable ? /*#__PURE__*/ React.createElement(Pressable, {
|
|
136
|
+
accessibilityLabel: hasCloseText ? properties.closeText : 'Close',
|
|
137
|
+
accessibilityRole: "button",
|
|
138
|
+
hitSlop: 10,
|
|
139
|
+
onPress: close,
|
|
140
|
+
style: [
|
|
141
|
+
{
|
|
142
|
+
marginTop: 2
|
|
143
|
+
},
|
|
144
|
+
styles.closeIcon
|
|
145
|
+
],
|
|
146
|
+
testID: `${blockId}_close`
|
|
147
|
+
}, hasCloseText ? /*#__PURE__*/ React.createElement(Text, {
|
|
148
|
+
style: getIosTextStyle({
|
|
149
|
+
color: typeColor,
|
|
150
|
+
textStyle: 'subheadline',
|
|
151
|
+
tokens
|
|
152
|
+
})
|
|
153
|
+
}, properties.closeText) : /*#__PURE__*/ React.createElement(components.Icon, {
|
|
154
|
+
properties: properties.closeIcon ?? {
|
|
155
|
+
name: 'close',
|
|
156
|
+
title: ''
|
|
157
|
+
},
|
|
158
|
+
styles: {
|
|
159
|
+
element: {
|
|
160
|
+
color: tokens.colorSecondaryLabel,
|
|
161
|
+
fontSize: 16
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
})) : null);
|
|
165
|
+
}
|
|
166
|
+
Alert.meta = meta;
|
|
167
|
+
export default Alert;
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import icon from '../../schemas/icon.js';
|
|
16
|
+
export default {
|
|
17
|
+
category: 'container',
|
|
18
|
+
icons: [
|
|
19
|
+
'success',
|
|
20
|
+
'info',
|
|
21
|
+
'warning',
|
|
22
|
+
'error',
|
|
23
|
+
'close'
|
|
24
|
+
],
|
|
25
|
+
valueType: null,
|
|
26
|
+
slots: {
|
|
27
|
+
action: 'Action area content.'
|
|
28
|
+
},
|
|
29
|
+
cssKeys: {
|
|
30
|
+
element: 'The Alert element.',
|
|
31
|
+
icon: 'The icon in the Alert.',
|
|
32
|
+
message: 'The Alert message.',
|
|
33
|
+
description: 'The Alert description.',
|
|
34
|
+
action: 'The Alert action.',
|
|
35
|
+
closeIcon: 'The Alert close icon.'
|
|
36
|
+
},
|
|
37
|
+
events: {
|
|
38
|
+
onClose: 'Called when Alert close button is clicked.',
|
|
39
|
+
afterClose: 'Called after Alert has been closed.'
|
|
40
|
+
},
|
|
41
|
+
properties: {
|
|
42
|
+
type: 'object',
|
|
43
|
+
additionalProperties: false,
|
|
44
|
+
properties: {
|
|
45
|
+
banner: {
|
|
46
|
+
type: 'boolean',
|
|
47
|
+
default: false,
|
|
48
|
+
description: 'Style as banner at top of application window. On mobile, a banner has no border or rounded corners.'
|
|
49
|
+
},
|
|
50
|
+
closable: {
|
|
51
|
+
type: 'boolean',
|
|
52
|
+
default: false,
|
|
53
|
+
description: 'Allow alert to be closed.'
|
|
54
|
+
},
|
|
55
|
+
closeIcon: {
|
|
56
|
+
...icon,
|
|
57
|
+
description: 'Icon name (a semantic name like `edit`, a Lucide icon name like `Pencil`, or a set-qualified name like `tabler:Pencil`) or properties of an Icon block to customize the close icon of a closable alert.'
|
|
58
|
+
},
|
|
59
|
+
closeText: {
|
|
60
|
+
type: 'string',
|
|
61
|
+
description: 'Close text to show instead of the close icon. Makes the alert closable.'
|
|
62
|
+
},
|
|
63
|
+
description: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
description: 'Content description of alert - supports html. On mobile, tags are removed and the text is shown plain.'
|
|
66
|
+
},
|
|
67
|
+
icon: {
|
|
68
|
+
...icon,
|
|
69
|
+
description: 'Icon name (a semantic name like `edit`, a Lucide icon name like `Pencil`, or a set-qualified name like `tabler:Pencil`) or properties of an Icon block to customize alert icon.'
|
|
70
|
+
},
|
|
71
|
+
message: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: 'Content message of alert - supports html. On mobile, tags are removed and the text is shown plain.'
|
|
74
|
+
},
|
|
75
|
+
showIcon: {
|
|
76
|
+
type: 'boolean',
|
|
77
|
+
default: true,
|
|
78
|
+
description: 'Show type default icon.'
|
|
79
|
+
},
|
|
80
|
+
type: {
|
|
81
|
+
type: 'string',
|
|
82
|
+
enum: [
|
|
83
|
+
'success',
|
|
84
|
+
'info',
|
|
85
|
+
'warning',
|
|
86
|
+
'error'
|
|
87
|
+
],
|
|
88
|
+
default: 'info',
|
|
89
|
+
description: 'Alert style type.'
|
|
90
|
+
},
|
|
91
|
+
variant: {
|
|
92
|
+
type: 'string',
|
|
93
|
+
enum: [
|
|
94
|
+
'outlined',
|
|
95
|
+
'filled'
|
|
96
|
+
],
|
|
97
|
+
default: 'outlined',
|
|
98
|
+
description: 'Alert style variant. `filled` hides the border and keeps the background tint. On mobile an alert is an iOS callout: a rounded box tinted in its type colour (the tint for info), with a border only when `outlined` is set.'
|
|
99
|
+
},
|
|
100
|
+
theme: {
|
|
101
|
+
type: 'object',
|
|
102
|
+
description: 'Antd design token overrides for this block. See <a href="https://ant.design/components/overview#design-token">antd design tokens</a>.',
|
|
103
|
+
docs: {
|
|
104
|
+
displayType: 'yaml',
|
|
105
|
+
link: 'https://ant.design/components/alert#design-token'
|
|
106
|
+
},
|
|
107
|
+
properties: {
|
|
108
|
+
defaultPadding: {
|
|
109
|
+
type: 'string',
|
|
110
|
+
default: '8px 12px',
|
|
111
|
+
description: 'Default padding for the alert without description.'
|
|
112
|
+
},
|
|
113
|
+
withDescriptionPadding: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
default: '20px 24px',
|
|
116
|
+
description: 'Padding for the alert when a description is present.'
|
|
117
|
+
},
|
|
118
|
+
withDescriptionIconSize: {
|
|
119
|
+
type: 'number',
|
|
120
|
+
default: 24,
|
|
121
|
+
description: 'Icon size when the alert has a description.'
|
|
122
|
+
},
|
|
123
|
+
colorText: {
|
|
124
|
+
type: 'string',
|
|
125
|
+
description: 'Text color of the alert message.'
|
|
126
|
+
},
|
|
127
|
+
colorTextHeading: {
|
|
128
|
+
type: 'string',
|
|
129
|
+
description: 'Heading text color when the alert has a description.'
|
|
130
|
+
},
|
|
131
|
+
colorIcon: {
|
|
132
|
+
type: 'string',
|
|
133
|
+
description: 'Icon color override.'
|
|
134
|
+
},
|
|
135
|
+
colorIconHover: {
|
|
136
|
+
type: 'string',
|
|
137
|
+
description: 'Icon hover color for the close button.'
|
|
138
|
+
},
|
|
139
|
+
fontSize: {
|
|
140
|
+
type: 'number',
|
|
141
|
+
default: 14,
|
|
142
|
+
description: 'Font size of the alert text.'
|
|
143
|
+
},
|
|
144
|
+
fontSizeLG: {
|
|
145
|
+
type: 'number',
|
|
146
|
+
default: 16,
|
|
147
|
+
description: 'Font size of the alert message when a description is present.'
|
|
148
|
+
},
|
|
149
|
+
lineHeight: {
|
|
150
|
+
type: 'number',
|
|
151
|
+
default: 1.5714,
|
|
152
|
+
description: 'Line height of the alert text.'
|
|
153
|
+
},
|
|
154
|
+
borderRadius: {
|
|
155
|
+
type: 'number',
|
|
156
|
+
default: 8,
|
|
157
|
+
description: 'Border radius of the alert container.'
|
|
158
|
+
},
|
|
159
|
+
borderRadiusLG: {
|
|
160
|
+
type: 'number',
|
|
161
|
+
default: 8,
|
|
162
|
+
description: 'Border radius for large alerts.'
|
|
163
|
+
},
|
|
164
|
+
colorSuccessBg: {
|
|
165
|
+
type: 'string',
|
|
166
|
+
description: 'Background color for success alerts.'
|
|
167
|
+
},
|
|
168
|
+
colorSuccessBorder: {
|
|
169
|
+
type: 'string',
|
|
170
|
+
description: 'Border color for success alerts.'
|
|
171
|
+
},
|
|
172
|
+
colorInfoBg: {
|
|
173
|
+
type: 'string',
|
|
174
|
+
description: 'Background color for info alerts.'
|
|
175
|
+
},
|
|
176
|
+
colorInfoBorder: {
|
|
177
|
+
type: 'string',
|
|
178
|
+
description: 'Border color for info alerts.'
|
|
179
|
+
},
|
|
180
|
+
colorWarningBg: {
|
|
181
|
+
type: 'string',
|
|
182
|
+
description: 'Background color for warning alerts.'
|
|
183
|
+
},
|
|
184
|
+
colorWarningBorder: {
|
|
185
|
+
type: 'string',
|
|
186
|
+
description: 'Border color for warning alerts.'
|
|
187
|
+
},
|
|
188
|
+
colorErrorBg: {
|
|
189
|
+
type: 'string',
|
|
190
|
+
description: 'Background color for error alerts.'
|
|
191
|
+
},
|
|
192
|
+
colorErrorBorder: {
|
|
193
|
+
type: 'string',
|
|
194
|
+
description: 'Border color for error alerts.'
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React from 'react';
|
|
16
|
+
import { type } from '@lowdefy/helpers';
|
|
17
|
+
import AvatarCircle from './AvatarCircle.js';
|
|
18
|
+
import AvatarStack from './AvatarStack.js';
|
|
19
|
+
import meta from './meta.js';
|
|
20
|
+
import useComponentTokens from '../../useComponentTokens.js';
|
|
21
|
+
/**
|
|
22
|
+
* A person's avatar: their initials on a colour their name picks, the same colour everywhere,
|
|
23
|
+
* or their image. With `avatars` it stacks several, overlapping, as a list of assignees does.
|
|
24
|
+
*/ function Avatar({ blockId, properties, styles }) {
|
|
25
|
+
const { isDark, tokens } = useComponentTokens(properties.theme);
|
|
26
|
+
const size = properties.size ?? 28;
|
|
27
|
+
if (type.isArray(properties.avatars)) {
|
|
28
|
+
return /*#__PURE__*/ React.createElement(AvatarStack, {
|
|
29
|
+
avatars: properties.avatars,
|
|
30
|
+
isDark: isDark,
|
|
31
|
+
max: properties.max,
|
|
32
|
+
ringColor: properties.ringColor,
|
|
33
|
+
size: size,
|
|
34
|
+
style: styles.element,
|
|
35
|
+
testID: `${blockId}_avatar`,
|
|
36
|
+
tokens: tokens
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
return /*#__PURE__*/ React.createElement(AvatarCircle, {
|
|
40
|
+
avatar: properties,
|
|
41
|
+
isDark: isDark,
|
|
42
|
+
size: size,
|
|
43
|
+
style: styles.element,
|
|
44
|
+
testID: `${blockId}_avatar`,
|
|
45
|
+
tokens: tokens
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
Avatar.meta = meta;
|
|
49
|
+
export default Avatar;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React, { useMemo, useState } from 'react';
|
|
16
|
+
import { StyleSheet, Text, View } from 'react-native';
|
|
17
|
+
import { SvgAst } from 'react-native-svg';
|
|
18
|
+
import { type } from '@lowdefy/helpers';
|
|
19
|
+
import AvatarPhoto from './AvatarPhoto.js';
|
|
20
|
+
import getAvatarColor from './getAvatarColor.js';
|
|
21
|
+
import getAvatarImage from './getAvatarImage.js';
|
|
22
|
+
import getInitials from './getInitials.js';
|
|
23
|
+
/**
|
|
24
|
+
* One round avatar: the initials of its name on a colour the name picks, under its picture when
|
|
25
|
+
* it has one. An SVG data URI is drawn at once; a photo fades in over the initials once loaded.
|
|
26
|
+
* A picture that fails to load leaves the initials, until `src` changes.
|
|
27
|
+
*
|
|
28
|
+
* @param {Object} props
|
|
29
|
+
* @param {{ name?: string, src?: string, content?: string, color?: string }} props.avatar
|
|
30
|
+
* @param {boolean} props.isDark
|
|
31
|
+
* @param {string} [props.ringColor] A ring around the avatar, as a stacked avatar has.
|
|
32
|
+
* @param {number} props.size
|
|
33
|
+
* @param {Object} [props.style]
|
|
34
|
+
* @param {string} [props.testID]
|
|
35
|
+
* @param {Object} props.tokens
|
|
36
|
+
*/ function AvatarCircle({ avatar, isDark, ringColor, size, style, testID, tokens }) {
|
|
37
|
+
const image = useMemo(()=>getAvatarImage({
|
|
38
|
+
src: avatar.src
|
|
39
|
+
}), [
|
|
40
|
+
avatar.src
|
|
41
|
+
]);
|
|
42
|
+
// Both hold the src they are about, so a new src starts over without an effect to reset them.
|
|
43
|
+
const [failedSrc, setFailedSrc] = useState(null);
|
|
44
|
+
const [shownSrc, setShownSrc] = useState(null);
|
|
45
|
+
const drawImage = image !== null && failedSrc !== avatar.src;
|
|
46
|
+
const covered = drawImage && (image.kind === 'svg' || shownSrc === avatar.src);
|
|
47
|
+
const ring = type.isString(ringColor) ? Math.max(1.5, size / 16) : 0;
|
|
48
|
+
const shape = {
|
|
49
|
+
borderColor: ringColor,
|
|
50
|
+
borderRadius: (size + ring * 2) / 2,
|
|
51
|
+
borderWidth: ring,
|
|
52
|
+
height: size + ring * 2,
|
|
53
|
+
overflow: 'hidden',
|
|
54
|
+
width: size + ring * 2
|
|
55
|
+
};
|
|
56
|
+
const accessibilityProps = type.isString(avatar.name) ? {
|
|
57
|
+
accessible: true,
|
|
58
|
+
accessibilityLabel: avatar.name,
|
|
59
|
+
accessibilityRole: 'image'
|
|
60
|
+
} : {
|
|
61
|
+
accessibilityElementsHidden: true,
|
|
62
|
+
importantForAccessibility: 'no-hide-descendants'
|
|
63
|
+
};
|
|
64
|
+
const { color } = getAvatarColor({
|
|
65
|
+
color: avatar.color,
|
|
66
|
+
isDark,
|
|
67
|
+
name: avatar.name,
|
|
68
|
+
tokens
|
|
69
|
+
});
|
|
70
|
+
return /*#__PURE__*/ React.createElement(View, {
|
|
71
|
+
...accessibilityProps,
|
|
72
|
+
style: [
|
|
73
|
+
shape,
|
|
74
|
+
{
|
|
75
|
+
alignItems: 'center',
|
|
76
|
+
backgroundColor: color,
|
|
77
|
+
justifyContent: 'center'
|
|
78
|
+
},
|
|
79
|
+
style
|
|
80
|
+
],
|
|
81
|
+
testID: testID
|
|
82
|
+
}, covered ? null : /*#__PURE__*/ React.createElement(Text, {
|
|
83
|
+
allowFontScaling: false,
|
|
84
|
+
numberOfLines: 1,
|
|
85
|
+
style: {
|
|
86
|
+
color: tokens.colorTextLightSolid,
|
|
87
|
+
fontSize: Math.round(size * 0.4),
|
|
88
|
+
fontWeight: '600',
|
|
89
|
+
letterSpacing: size <= 20 ? -0.2 : 0
|
|
90
|
+
}
|
|
91
|
+
}, getInitials({
|
|
92
|
+
content: avatar.content,
|
|
93
|
+
name: avatar.name
|
|
94
|
+
})), drawImage && image.kind === 'svg' ? /*#__PURE__*/ React.createElement(View, {
|
|
95
|
+
pointerEvents: "none",
|
|
96
|
+
style: StyleSheet.absoluteFill
|
|
97
|
+
}, /*#__PURE__*/ React.createElement(SvgAst, {
|
|
98
|
+
ast: image.ast,
|
|
99
|
+
override: {
|
|
100
|
+
height: size,
|
|
101
|
+
width: size
|
|
102
|
+
}
|
|
103
|
+
})) : null, drawImage && image.kind === 'uri' ? /*#__PURE__*/ React.createElement(AvatarPhoto, {
|
|
104
|
+
key: image.uri,
|
|
105
|
+
onError: ()=>setFailedSrc(avatar.src),
|
|
106
|
+
onShown: ()=>setShownSrc(avatar.src),
|
|
107
|
+
size: size,
|
|
108
|
+
uri: image.uri
|
|
109
|
+
}) : null);
|
|
110
|
+
}
|
|
111
|
+
export default AvatarCircle;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React, { useRef } from 'react';
|
|
16
|
+
import { Animated, Easing, StyleSheet } from 'react-native';
|
|
17
|
+
import { Image } from 'expo-image';
|
|
18
|
+
const FADE_MS = 220;
|
|
19
|
+
/**
|
|
20
|
+
* An avatar's photo over its initials, loaded and cached (in memory and on disk) by expo-image.
|
|
21
|
+
* It fades in once it has loaded, except from the memory cache, so rows scrolled back into view
|
|
22
|
+
* do not flicker. Give it a `key` of its url, so a new picture starts hidden again.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} props
|
|
25
|
+
* @param {Function} props.onError Called when the image fails to load.
|
|
26
|
+
* @param {Function} props.onShown Called once the image covers the initials.
|
|
27
|
+
* @param {number} props.size
|
|
28
|
+
* @param {string} props.uri
|
|
29
|
+
*/ function AvatarPhoto({ onError, onShown, size, uri }) {
|
|
30
|
+
const opacity = useRef(new Animated.Value(0)).current;
|
|
31
|
+
const onLoad = ({ cacheType })=>{
|
|
32
|
+
if (cacheType === 'memory') {
|
|
33
|
+
opacity.setValue(1);
|
|
34
|
+
onShown();
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
Animated.timing(opacity, {
|
|
38
|
+
duration: FADE_MS,
|
|
39
|
+
easing: Easing.out(Easing.quad),
|
|
40
|
+
toValue: 1,
|
|
41
|
+
useNativeDriver: true
|
|
42
|
+
}).start(({ finished })=>{
|
|
43
|
+
if (finished) onShown();
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
return /*#__PURE__*/ React.createElement(Animated.View, {
|
|
47
|
+
pointerEvents: "none",
|
|
48
|
+
style: [
|
|
49
|
+
StyleSheet.absoluteFill,
|
|
50
|
+
{
|
|
51
|
+
opacity
|
|
52
|
+
}
|
|
53
|
+
]
|
|
54
|
+
}, /*#__PURE__*/ React.createElement(Image, {
|
|
55
|
+
accessibilityIgnoresInvertColors: true,
|
|
56
|
+
cachePolicy: "memory-disk",
|
|
57
|
+
contentFit: "cover",
|
|
58
|
+
onError: onError,
|
|
59
|
+
onLoad: onLoad,
|
|
60
|
+
recyclingKey: uri,
|
|
61
|
+
source: {
|
|
62
|
+
uri
|
|
63
|
+
},
|
|
64
|
+
style: {
|
|
65
|
+
height: size,
|
|
66
|
+
width: size
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
}
|
|
70
|
+
export default AvatarPhoto;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2026 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ import React from 'react';
|
|
16
|
+
import { Text, View } from 'react-native';
|
|
17
|
+
import { type } from '@lowdefy/helpers';
|
|
18
|
+
import AvatarCircle from './AvatarCircle.js';
|
|
19
|
+
import getSemanticColors from '../../shared/getSemanticColors.js';
|
|
20
|
+
/**
|
|
21
|
+
* Overlapping avatars, the first on top, each ringed in the surface colour so the overlaps read.
|
|
22
|
+
* Past `max`, a "+n" circle counts the rest.
|
|
23
|
+
*
|
|
24
|
+
* @param {Object} props
|
|
25
|
+
* @param {Object[]} props.avatars
|
|
26
|
+
* @param {boolean} props.isDark
|
|
27
|
+
* @param {number} [props.max]
|
|
28
|
+
* @param {string} [props.ringColor] Defaults to the cell colour.
|
|
29
|
+
* @param {number} props.size
|
|
30
|
+
* @param {Object} [props.style]
|
|
31
|
+
* @param {string} props.testID
|
|
32
|
+
* @param {Object} props.tokens
|
|
33
|
+
*/ function AvatarStack({ avatars, isDark, max, ringColor, size, style, testID, tokens }) {
|
|
34
|
+
const colors = getSemanticColors({
|
|
35
|
+
tokens
|
|
36
|
+
});
|
|
37
|
+
const ring = ringColor ?? colors.cell;
|
|
38
|
+
const shown = type.isNumber(max) ? avatars.slice(0, max) : avatars;
|
|
39
|
+
const rest = avatars.length - shown.length;
|
|
40
|
+
const overlap = -Math.round(size * 0.3);
|
|
41
|
+
const names = avatars.map((avatar)=>avatar.name).filter((name)=>type.isString(name));
|
|
42
|
+
return /*#__PURE__*/ React.createElement(View, {
|
|
43
|
+
accessible: true,
|
|
44
|
+
accessibilityLabel: names.join(', '),
|
|
45
|
+
style: [
|
|
46
|
+
{
|
|
47
|
+
alignItems: 'center',
|
|
48
|
+
flexDirection: 'row'
|
|
49
|
+
},
|
|
50
|
+
style
|
|
51
|
+
],
|
|
52
|
+
testID: testID
|
|
53
|
+
}, shown.map((avatar, index)=>/*#__PURE__*/ React.createElement(AvatarCircle, {
|
|
54
|
+
avatar: avatar,
|
|
55
|
+
isDark: isDark,
|
|
56
|
+
key: `${avatar.name ?? avatar.src ?? ''}-${index}`,
|
|
57
|
+
ringColor: ring,
|
|
58
|
+
size: size,
|
|
59
|
+
style: {
|
|
60
|
+
marginLeft: index === 0 ? 0 : overlap,
|
|
61
|
+
zIndex: shown.length - index
|
|
62
|
+
},
|
|
63
|
+
testID: `${testID}_${index}`,
|
|
64
|
+
tokens: tokens
|
|
65
|
+
})), rest > 0 ? /*#__PURE__*/ React.createElement(View, {
|
|
66
|
+
style: {
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
backgroundColor: tokens.colorFillSecondary,
|
|
69
|
+
borderColor: ring,
|
|
70
|
+
borderRadius: size,
|
|
71
|
+
borderWidth: Math.max(1.5, size / 16),
|
|
72
|
+
height: size + Math.max(1.5, size / 16) * 2,
|
|
73
|
+
justifyContent: 'center',
|
|
74
|
+
marginLeft: overlap,
|
|
75
|
+
minWidth: size + Math.max(1.5, size / 16) * 2,
|
|
76
|
+
paddingHorizontal: 2
|
|
77
|
+
}
|
|
78
|
+
}, /*#__PURE__*/ React.createElement(Text, {
|
|
79
|
+
allowFontScaling: false,
|
|
80
|
+
style: {
|
|
81
|
+
color: colors.secondaryLabel,
|
|
82
|
+
fontSize: Math.round(size * 0.38),
|
|
83
|
+
fontWeight: '600'
|
|
84
|
+
}
|
|
85
|
+
}, `+${rest}`)) : null);
|
|
86
|
+
}
|
|
87
|
+
export default AvatarStack;
|