@layers-app/editor-video 0.1.7 → 0.1.9

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.css CHANGED
@@ -99,6 +99,14 @@ div.doc-space-styles-provider .video-upload-container *::after {
99
99
  pointer-events: auto !important;
100
100
  }
101
101
 
102
+ .editor-select__chevron {
103
+ transition: transform 150ms ease;
104
+ }
105
+
106
+ [data-expanded=true] + * .editor-select__chevron {
107
+ transform: rotate(180deg);
108
+ }
109
+
102
110
  .media-actions .media-action {
103
111
  border: none;
104
112
  background-color: var(--mantine-color-body, white);
package/dist/index.js CHANGED
@@ -5,11 +5,12 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { createContext, useState, useRef, useCallback, useMemo, useContext, forwardRef, createElement, useEffect } from "react";
6
6
  import { createCommand, $getNodeByKey, $setSelection, COMMAND_PRIORITY_LOW, DecoratorNode } from "lexical";
7
7
  import { useTranslation } from "react-i18next";
8
- import { Tooltip, ActionIcon, Text, Progress, Paper, Button, TextInput, Menu, Box, Slider, Flex, Select, Stack, Divider, Group, Textarea, Loader, Switch, Modal } from "@mantine/core";
8
+ import { Tooltip, ActionIcon, Text, Progress, Paper, Button, TextInput, Menu, Box, Slider, Flex, useCombobox, Combobox, InputBase, Group, Stack, Divider, Textarea, Loader, Switch, Modal } from "@mantine/core";
9
9
  import { BlockWithAlignableContents } from "@lexical/react/LexicalBlockWithAlignableContents";
10
10
  import { useLexicalComposerContext } from "@lexical/react/LexicalComposerContext";
11
11
  import { Dropzone as Dropzone$1, IMAGE_MIME_TYPE } from "@mantine/dropzone";
12
12
  import ShakaPlayer from "shaka-player-react";
13
+ import { IconChevronDown, IconCheck } from "@tabler/icons-react";
13
14
  import { Carousel } from "@mantine/carousel";
14
15
  const VideoContext = createContext(null);
15
16
  function VideoPluginProvider({
@@ -4972,6 +4973,123 @@ function VideoPlayerState({
4972
4973
  }
4973
4974
  );
4974
4975
  }
4976
+ function VideoSelect({
4977
+ size = "sm",
4978
+ w = 150,
4979
+ comboboxProps,
4980
+ rightSection,
4981
+ renderOption,
4982
+ data,
4983
+ value,
4984
+ defaultValue,
4985
+ onChange,
4986
+ inputClassName,
4987
+ ...inputProps
4988
+ }) {
4989
+ var _a;
4990
+ const {
4991
+ onClick: onInputClick,
4992
+ type: _inputType,
4993
+ onCopy: _onCopy,
4994
+ onCut: _onCut,
4995
+ onPaste: _onPaste,
4996
+ classNames: parentClassNames,
4997
+ allowDeselect: _allowDeselect,
4998
+ ...restInputProps
4999
+ } = inputProps;
5000
+ const parentInputClass = typeof parentClassNames === "object" && parentClassNames && "input" in parentClassNames ? parentClassNames.input : void 0;
5001
+ const inputClass = [parentInputClass, inputClassName].filter(Boolean).join(" ") || void 0;
5002
+ const mergedClassNames = inputClass ? {
5003
+ ...typeof parentClassNames === "object" && parentClassNames ? parentClassNames : {},
5004
+ input: inputClass
5005
+ } : parentClassNames;
5006
+ const [search, setSearch] = useState("");
5007
+ const combobox = useCombobox({
5008
+ onDropdownClose: () => {
5009
+ combobox.resetSelectedOption();
5010
+ combobox.focusTarget();
5011
+ setSearch("");
5012
+ },
5013
+ onDropdownOpen: () => {
5014
+ combobox.focusSearchInput();
5015
+ }
5016
+ });
5017
+ const normalizedData = useMemo(
5018
+ () => (Array.isArray(data) ? data : []).map(
5019
+ (item) => typeof item === "string" ? { value: item, label: item } : item
5020
+ ),
5021
+ [data]
5022
+ );
5023
+ const selectedValue = value ?? defaultValue ?? null;
5024
+ const selectedLabel = ((_a = normalizedData.find((item) => item.value === selectedValue)) == null ? void 0 : _a.label) ?? "";
5025
+ const renderOptionNode = (optionValue, optionLabel, checked) => renderOption ? renderOption({
5026
+ option: { value: optionValue, label: optionLabel },
5027
+ checked
5028
+ }) : /* @__PURE__ */ jsxs(Group, { justify: "space-between", wrap: "nowrap", w: "100%", children: [
5029
+ optionLabel,
5030
+ checked && /* @__PURE__ */ jsx(IconCheck, { size: 16, color: "var(--primary-color-text, #4C6EF5)" })
5031
+ ] });
5032
+ const { width: comboboxWidth, ...restComboboxProps } = comboboxProps || {};
5033
+ const dropdownWidth = comboboxWidth ?? 250;
5034
+ return /* @__PURE__ */ jsxs(
5035
+ Combobox,
5036
+ {
5037
+ store: combobox,
5038
+ withinPortal: true,
5039
+ onOptionSubmit: (val) => {
5040
+ const option = normalizedData.find((item) => item.value === val) ?? {
5041
+ value: val,
5042
+ label: val
5043
+ };
5044
+ onChange == null ? void 0 : onChange(val, option);
5045
+ combobox.closeDropdown();
5046
+ },
5047
+ width: dropdownWidth,
5048
+ ...restComboboxProps,
5049
+ children: [
5050
+ /* @__PURE__ */ jsx(Combobox.Target, { children: /* @__PURE__ */ jsx(
5051
+ InputBase,
5052
+ {
5053
+ component: "button",
5054
+ size,
5055
+ w,
5056
+ classNames: mergedClassNames,
5057
+ pointer: true,
5058
+ rightSection: rightSection ?? /* @__PURE__ */ jsx(
5059
+ IconChevronDown,
5060
+ {
5061
+ size: 16,
5062
+ className: "editor-select__chevron",
5063
+ style: { cursor: "pointer" },
5064
+ onClick: () => combobox.toggleDropdown()
5065
+ }
5066
+ ),
5067
+ rightSectionPointerEvents: "all",
5068
+ onClick: (e) => {
5069
+ onInputClick == null ? void 0 : onInputClick(e);
5070
+ combobox.toggleDropdown();
5071
+ },
5072
+ ...restInputProps,
5073
+ children: selectedLabel
5074
+ }
5075
+ ) }),
5076
+ /* @__PURE__ */ jsx(Combobox.Dropdown, { children: /* @__PURE__ */ jsx(
5077
+ Combobox.Options,
5078
+ {
5079
+ style: {
5080
+ maxHeight: 200,
5081
+ overflowY: "auto"
5082
+ },
5083
+ children: normalizedData.length > 0 ? normalizedData.map((item) => {
5084
+ const checked = item.value === selectedValue;
5085
+ return /* @__PURE__ */ jsx(Combobox.Option, { value: item.value, children: renderOptionNode(item.value, item.label, checked) }, item.value);
5086
+ }) : /* @__PURE__ */ jsx(Combobox.Empty, { children: "Nothing found" })
5087
+ }
5088
+ ) })
5089
+ ]
5090
+ }
5091
+ );
5092
+ }
4975
5093
  const isLinkPlatform = (value) => value === "link" || value === "youtube" || value === "vk" || value === "rutube";
4976
5094
  const isUploadPlatform = (value) => value === "upload" || value === "download";
4977
5095
  function VideoUploadComponent({
@@ -4997,7 +5115,7 @@ function VideoUploadComponent({
4997
5115
  const { t, i18n } = useTranslation();
4998
5116
  const { config, dependencies, registerUpload, unregisterUpload, reportError } = useVideoPluginContext();
4999
5117
  const { maxFileSize = 5, pageId } = config;
5000
- const SelectComponent = dependencies.Select || Select;
5118
+ const SelectComponent = dependencies.Select || VideoSelect;
5001
5119
  const [currentState, setCurrentState] = useState(
5002
5120
  initialVideoState ?? "default"
5003
5121
  );
@@ -5841,7 +5959,7 @@ function ChaptersSection({
5841
5959
  addTranscriptManuallyLabel
5842
5960
  }) {
5843
5961
  const dependencies = useVideoPluginDependencies();
5844
- const SelectComponent = dependencies.Select || Select;
5962
+ const SelectComponent = dependencies.Select || VideoSelect;
5845
5963
  const [editableChapters, setEditableChapters] = useState(
5846
5964
  []
5847
5965
  );
@@ -6494,7 +6612,7 @@ function ManualSubtitlesPanel({
6494
6612
  const { t } = useTranslation();
6495
6613
  const { reportError } = useVideoPluginContext();
6496
6614
  const dependencies = useVideoPluginDependencies();
6497
- const SelectComponent = dependencies.Select || Select;
6615
+ const SelectComponent = dependencies.Select || VideoSelect;
6498
6616
  const [tracks, setTracks] = useState([]);
6499
6617
  const [drafts, setDrafts] = useState([]);
6500
6618
  const uploadControllersRef = useRef(/* @__PURE__ */ new Map());