@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,61 @@
|
|
|
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 { type } from '@lowdefy/helpers';
|
|
16
|
+
import getOptionLabel from './getOptionLabel.js';
|
|
17
|
+
// The menu item that stands for no value.
|
|
18
|
+
const NO_VALUE_ID = 'no_value';
|
|
19
|
+
function getOptionImage(option) {
|
|
20
|
+
if (!type.isObject(option)) return undefined;
|
|
21
|
+
return option.symbol ?? (option.avatar ? 'person.crop.circle' : undefined);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The native menu actions of a Selector with `variant: menu`: one checkable item per option,
|
|
25
|
+
* the chosen one checked, each with its SF Symbol (or the person symbol for an option with
|
|
26
|
+
* an avatar). A disabled option is shown dimmed. The placeholder item, checked while nothing is
|
|
27
|
+
* chosen, comes first while there is no value or the value can be cleared. An action's id is
|
|
28
|
+
* its option's index, as the menu passes ids back as strings.
|
|
29
|
+
*
|
|
30
|
+
* @param {Object} params
|
|
31
|
+
* @param {boolean} params.allowClear
|
|
32
|
+
* @param {Array} params.options
|
|
33
|
+
* @param {string} params.placeholder
|
|
34
|
+
* @param {number|null} params.selectedIndex
|
|
35
|
+
* @returns {Object[]}
|
|
36
|
+
*/ function getSelectorMenuActions({ allowClear, options, placeholder, selectedIndex }) {
|
|
37
|
+
const actions = options.map((option, index)=>({
|
|
38
|
+
id: `${index}`,
|
|
39
|
+
title: getOptionLabel({
|
|
40
|
+
option
|
|
41
|
+
}),
|
|
42
|
+
image: getOptionImage(option),
|
|
43
|
+
state: index === selectedIndex ? 'on' : 'off',
|
|
44
|
+
attributes: {
|
|
45
|
+
disabled: type.isObject(option) && option.disabled === true
|
|
46
|
+
}
|
|
47
|
+
}));
|
|
48
|
+
if (selectedIndex !== null && !allowClear) {
|
|
49
|
+
return actions;
|
|
50
|
+
}
|
|
51
|
+
return [
|
|
52
|
+
{
|
|
53
|
+
id: NO_VALUE_ID,
|
|
54
|
+
title: placeholder,
|
|
55
|
+
state: selectedIndex === null ? 'on' : 'off'
|
|
56
|
+
},
|
|
57
|
+
...actions
|
|
58
|
+
];
|
|
59
|
+
}
|
|
60
|
+
export { NO_VALUE_ID };
|
|
61
|
+
export default getSelectorMenuActions;
|
|
@@ -0,0 +1,195 @@
|
|
|
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 label from '../../schemas/inputLabel.js';
|
|
16
|
+
import { allowClear, autoFocus, bordered, disabled, inputTitle, placeholder, sizeSmallDefaultLarge, theme, variant, webIcon } from '../../schemas/inputProperties.js';
|
|
17
|
+
const primitiveOption = {
|
|
18
|
+
type: [
|
|
19
|
+
'string',
|
|
20
|
+
'number',
|
|
21
|
+
'boolean'
|
|
22
|
+
]
|
|
23
|
+
};
|
|
24
|
+
export default {
|
|
25
|
+
category: 'input',
|
|
26
|
+
icons: [
|
|
27
|
+
'Check',
|
|
28
|
+
'ChevronsUpDown',
|
|
29
|
+
'Search',
|
|
30
|
+
'X'
|
|
31
|
+
],
|
|
32
|
+
valueType: 'any',
|
|
33
|
+
cssKeys: {
|
|
34
|
+
element: 'The Selector box, or the row of the menu and sheet variants.',
|
|
35
|
+
label: 'The Selector label.',
|
|
36
|
+
extra: 'The Selector extra content.',
|
|
37
|
+
feedback: 'The Selector validation feedback.',
|
|
38
|
+
value: 'The chosen option text of the menu and sheet variants.'
|
|
39
|
+
},
|
|
40
|
+
events: {
|
|
41
|
+
onChange: {
|
|
42
|
+
description: 'Trigger actions when an option is picked.',
|
|
43
|
+
event: {
|
|
44
|
+
value: 'The value of the picked option, or null for no value.'
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
onClear: 'Trigger actions when the value is cleared.'
|
|
48
|
+
},
|
|
49
|
+
properties: {
|
|
50
|
+
type: 'object',
|
|
51
|
+
additionalProperties: false,
|
|
52
|
+
properties: {
|
|
53
|
+
allowClear: {
|
|
54
|
+
...allowClear,
|
|
55
|
+
default: true,
|
|
56
|
+
description: 'Keep the placeholder in the picker, so the value can be cleared.'
|
|
57
|
+
},
|
|
58
|
+
appearance: {
|
|
59
|
+
type: 'string',
|
|
60
|
+
enum: [
|
|
61
|
+
'menu',
|
|
62
|
+
'wheel'
|
|
63
|
+
],
|
|
64
|
+
default: 'menu',
|
|
65
|
+
description: "Mobile only. 'menu' opens a menu of options; 'wheel' shows the iOS scroll wheel in place (Android shows a menu)."
|
|
66
|
+
},
|
|
67
|
+
autoFocus,
|
|
68
|
+
bordered,
|
|
69
|
+
disabled,
|
|
70
|
+
label,
|
|
71
|
+
options: {
|
|
72
|
+
description: 'Options to pick from: primitives, or objects with a label and a value. Labels show as plain text on mobile.',
|
|
73
|
+
oneOf: [
|
|
74
|
+
{
|
|
75
|
+
type: 'array',
|
|
76
|
+
items: primitiveOption
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
type: 'array',
|
|
80
|
+
items: {
|
|
81
|
+
type: 'object',
|
|
82
|
+
required: [
|
|
83
|
+
'value'
|
|
84
|
+
],
|
|
85
|
+
properties: {
|
|
86
|
+
label: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
description: 'Option label.'
|
|
89
|
+
},
|
|
90
|
+
value: {
|
|
91
|
+
description: 'The value the option sets. Can be any type.'
|
|
92
|
+
},
|
|
93
|
+
disabled: {
|
|
94
|
+
type: 'boolean',
|
|
95
|
+
default: false,
|
|
96
|
+
description: 'Leave the option out of the picker. The menu and sheet variants show it dimmed.'
|
|
97
|
+
},
|
|
98
|
+
symbol: {
|
|
99
|
+
type: 'string',
|
|
100
|
+
description: 'Mobile menu and sheet variants only. An SF Symbol name drawn beside the option in the native menu or the sheet and, on iOS, beside the chosen option in the row.'
|
|
101
|
+
},
|
|
102
|
+
icon: {
|
|
103
|
+
type: 'string',
|
|
104
|
+
description: 'Mobile menu and sheet variants only. An icon name from the app icon data, drawn beside the option in the sheet and the chosen option in the row where there is no SF Symbol (Android, or an option without symbol).'
|
|
105
|
+
},
|
|
106
|
+
iconColor: {
|
|
107
|
+
type: 'string',
|
|
108
|
+
description: 'Mobile menu and sheet variants only. The colour of the glyph in the row and the sheet: a palette hue (`amber`, `blue`), a theme token (`colorPrimary`, `colorTint`) or a colour value.'
|
|
109
|
+
},
|
|
110
|
+
avatar: {
|
|
111
|
+
type: 'object',
|
|
112
|
+
description: 'Mobile menu and sheet variants only. A person the option stands for, drawn as an avatar (their picture, or initials) beside the chosen option in the row and beside the option in the sheet; the native menu shows the person symbol.',
|
|
113
|
+
properties: {
|
|
114
|
+
name: {
|
|
115
|
+
type: 'string',
|
|
116
|
+
description: 'The name the initials are taken from.'
|
|
117
|
+
},
|
|
118
|
+
src: {
|
|
119
|
+
type: 'string',
|
|
120
|
+
description: 'A picture url or SVG data URI, drawn in place of the initials.'
|
|
121
|
+
},
|
|
122
|
+
color: {
|
|
123
|
+
type: 'string',
|
|
124
|
+
description: 'The circle colour.'
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
description: {
|
|
129
|
+
type: 'string',
|
|
130
|
+
description: 'Mobile sheet variant only. A line of secondary text under the option label, such as an email address.'
|
|
131
|
+
},
|
|
132
|
+
pinned: {
|
|
133
|
+
type: 'boolean',
|
|
134
|
+
default: false,
|
|
135
|
+
description: 'Mobile sheet variant only. Show the option in the group at the top of the sheet, under the placeholder item and above a hairline, such as "Assign to me".'
|
|
136
|
+
},
|
|
137
|
+
filterString: {
|
|
138
|
+
type: 'string',
|
|
139
|
+
nativeIgnored: true,
|
|
140
|
+
description: 'Ignored on mobile.'
|
|
141
|
+
},
|
|
142
|
+
style: {
|
|
143
|
+
type: 'object',
|
|
144
|
+
nativeIgnored: true,
|
|
145
|
+
description: 'Ignored on mobile.'
|
|
146
|
+
},
|
|
147
|
+
tag: {
|
|
148
|
+
type: 'object',
|
|
149
|
+
nativeIgnored: true,
|
|
150
|
+
description: 'Ignored on mobile.'
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
menuTitle: {
|
|
158
|
+
type: 'string',
|
|
159
|
+
description: 'Mobile menu and sheet variants only. A title at the top of the menu, on iOS, or centred in the sheet header (the Selector title by default).'
|
|
160
|
+
},
|
|
161
|
+
placeholder: {
|
|
162
|
+
...placeholder,
|
|
163
|
+
default: 'Select item'
|
|
164
|
+
},
|
|
165
|
+
searchThreshold: {
|
|
166
|
+
type: 'number',
|
|
167
|
+
default: 7,
|
|
168
|
+
description: 'Mobile sheet variant only. Show a search field above the options when there are more options than this. The search matches labels, ignoring case and accents.'
|
|
169
|
+
},
|
|
170
|
+
showSearch: {
|
|
171
|
+
type: 'boolean',
|
|
172
|
+
default: true,
|
|
173
|
+
nativeIgnored: true,
|
|
174
|
+
description: 'Ignored on mobile.'
|
|
175
|
+
},
|
|
176
|
+
size: sizeSmallDefaultLarge,
|
|
177
|
+
suffixIcon: webIcon,
|
|
178
|
+
theme,
|
|
179
|
+
title: inputTitle,
|
|
180
|
+
variant: {
|
|
181
|
+
...variant,
|
|
182
|
+
enum: [
|
|
183
|
+
'solid',
|
|
184
|
+
'outlined',
|
|
185
|
+
'filled',
|
|
186
|
+
'borderless',
|
|
187
|
+
'underlined',
|
|
188
|
+
'menu',
|
|
189
|
+
'sheet'
|
|
190
|
+
],
|
|
191
|
+
description: "Input visual variant. On mobile, 'menu' draws an iOS Settings-style row, the title at the left and the chosen option at the right, that opens a native menu of the options. 'sheet' draws the same row, opening a bottom sheet of the options with their avatar pictures, descriptions, a pinned group and a search field for a long list."
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
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
|
+
*/ // The combining marks NFD splits from their letters, so "é" matches "e".
|
|
16
|
+
const COMBINING_MARKS = /[̀-ͯ]/g;
|
|
17
|
+
/**
|
|
18
|
+
* Text as a picker search compares it: decomposed with its accents dropped, in lower case and
|
|
19
|
+
* trimmed, so a search ignores case and diacritics.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} params
|
|
22
|
+
* @param {string} params.text
|
|
23
|
+
* @returns {string}
|
|
24
|
+
*/ function normalizeSearchText({ text }) {
|
|
25
|
+
return text.normalize('NFD').replace(COMBINING_MARKS, '').toLowerCase().trim();
|
|
26
|
+
}
|
|
27
|
+
export default normalizeSearchText;
|
|
@@ -0,0 +1,52 @@
|
|
|
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 getOptionValue from './getOptionValue.js';
|
|
16
|
+
/**
|
|
17
|
+
* Sets the value a Selector's menu or sheet picked and fires its events: onChange with the new
|
|
18
|
+
* value, and onClear too when the pick was the item that stands for no value. Picking the option
|
|
19
|
+
* already chosen changes nothing.
|
|
20
|
+
*
|
|
21
|
+
* @param {Object} params
|
|
22
|
+
* @param {number|null} params.index The picked option's index, or null for no value.
|
|
23
|
+
* @param {Object} params.methods The block's methods.
|
|
24
|
+
* @param {Array} params.options
|
|
25
|
+
* @param {number|null} params.selectedIndex The index of the option chosen before the pick.
|
|
26
|
+
*/ function setSelectorValue({ index, methods, options, selectedIndex }) {
|
|
27
|
+
if (index === selectedIndex) return;
|
|
28
|
+
if (index === null) {
|
|
29
|
+
methods.setValue(null);
|
|
30
|
+
methods.triggerEvent({
|
|
31
|
+
name: 'onChange',
|
|
32
|
+
event: {
|
|
33
|
+
value: null
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
methods.triggerEvent({
|
|
37
|
+
name: 'onClear'
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const next = getOptionValue({
|
|
42
|
+
option: options[index]
|
|
43
|
+
});
|
|
44
|
+
methods.setValue(next);
|
|
45
|
+
methods.triggerEvent({
|
|
46
|
+
name: 'onChange',
|
|
47
|
+
event: {
|
|
48
|
+
value: next
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
export default setSelectorValue;
|
|
@@ -0,0 +1,174 @@
|
|
|
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, { useEffect, useMemo, useRef, useState } from 'react';
|
|
16
|
+
import { Platform, ScrollView, Text, View } from 'react-native';
|
|
17
|
+
import { BottomSheet } from '@expo/ui/community/bottom-sheet';
|
|
18
|
+
import { iosColors, NaturalSizeContext, ThemeContext, useScreenFocused, useTheme } from '@lowdefy/client-native';
|
|
19
|
+
import { type } from '@lowdefy/helpers';
|
|
20
|
+
import getSheetDetents from './getSheetDetents.js';
|
|
21
|
+
import meta from './meta.js';
|
|
22
|
+
import SheetCloseButton from '../../shared/SheetCloseButton.js';
|
|
23
|
+
import useComponentTokens from '../../useComponentTokens.js';
|
|
24
|
+
const CLOSED = -1;
|
|
25
|
+
const HEADER_HEIGHT = 44;
|
|
26
|
+
/**
|
|
27
|
+
* A native sheet holding child blocks: a SwiftUI sheet with medium and large detents on iOS, a
|
|
28
|
+
* Material modal bottom sheet on Android. It starts closed; the open and close methods present
|
|
29
|
+
* and dismiss it, and onOpen and onClose fire as it does. A swipe down dismisses it too, unless
|
|
30
|
+
* dragToDismiss is false. Its blocks mount while it is presented; their values stay in state.
|
|
31
|
+
*
|
|
32
|
+
* The sheet keeps the system's own background while the app shows the system's colour mode, and
|
|
33
|
+
* takes the theme's elevated background when the app forces the other mode.
|
|
34
|
+
*/ function Sheet({ blockId, components, content, methods, properties, styles = {} }) {
|
|
35
|
+
const { isDark, tokens } = useComponentTokens(properties.theme);
|
|
36
|
+
// The sheet's content is drawn on the elevated grouped surfaces, as a presented sheet is on iOS,
|
|
37
|
+
// so a grouped List in it stands off the sheet rather than taking the screen's colours.
|
|
38
|
+
const theme = useTheme();
|
|
39
|
+
const elevatedTheme = useMemo(()=>({
|
|
40
|
+
...theme,
|
|
41
|
+
tokens: {
|
|
42
|
+
...theme.tokens,
|
|
43
|
+
...iosColors.elevated[isDark ? 'dark' : 'light']
|
|
44
|
+
}
|
|
45
|
+
}), [
|
|
46
|
+
isDark,
|
|
47
|
+
theme
|
|
48
|
+
]);
|
|
49
|
+
// Kept while the colour is unchanged: iOS's BottomSheet re-applies its presentation modifiers
|
|
50
|
+
// when backgroundStyle changes identity, which cancels a touch on the sheet.
|
|
51
|
+
const backgroundColor = elevatedTheme.tokens.colorGroupedBackground;
|
|
52
|
+
const backgroundStyle = useMemo(()=>({
|
|
53
|
+
backgroundColor
|
|
54
|
+
}), [
|
|
55
|
+
backgroundColor
|
|
56
|
+
]);
|
|
57
|
+
const [index, setIndex] = useState(CLOSED);
|
|
58
|
+
const isOpen = index !== CLOSED;
|
|
59
|
+
// The latest open state, read by the registered methods.
|
|
60
|
+
const isOpenRef = useRef(isOpen);
|
|
61
|
+
isOpenRef.current = isOpen;
|
|
62
|
+
// A sheet is drawn above the whole app, so it closes when its screen stops being the one shown
|
|
63
|
+
// (another tab picked, or a screen pushed over it); otherwise it would sit over the next screen.
|
|
64
|
+
const focused = useScreenFocused();
|
|
65
|
+
useEffect(()=>{
|
|
66
|
+
if (!focused && isOpenRef.current) {
|
|
67
|
+
setIndex(CLOSED);
|
|
68
|
+
}
|
|
69
|
+
}, [
|
|
70
|
+
focused
|
|
71
|
+
]);
|
|
72
|
+
useEffect(()=>{
|
|
73
|
+
methods.registerMethod('open', ()=>{
|
|
74
|
+
if (isOpenRef.current) return;
|
|
75
|
+
isOpenRef.current = true;
|
|
76
|
+
setIndex(0);
|
|
77
|
+
methods.triggerEvent({
|
|
78
|
+
name: 'onOpen'
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
methods.registerMethod('close', ()=>{
|
|
82
|
+
setIndex(CLOSED);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
85
|
+
const { snapPoints, resizable } = getSheetDetents({
|
|
86
|
+
detents: properties.detents,
|
|
87
|
+
platform: Platform.OS
|
|
88
|
+
});
|
|
89
|
+
const dragToDismiss = properties.dragToDismiss !== false;
|
|
90
|
+
const closable = properties.closable ?? !dragToDismiss;
|
|
91
|
+
const title = type.isString(properties.title) ? properties.title : null;
|
|
92
|
+
const hasHeader = title !== null || closable || Boolean(content.headerRight);
|
|
93
|
+
return /*#__PURE__*/ React.createElement(BottomSheet, {
|
|
94
|
+
backgroundStyle: backgroundStyle,
|
|
95
|
+
enableDynamicSizing: false,
|
|
96
|
+
enablePanDownToClose: dragToDismiss,
|
|
97
|
+
handleComponent: resizable ? undefined : null,
|
|
98
|
+
index: index,
|
|
99
|
+
onClose: ()=>{
|
|
100
|
+
isOpenRef.current = false;
|
|
101
|
+
setIndex(CLOSED);
|
|
102
|
+
methods.triggerEvent({
|
|
103
|
+
name: 'onClose'
|
|
104
|
+
});
|
|
105
|
+
},
|
|
106
|
+
snapPoints: snapPoints
|
|
107
|
+
}, /*#__PURE__*/ React.createElement(ThemeContext.Provider, {
|
|
108
|
+
value: elevatedTheme
|
|
109
|
+
}, /*#__PURE__*/ React.createElement(View, {
|
|
110
|
+
style: [
|
|
111
|
+
{
|
|
112
|
+
flex: 1
|
|
113
|
+
},
|
|
114
|
+
styles.element
|
|
115
|
+
],
|
|
116
|
+
testID: blockId
|
|
117
|
+
}, hasHeader ? /*#__PURE__*/ React.createElement(View, {
|
|
118
|
+
style: [
|
|
119
|
+
{
|
|
120
|
+
alignItems: 'center',
|
|
121
|
+
flexDirection: 'row',
|
|
122
|
+
minHeight: HEADER_HEIGHT,
|
|
123
|
+
paddingHorizontal: 16
|
|
124
|
+
},
|
|
125
|
+
styles.header
|
|
126
|
+
]
|
|
127
|
+
}, /*#__PURE__*/ React.createElement(View, {
|
|
128
|
+
style: {
|
|
129
|
+
flex: 1
|
|
130
|
+
}
|
|
131
|
+
}), title === null ? null : /*#__PURE__*/ React.createElement(Text, {
|
|
132
|
+
accessibilityRole: "header",
|
|
133
|
+
numberOfLines: 1,
|
|
134
|
+
style: [
|
|
135
|
+
{
|
|
136
|
+
color: tokens.colorText,
|
|
137
|
+
fontSize: 17,
|
|
138
|
+
fontWeight: '600',
|
|
139
|
+
textAlign: 'center'
|
|
140
|
+
},
|
|
141
|
+
styles.title
|
|
142
|
+
]
|
|
143
|
+
}, title), /*#__PURE__*/ React.createElement(View, {
|
|
144
|
+
style: {
|
|
145
|
+
alignItems: 'flex-end',
|
|
146
|
+
flex: 1
|
|
147
|
+
}
|
|
148
|
+
}, content.headerRight ? /*#__PURE__*/ React.createElement(NaturalSizeContext.Provider, {
|
|
149
|
+
value: true
|
|
150
|
+
}, content.headerRight({
|
|
151
|
+
alignItems: 'center',
|
|
152
|
+
flexWrap: 'nowrap'
|
|
153
|
+
})) : null, !content.headerRight && closable ? /*#__PURE__*/ React.createElement(SheetCloseButton, {
|
|
154
|
+
components: components,
|
|
155
|
+
onPress: ()=>setIndex(CLOSED),
|
|
156
|
+
testID: `${blockId}_close`,
|
|
157
|
+
tokens: tokens
|
|
158
|
+
}) : null)) : null, /*#__PURE__*/ React.createElement(ScrollView, {
|
|
159
|
+
contentContainerStyle: [
|
|
160
|
+
{
|
|
161
|
+
padding: 16,
|
|
162
|
+
paddingBottom: 32
|
|
163
|
+
},
|
|
164
|
+
styles.body
|
|
165
|
+
],
|
|
166
|
+
keyboardDismissMode: "interactive",
|
|
167
|
+
keyboardShouldPersistTaps: "handled",
|
|
168
|
+
style: {
|
|
169
|
+
flex: 1
|
|
170
|
+
}
|
|
171
|
+
}, content.content ? content.content() : null))));
|
|
172
|
+
}
|
|
173
|
+
Sheet.meta = meta;
|
|
174
|
+
export default Sheet;
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
*/ // The same arrays each time: iOS's BottomSheet re-applies its presentation modifiers when the
|
|
16
|
+
// snapPoints prop changes identity, which cancels a touch on the sheet.
|
|
17
|
+
const MEDIUM = [
|
|
18
|
+
'50%'
|
|
19
|
+
];
|
|
20
|
+
const LARGE = [
|
|
21
|
+
'100%'
|
|
22
|
+
];
|
|
23
|
+
const MEDIUM_AND_LARGE = [
|
|
24
|
+
'50%',
|
|
25
|
+
'100%'
|
|
26
|
+
];
|
|
27
|
+
/**
|
|
28
|
+
* The BottomSheet props that give a Sheet its detents. On iOS, no snap points give the system
|
|
29
|
+
* medium and large detents; a single detent is a fraction of the large height. Android's sheet
|
|
30
|
+
* has a half-height and a full-height state, which two snap points turn on, and opens a single
|
|
31
|
+
* detent at full height.
|
|
32
|
+
*
|
|
33
|
+
* @param {Object} params
|
|
34
|
+
* @param {'both'|'medium'|'large'} [params.detents] Defaults to both.
|
|
35
|
+
* @param {string} params.platform Platform.OS.
|
|
36
|
+
* @returns {{ snapPoints: (string[]|undefined), resizable: boolean }} resizable is whether the
|
|
37
|
+
* sheet moves between detents, so it shows the drag indicator.
|
|
38
|
+
*/ function getSheetDetents({ detents = 'both', platform }) {
|
|
39
|
+
if (detents === 'medium') {
|
|
40
|
+
return {
|
|
41
|
+
snapPoints: MEDIUM,
|
|
42
|
+
resizable: false
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
if (detents === 'large') {
|
|
46
|
+
return {
|
|
47
|
+
snapPoints: LARGE,
|
|
48
|
+
resizable: false
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
snapPoints: platform === 'ios' ? undefined : MEDIUM_AND_LARGE,
|
|
53
|
+
resizable: true
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export default getSheetDetents;
|
|
@@ -0,0 +1,72 @@
|
|
|
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
|
+
*/ export default {
|
|
16
|
+
category: 'container',
|
|
17
|
+
icons: [
|
|
18
|
+
'X'
|
|
19
|
+
],
|
|
20
|
+
valueType: null,
|
|
21
|
+
slots: {
|
|
22
|
+
content: 'Blocks inside the sheet, in a scroll view.',
|
|
23
|
+
headerRight: 'Blocks at the right of the sheet header, such as a Save button. Replaces the close button.'
|
|
24
|
+
},
|
|
25
|
+
cssKeys: {
|
|
26
|
+
element: 'The sheet content.',
|
|
27
|
+
header: 'The sheet header.',
|
|
28
|
+
title: 'The sheet title.',
|
|
29
|
+
body: 'The scroll view content around the blocks.'
|
|
30
|
+
},
|
|
31
|
+
events: {
|
|
32
|
+
onOpen: 'Trigger actions when the open method presents the sheet.',
|
|
33
|
+
onClose: 'Trigger actions when the sheet has been dismissed, by the close method, the close button or a swipe down.'
|
|
34
|
+
},
|
|
35
|
+
methods: {
|
|
36
|
+
open: 'Present the sheet. Does nothing while it is open.',
|
|
37
|
+
close: 'Dismiss the sheet.'
|
|
38
|
+
},
|
|
39
|
+
properties: {
|
|
40
|
+
type: 'object',
|
|
41
|
+
additionalProperties: false,
|
|
42
|
+
properties: {
|
|
43
|
+
closable: {
|
|
44
|
+
type: 'boolean',
|
|
45
|
+
description: 'Show a close button at the right of the header. Defaults to true when dragToDismiss is false, so the sheet can always be closed.'
|
|
46
|
+
},
|
|
47
|
+
detents: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
enum: [
|
|
50
|
+
'both',
|
|
51
|
+
'medium',
|
|
52
|
+
'large'
|
|
53
|
+
],
|
|
54
|
+
default: 'both',
|
|
55
|
+
description: "The heights the sheet rests at. 'both' opens at medium (about half the screen) and can be dragged to large; 'medium' or 'large' keeps one height. Android opens a single detent at full height."
|
|
56
|
+
},
|
|
57
|
+
dragToDismiss: {
|
|
58
|
+
type: 'boolean',
|
|
59
|
+
default: true,
|
|
60
|
+
description: 'Dismiss the sheet when it is swiped down or, on iOS, when the dimmed page behind it is tapped.'
|
|
61
|
+
},
|
|
62
|
+
theme: {
|
|
63
|
+
type: 'object',
|
|
64
|
+
description: 'Antd design token overrides for this block, such as colorText, colorBgElevated or colorFillSecondary.'
|
|
65
|
+
},
|
|
66
|
+
title: {
|
|
67
|
+
type: 'string',
|
|
68
|
+
description: 'The title, centred in the sheet header.'
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|