@ryuzaki13/react-foundation-ui 1.0.4 → 1.0.6
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/chunks/Input-BmjlpA09.js.map +1 -1
- package/dist/chunks/Select-BJ5OqTe7.js +182 -0
- package/dist/chunks/Select-BJ5OqTe7.js.map +1 -0
- package/dist/chunks/{SerializableSelect-DkYeJtAO.js → SerializableSelect-CNe728Qa.js} +2 -2
- package/dist/chunks/{SerializableSelect-DkYeJtAO.js.map → SerializableSelect-CNe728Qa.js.map} +1 -1
- package/dist/chunks/{StateSelect-1jH3uLz9.js → StateSelect-ujAre258.js} +2 -2
- package/dist/chunks/{StateSelect-1jH3uLz9.js.map → StateSelect-ujAre258.js.map} +1 -1
- package/dist/chunks/{select-BT65bQ8J.js → select-BkLc6dyx.js} +2 -2
- package/dist/chunks/select-BkLc6dyx.js.map +1 -0
- package/dist/chunks/slider-CFKsfxFp.js.map +1 -1
- package/dist/expandable-action-panel/stories/ExpandableActionPanel.stories.js +1 -1
- package/dist/input/Input.d.ts +1 -1
- package/dist/input/Input.d.ts.map +1 -1
- package/dist/input/stories/Input.stories.js +1 -1
- package/dist/input/stories/Input.stories.js.map +1 -1
- package/dist/preset-select/index.js +1 -1
- package/dist/preset-select/index.js.map +1 -1
- package/dist/select/Select.d.ts +10 -5
- package/dist/select/Select.d.ts.map +1 -1
- package/dist/select/index.js +3 -3
- package/dist/select/stories/Select.stories.d.ts +1 -1
- package/dist/select/stories/Select.stories.js +1 -1
- package/dist/select/stories/SerializableSelect.stories.js +1 -1
- package/dist/slider/SliderInput.d.ts +2 -2
- package/dist/slider/SliderInput.d.ts.map +1 -1
- package/dist/slider/stories/SliderInput.stories.js.map +1 -1
- package/dist/state-select/index.js +1 -1
- package/dist/state-select/stories/StateSelect.stories.js +1 -1
- package/package.json +1 -1
- package/dist/chunks/Select-CXeVjVKA.js +0 -182
- package/dist/chunks/Select-CXeVjVKA.js.map +0 -1
- package/dist/chunks/select-BT65bQ8J.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SliderInput.stories.js","names":[],"sources":["../../../src/slider/stories/SliderInput.stories.tsx"],"sourcesContent":["import { ReactNode, useState } from \"react\";\n\nimport { createFilterBetween } from \"@ryuzaki13/react-foundation-lib/odata-service\";\n\nimport { SliderInput, SliderRangeInput, type SliderRangeValue } from \"..\";\n\nimport type { Meta, StoryObj } from \"@storybook/react-vite\";\n\nconst percentMarks = [\n\t{ value: 0, label: \"0\" },\n\t{ value: 20, label: \"20\" },\n\t{ value: 40, label: \"40\" },\n\t{ value: 60, label: \"60\" },\n\t{ value: 80, label: \"80\" },\n\t{ value: 100, label: \"100\" }\n] as const;\n\nconst openMonthMarks = [\n\t{ value: 0, label: \"Без нижней границы\", outputValue: null },\n\t{ value: 1, label: \"1 мес.\" },\n\t{ value: 3, label: \"3 мес.\" },\n\t{ value: 6, label: \"6 мес.\" },\n\t{ value: 12, label: \"12 мес.\" },\n\t{ value: 24, label: \"24 мес.\" },\n\t{ value: 25, label: \"Без верхней границы\", outputValue: null }\n] as const;\n\nconst monthToDayMarks = [\n\t{ value: 1, label: \"1 мес.\", outputValue: 30 },\n\t{ value: 3, label: \"3 мес.\", outputValue: 90 },\n\t{ value: 6, label: \"6 мес.\", outputValue: 180 },\n\t{ value: 12, label: \"12 мес.\", outputValue: 360 },\n\t{ value: 24, label: \"24 мес.\", outputValue: 720 }\n] as const;\n\nconst openMonthToDayMarks = [\n\t{ value: 0, label: \"-\", outputValue: null },\n\t{ value: 1, label: \"1м.\", outputValue: 30 },\n\t{ value: 3, label: \"3м.\", outputValue: 90 },\n\t{ value: 6, label: \"6м.\", outputValue: 180 },\n\t{ value: 12, label: \"1г.\", outputValue: 360 },\n\t{ value: 18, label: \"1.5г.\", outputValue: 540 },\n\t{ value: 24, label: \"2г.\", outputValue: 720 },\n\t{ value: 25, label: \"-\", outputValue: null }\n] as const;\n\nconst meta = {\n\ttitle: \"Shared/UI/SliderInput\",\n\tcomponent: SliderInput,\n\targs: {\n\t\tvalue: 12,\n\t\tonChange: () => {},\n\t\tmin: 0,\n\t\tmax: 100,\n\t\tstep: 0.5\n\t},\n\tparameters: {\n\t\tatomicCanvas: true,\n\t\tlayout: \"padded\"\n\t},\n\ttags: [\"autodocs\"]\n} satisfies Meta<typeof SliderInput>;\n\nexport default meta;\ntype Story = StoryObj<typeof meta>;\n\nfunction RangePreview({\n\tvalue,\n\tfield,\n\tchildren\n}: {\n\tvalue: SliderRangeValue | undefined;\n\tfield: string;\n\tunit?: string;\n\tchildren?: ReactNode;\n}) {\n\tconst [from, to] = value ?? [null, null];\n\n\treturn (\n\t\t<div className=\"marginTopMd\">\n\t\t\t<div className=\"textSm сontent2\">Preview фильтра</div>\n\t\t\t<pre>\n\t\t\t\t{JSON.stringify(\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: [from, to],\n\t\t\t\t\t\tfilter: createFilterBetween(field, value)\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t\t2\n\t\t\t\t)}\n\t\t\t</pre>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\nexport const Basic: Story = {\n\trender: (args) => {\n\t\tconst [value, setValue] = useState<number | undefined>(args.value as number | undefined);\n\n\t\treturn (\n\t\t\t<SliderInput\n\t\t\t\t{...args}\n\t\t\t\tlabel=\"Порог\"\n\t\t\t\tdescription=\"Ручной ввод и popover slider работают с одним значением.\"\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={setValue}\n\t\t\t/>\n\t\t);\n\t}\n};\n\nexport const MarksSnap: Story = {\n\trender: (args) => {\n\t\tconst [value, setValue] = useState<number | undefined>(40);\n\n\t\treturn <SliderInput {...args} label=\"Готовый пресет\" marks={percentMarks} value={value} onChange={setValue} />;\n\t}\n};\n\nexport const DecimalManualInput: Story = {\n\trender: (args) => {\n\t\tconst [value, setValue] = useState<number | undefined>(17.5);\n\n\t\treturn <SliderInput {...args} label=\"Десятичное значение\" value={value} onChange={setValue} />;\n\t},\n\targs: {\n\t\tstep: 0.5\n\t}\n};\n\nexport const RangeInputPlain: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue | undefined>([20, 80]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Процент выполнения\"\n\t\t\t\t\tdescription=\"RangeInput без outputValue: наружу отдаётся координата `value`.\"\n\t\t\t\t\tmin={0}\n\t\t\t\t\tmax={100}\n\t\t\t\t\tmarks={percentMarks}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"progress\" unit=\"%\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const RangeInputOpenWithoutExplicitMiddleOutput: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue | undefined>([null, 12]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Срок в месяцах\"\n\t\t\t\t\tdescription=\"У крайних marks `outputValue:null`; у обычных marks outputValue не указан и берётся `value`.\"\n\t\t\t\t\tmin={0}\n\t\t\t\t\tmax={25}\n\t\t\t\t\tmarks={openMonthMarks}\n\t\t\t\t\tmarksPosition=\"index\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"months\" unit=\" мес.\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const RangeInputMonthToDaysOutput: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue | undefined>([90, 360]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Срок: месяцы на шкале, дни в фильтре\"\n\t\t\t\t\tdescription=\"В поле и фильтре видны дни, а popover показывает месячные marks.\"\n\t\t\t\t\tmin={1}\n\t\t\t\t\tmax={24}\n\t\t\t\t\tmarks={monthToDayMarks}\n\t\t\t\t\tmarksPosition=\"index\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"days\" unit=\" дн.\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const RangeInputOpenMonthToDaysOutput: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue | undefined>([null, 720]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Срок: открытые границы и дни в фильтре\"\n\t\t\t\t\tdescription=\"Крайние marks отдают null, обычные marks отдают дни через `outputValue`.\"\n\t\t\t\t\tmin={0}\n\t\t\t\t\tmax={25}\n\t\t\t\t\tmarks={openMonthToDayMarks}\n\t\t\t\t\tmarksPosition=\"index\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"days\" unit=\" дн.\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const RangeInputReadonlyText: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue | undefined>([90, 180]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Срок текстом\"\n\t\t\t\t\tdescription=\"В поле выводится готовый текст по marks, а изменение через popover коммитится при закрытии.\"\n\t\t\t\t\tmin={0}\n\t\t\t\t\tmax={25}\n\t\t\t\t\tmarks={openMonthToDayMarks}\n\t\t\t\t\tmarksPosition=\"index\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t\treadonlyValueText\n\t\t\t\t\tplaceholder=\"Любой срок\"\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"days\" unit=\" дн.\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const Disabled: Story = {\n\targs: {\n\t\tlabel: \"Недоступно\",\n\t\tdescription: \"Поле и popover отключены.\",\n\t\tvalue: 20,\n\t\tdisabled: true,\n\t\tmarks: percentMarks\n\t}\n};\n"],"mappings":";;;;;AAQA,IAAM,IAAe;CACpB;EAAE,OAAO;EAAG,OAAO;CAAI;CACvB;EAAE,OAAO;EAAI,OAAO;CAAK;CACzB;EAAE,OAAO;EAAI,OAAO;CAAK;CACzB;EAAE,OAAO;EAAI,OAAO;CAAK;CACzB;EAAE,OAAO;EAAI,OAAO;CAAK;CACzB;EAAE,OAAO;EAAK,OAAO;CAAM;AAC5B,GAEM,IAAiB;CACtB;EAAE,OAAO;EAAG,OAAO;EAAsB,aAAa;CAAK;CAC3D;EAAE,OAAO;EAAG,OAAO;CAAS;CAC5B;EAAE,OAAO;EAAG,OAAO;CAAS;CAC5B;EAAE,OAAO;EAAG,OAAO;CAAS;CAC5B;EAAE,OAAO;EAAI,OAAO;CAAU;CAC9B;EAAE,OAAO;EAAI,OAAO;CAAU;CAC9B;EAAE,OAAO;EAAI,OAAO;EAAuB,aAAa;CAAK;AAC9D,GAEM,IAAkB;CACvB;EAAE,OAAO;EAAG,OAAO;EAAU,aAAa;CAAG;CAC7C;EAAE,OAAO;EAAG,OAAO;EAAU,aAAa;CAAG;CAC7C;EAAE,OAAO;EAAG,OAAO;EAAU,aAAa;CAAI;CAC9C;EAAE,OAAO;EAAI,OAAO;EAAW,aAAa;CAAI;CAChD;EAAE,OAAO;EAAI,OAAO;EAAW,aAAa;CAAI;AACjD,GAEM,IAAsB;CAC3B;EAAE,OAAO;EAAG,OAAO;EAAK,aAAa;CAAK;CAC1C;EAAE,OAAO;EAAG,OAAO;EAAO,aAAa;CAAG;CAC1C;EAAE,OAAO;EAAG,OAAO;EAAO,aAAa;CAAG;CAC1C;EAAE,OAAO;EAAG,OAAO;EAAO,aAAa;CAAI;CAC3C;EAAE,OAAO;EAAI,OAAO;EAAO,aAAa;CAAI;CAC5C;EAAE,OAAO;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;CAAQ,CAAA,CACrD,EAAA,CAAA;AAEJ,EACD,GAEa,IAAgC,EAC5C,cAAc;CACb,IAAM,CAAC,GAAO,KAAY,EAAuC,CAAC,IAAI,GAAG,CAAC;CAE1E,OACC,kBAAA,GAAA,EAAA,UAAA,CACC,kBAAC,GAAD;EACC,OAAM;EACN,aAAY;EACZ,KAAK;EACL,KAAK;EACL,OAAO;EACP,eAAc;EACP;EACP,UAAU;EACV,mBAAA;EACA,aAAY;CACZ,CAAA,GACD,kBAAC,GAAD;EAAqB;EAAO,OAAM;EAAO,MAAK;CAAQ,CAAA,CACrD,EAAA,CAAA;AAEJ,EACD,GAEa,IAAkB,EAC9B,MAAM;CACL,OAAO;CACP,aAAa;CACb,OAAO;CACP,UAAU;CACV,OAAO;AACR,EACD"}
|
|
1
|
+
{"version":3,"file":"SliderInput.stories.js","names":[],"sources":["../../../src/slider/stories/SliderInput.stories.tsx"],"sourcesContent":["import { ReactNode, useState } from \"react\";\n\nimport { createFilterBetween } from \"@ryuzaki13/react-foundation-lib/odata-service\";\n\nimport { SliderInput, SliderRangeInput, type SliderRangeValue } from \"..\";\n\nimport type { Meta, StoryObj } from \"@storybook/react-vite\";\n\nconst percentMarks = [\n\t{ value: 0, label: \"0\" },\n\t{ value: 20, label: \"20\" },\n\t{ value: 40, label: \"40\" },\n\t{ value: 60, label: \"60\" },\n\t{ value: 80, label: \"80\" },\n\t{ value: 100, label: \"100\" }\n] as const;\n\nconst openMonthMarks = [\n\t{ value: 0, label: \"Без нижней границы\", outputValue: null },\n\t{ value: 1, label: \"1 мес.\" },\n\t{ value: 3, label: \"3 мес.\" },\n\t{ value: 6, label: \"6 мес.\" },\n\t{ value: 12, label: \"12 мес.\" },\n\t{ value: 24, label: \"24 мес.\" },\n\t{ value: 25, label: \"Без верхней границы\", outputValue: null }\n] as const;\n\nconst monthToDayMarks = [\n\t{ value: 1, label: \"1 мес.\", outputValue: 30 },\n\t{ value: 3, label: \"3 мес.\", outputValue: 90 },\n\t{ value: 6, label: \"6 мес.\", outputValue: 180 },\n\t{ value: 12, label: \"12 мес.\", outputValue: 360 },\n\t{ value: 24, label: \"24 мес.\", outputValue: 720 }\n] as const;\n\nconst openMonthToDayMarks = [\n\t{ value: 0, label: \"-\", outputValue: null },\n\t{ value: 1, label: \"1м.\", outputValue: 30 },\n\t{ value: 3, label: \"3м.\", outputValue: 90 },\n\t{ value: 6, label: \"6м.\", outputValue: 180 },\n\t{ value: 12, label: \"1г.\", outputValue: 360 },\n\t{ value: 18, label: \"1.5г.\", outputValue: 540 },\n\t{ value: 24, label: \"2г.\", outputValue: 720 },\n\t{ value: 25, label: \"-\", outputValue: null }\n] as const;\n\nconst meta = {\n\ttitle: \"Shared/UI/SliderInput\",\n\tcomponent: SliderInput,\n\targs: {\n\t\tvalue: 12,\n\t\tonChange: () => {},\n\t\tmin: 0,\n\t\tmax: 100,\n\t\tstep: 0.5\n\t},\n\tparameters: {\n\t\tatomicCanvas: true,\n\t\tlayout: \"padded\"\n\t},\n\ttags: [\"autodocs\"]\n} satisfies Meta<typeof SliderInput>;\n\nexport default meta;\ntype Story = StoryObj<typeof meta>;\n\nfunction RangePreview({\n\tvalue,\n\tfield,\n\tchildren\n}: {\n\tvalue: SliderRangeValue | undefined;\n\tfield: string;\n\tunit?: string;\n\tchildren?: ReactNode;\n}) {\n\tconst [from, to] = value ?? [null, null];\n\n\treturn (\n\t\t<div className=\"marginTopMd\">\n\t\t\t<div className=\"textSm сontent2\">Preview фильтра</div>\n\t\t\t<pre>\n\t\t\t\t{JSON.stringify(\n\t\t\t\t\t{\n\t\t\t\t\t\tvalue: [from, to],\n\t\t\t\t\t\tfilter: createFilterBetween(field, value)\n\t\t\t\t\t},\n\t\t\t\t\tnull,\n\t\t\t\t\t2\n\t\t\t\t)}\n\t\t\t</pre>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\nexport const Basic: Story = {\n\trender: (args) => {\n\t\tconst [value, setValue] = useState<number>(args.value);\n\n\t\treturn (\n\t\t\t<SliderInput\n\t\t\t\t{...args}\n\t\t\t\tlabel=\"Порог\"\n\t\t\t\tdescription=\"Ручной ввод и popover slider работают с одним значением.\"\n\t\t\t\tvalue={value}\n\t\t\t\tonChange={setValue}\n\t\t\t/>\n\t\t);\n\t}\n};\n\nexport const MarksSnap: Story = {\n\trender: (args) => {\n\t\tconst [value, setValue] = useState<number>(40);\n\n\t\treturn <SliderInput {...args} label=\"Готовый пресет\" marks={percentMarks} value={value} onChange={setValue} />;\n\t}\n};\n\nexport const DecimalManualInput: Story = {\n\trender: (args) => {\n\t\tconst [value, setValue] = useState<number>(17.5);\n\n\t\treturn <SliderInput {...args} label=\"Десятичное значение\" value={value} onChange={setValue} />;\n\t},\n\targs: {\n\t\tstep: 0.5\n\t}\n};\n\nexport const RangeInputPlain: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue>([20, 80]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Процент выполнения\"\n\t\t\t\t\tdescription=\"RangeInput без outputValue: наружу отдаётся координата `value`.\"\n\t\t\t\t\tmin={0}\n\t\t\t\t\tmax={100}\n\t\t\t\t\tmarks={percentMarks}\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"progress\" unit=\"%\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const RangeInputOpenWithoutExplicitMiddleOutput: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue>([null, 12]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Срок в месяцах\"\n\t\t\t\t\tdescription=\"У крайних marks `outputValue:null`; у обычных marks outputValue не указан и берётся `value`.\"\n\t\t\t\t\tmin={0}\n\t\t\t\t\tmax={25}\n\t\t\t\t\tmarks={openMonthMarks}\n\t\t\t\t\tmarksPosition=\"index\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"months\" unit=\" мес.\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const RangeInputMonthToDaysOutput: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue>([90, 360]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Срок: месяцы на шкале, дни в фильтре\"\n\t\t\t\t\tdescription=\"В поле и фильтре видны дни, а popover показывает месячные marks.\"\n\t\t\t\t\tmin={1}\n\t\t\t\t\tmax={24}\n\t\t\t\t\tmarks={monthToDayMarks}\n\t\t\t\t\tmarksPosition=\"index\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"days\" unit=\" дн.\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const RangeInputOpenMonthToDaysOutput: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue>([null, 720]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Срок: открытые границы и дни в фильтре\"\n\t\t\t\t\tdescription=\"Крайние marks отдают null, обычные marks отдают дни через `outputValue`.\"\n\t\t\t\t\tmin={0}\n\t\t\t\t\tmax={25}\n\t\t\t\t\tmarks={openMonthToDayMarks}\n\t\t\t\t\tmarksPosition=\"index\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"days\" unit=\" дн.\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const RangeInputReadonlyText: Story = {\n\trender: () => {\n\t\tconst [value, setValue] = useState<SliderRangeValue>([90, 180]);\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<SliderRangeInput\n\t\t\t\t\tlabel=\"Срок текстом\"\n\t\t\t\t\tdescription=\"В поле выводится готовый текст по marks, а изменение через popover коммитится при закрытии.\"\n\t\t\t\t\tmin={0}\n\t\t\t\t\tmax={25}\n\t\t\t\t\tmarks={openMonthToDayMarks}\n\t\t\t\t\tmarksPosition=\"index\"\n\t\t\t\t\tvalue={value}\n\t\t\t\t\tonChange={setValue}\n\t\t\t\t\treadonlyValueText\n\t\t\t\t\tplaceholder=\"Любой срок\"\n\t\t\t\t/>\n\t\t\t\t<RangePreview value={value} field=\"days\" unit=\" дн.\" />\n\t\t\t</>\n\t\t);\n\t}\n};\n\nexport const Disabled: Story = {\n\targs: {\n\t\tlabel: \"Недоступно\",\n\t\tdescription: \"Поле и popover отключены.\",\n\t\tvalue: 20,\n\t\tdisabled: true,\n\t\tmarks: percentMarks\n\t}\n};\n"],"mappings":";;;;;AAQA,IAAM,IAAe;CACpB;EAAE,OAAO;EAAG,OAAO;CAAI;CACvB;EAAE,OAAO;EAAI,OAAO;CAAK;CACzB;EAAE,OAAO;EAAI,OAAO;CAAK;CACzB;EAAE,OAAO;EAAI,OAAO;CAAK;CACzB;EAAE,OAAO;EAAI,OAAO;CAAK;CACzB;EAAE,OAAO;EAAK,OAAO;CAAM;AAC5B,GAEM,IAAiB;CACtB;EAAE,OAAO;EAAG,OAAO;EAAsB,aAAa;CAAK;CAC3D;EAAE,OAAO;EAAG,OAAO;CAAS;CAC5B;EAAE,OAAO;EAAG,OAAO;CAAS;CAC5B;EAAE,OAAO;EAAG,OAAO;CAAS;CAC5B;EAAE,OAAO;EAAI,OAAO;CAAU;CAC9B;EAAE,OAAO;EAAI,OAAO;CAAU;CAC9B;EAAE,OAAO;EAAI,OAAO;EAAuB,aAAa;CAAK;AAC9D,GAEM,IAAkB;CACvB;EAAE,OAAO;EAAG,OAAO;EAAU,aAAa;CAAG;CAC7C;EAAE,OAAO;EAAG,OAAO;EAAU,aAAa;CAAG;CAC7C;EAAE,OAAO;EAAG,OAAO;EAAU,aAAa;CAAI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,CAAA,GACD,kBAAC,GAAD;EAAqB;EAAO,OAAM;EAAO,MAAK;CAAQ,CAAA,CACrD,EAAA,CAAA;AAEJ,EACD,GAEa,IAAyC,EACrD,cAAc;CACb,IAAM,CAAC,GAAO,KAAY,EAA2B,CAAC,MAAM,GAAG,CAAC;CAEhE,OACC,kBAAA,GAAA,EAAA,UAAA,CACC,kBAAC,GAAD;EACC,OAAM;EACN,aAAY;EACZ,KAAK;EACL,KAAK;EACL,OAAO;EACP,eAAc;EACP;EACP,UAAU;CACV,CAAA,GACD,kBAAC,GAAD;EAAqB;EAAO,OAAM;EAAO,MAAK;CAAQ,CAAA,CACrD,EAAA,CAAA;AAEJ,EACD,GAEa,IAAgC,EAC5C,cAAc;CACb,IAAM,CAAC,GAAO,KAAY,EAA2B,CAAC,IAAI,GAAG,CAAC;CAE9D,OACC,kBAAA,GAAA,EAAA,UAAA,CACC,kBAAC,GAAD;EACC,OAAM;EACN,aAAY;EACZ,KAAK;EACL,KAAK;EACL,OAAO;EACP,eAAc;EACP;EACP,UAAU;EACV,mBAAA;EACA,aAAY;CACZ,CAAA,GACD,kBAAC,GAAD;EAAqB;EAAO,OAAM;EAAO,MAAK;CAAQ,CAAA,CACrD,EAAA,CAAA;AAEJ,EACD,GAEa,IAAkB,EAC9B,MAAM;CACL,OAAO;CACP,aAAa;CACb,OAAO;CACP,UAAU;CACV,OAAO;AACR,EACD"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as e } from "../chunks/StateSelect-
|
|
1
|
+
import { t as e } from "../chunks/StateSelect-ujAre258.js";
|
|
2
2
|
export { e as StateSelect };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as e } from "../../chunks/StateSelect-
|
|
1
|
+
import { t as e } from "../../chunks/StateSelect-ujAre258.js";
|
|
2
2
|
import { useState as t } from "react";
|
|
3
3
|
import { AlertTriangleIcon as n, CheckCircle2Icon as r, InfoIcon as i, MinusCircleIcon as a, XCircleIcon as o } from "lucide-react";
|
|
4
4
|
import { jsx as s } from "react/jsx-runtime";
|
package/package.json
CHANGED
|
@@ -1,182 +0,0 @@
|
|
|
1
|
-
import { t as e } from "./ui.module-BisoTevy.js";
|
|
2
|
-
import { a as t, c as n, d as r, f as i, i as a, l as o, o as s, r as c, t as l, u as ee } from "./picker-Dg55Ss-B.js";
|
|
3
|
-
import { useRef as te, useState as ne } from "react";
|
|
4
|
-
import { cn as u } from "@ryuzaki13/react-foundation-lib/utils";
|
|
5
|
-
import { CheckIcon as d, XIcon as f } from "lucide-react";
|
|
6
|
-
import { Fragment as p, jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
7
|
-
//#region src/select/lib/getOptionSearchText.ts
|
|
8
|
-
function re({ option: e, getOptionLabel: t, getOptionCode: n }) {
|
|
9
|
-
return [s(t(e)), s(n?.(e))].filter((e) => !!e).join(" ").toLowerCase();
|
|
10
|
-
}
|
|
11
|
-
function g(e, t, n) {
|
|
12
|
-
return e.find((e) => e.value === t) ?? n;
|
|
13
|
-
}
|
|
14
|
-
var _ = {
|
|
15
|
-
inputWithOverlay: "aEEqH1",
|
|
16
|
-
valueOverlay: "_4HQKa7"
|
|
17
|
-
};
|
|
18
|
-
//#endregion
|
|
19
|
-
//#region src/select/Select.tsx
|
|
20
|
-
function v({ label: g, description: v, disabled: y, placeholder: b, size: ie, options: x, value: S, onChange: C, getOptionKey: w, getOptionLabel: T, getOptionCode: E, getOptionDisabled: D, getOptionAriaLabel: ae, getOptionClassName: oe, renderOption: O, renderValue: k, className: se, buttonClassName: ce, optionsClassName: le, optionsContentClassName: ue, searchable: A = !1, defaultFilter: de = !0, query: fe, defaultQuery: pe, onQuery: me, renderPopupHeader: he, emptyState: j, loadingState: M, errorState: N, placement: P = "bottom-start", clearable: F = !1 }) {
|
|
21
|
-
let I = te(null), [L, R] = ne(!1), z = A ? "search-single" : "display", B = S === void 0 ? void 0 : w(S), V = B === void 0 ? void 0 : x.find((e) => w(e) === B) ?? S, { query: H, setQuery: U } = c({
|
|
22
|
-
open: L,
|
|
23
|
-
query: fe,
|
|
24
|
-
defaultQuery: pe,
|
|
25
|
-
onQuery: me,
|
|
26
|
-
triggerMode: z
|
|
27
|
-
}), W = t({
|
|
28
|
-
options: x,
|
|
29
|
-
query: H,
|
|
30
|
-
enabled: A && de,
|
|
31
|
-
getSearchText: (e) => re({
|
|
32
|
-
option: e,
|
|
33
|
-
getOptionLabel: T,
|
|
34
|
-
getOptionCode: E
|
|
35
|
-
})
|
|
36
|
-
}), { activeIndex: ge, context: _e, floatingStyles: ve, getFloatingProps: ye, setReference: be, setFloating: xe, setOptionRef: Se, close: G, openList: Ce, toggleOpen: we, selectOption: Te, selectActiveOption: Ee, handleReferenceKeyDown: De, handleFloatingKeyDown: Oe, getOptionId: ke, getActiveOptionId: K } = a({
|
|
37
|
-
options: W,
|
|
38
|
-
selectedIndex: B === void 0 ? -1 : W.findIndex((e) => w(e) === B),
|
|
39
|
-
open: L,
|
|
40
|
-
onOpenChange: R,
|
|
41
|
-
getOptionDisabled: D,
|
|
42
|
-
onSelect: (e) => C(e),
|
|
43
|
-
disabled: y,
|
|
44
|
-
placement: P,
|
|
45
|
-
triggerMode: z
|
|
46
|
-
}), q = W.length > 0, J = V === void 0 ? void 0 : T(V), Y = V === void 0 ? void 0 : k ? k(V) : J, Ae = s(J), je = V === void 0 ? void 0 : s(E?.(V)), Me = s(Y) ?? Ae ?? je ?? (B === void 0 ? "" : String(B)), X = A && (L || H.length > 0), Z = X ? H : V === void 0 ? "" : Me, Q = V !== void 0 && Y !== void 0 && s(Y) === void 0 && !X, $ = l({
|
|
47
|
-
mode: z,
|
|
48
|
-
open: L,
|
|
49
|
-
currentQuery: H,
|
|
50
|
-
hasDisplayValue: V !== void 0,
|
|
51
|
-
inputRef: I,
|
|
52
|
-
setQuery: U,
|
|
53
|
-
openList: Ce,
|
|
54
|
-
close: G,
|
|
55
|
-
toggleOpen: we
|
|
56
|
-
}), Ne = (e) => {
|
|
57
|
-
I.current = e;
|
|
58
|
-
}, Pe = () => {
|
|
59
|
-
F && C(void 0), U(""), G();
|
|
60
|
-
};
|
|
61
|
-
return /* @__PURE__ */ m(i, {
|
|
62
|
-
label: g,
|
|
63
|
-
description: v,
|
|
64
|
-
disabled: y,
|
|
65
|
-
placeholder: b,
|
|
66
|
-
size: ie,
|
|
67
|
-
className: se,
|
|
68
|
-
children: ({ controlId: t, labelId: i, describedBy: a }) => {
|
|
69
|
-
let s = `${t}-listbox`;
|
|
70
|
-
return /* @__PURE__ */ h(p, { children: [/* @__PURE__ */ m(n, {
|
|
71
|
-
ref: Ne,
|
|
72
|
-
rootRef: be,
|
|
73
|
-
id: t,
|
|
74
|
-
type: "text",
|
|
75
|
-
disabled: y,
|
|
76
|
-
readOnly: !A,
|
|
77
|
-
autoComplete: "off",
|
|
78
|
-
role: "combobox",
|
|
79
|
-
value: Z,
|
|
80
|
-
placeholder: V === void 0 || X ? b : void 0,
|
|
81
|
-
"aria-labelledby": i,
|
|
82
|
-
"aria-describedby": a,
|
|
83
|
-
"aria-haspopup": "listbox",
|
|
84
|
-
"aria-expanded": L,
|
|
85
|
-
"aria-controls": L ? s : void 0,
|
|
86
|
-
"aria-autocomplete": A ? "list" : "none",
|
|
87
|
-
"aria-activedescendant": L ? K(s) : void 0,
|
|
88
|
-
inputClassName: u(Q && _.inputWithOverlay, ce, "textOverflow"),
|
|
89
|
-
overlay: Q ? /* @__PURE__ */ m("div", {
|
|
90
|
-
className: _.valueOverlay,
|
|
91
|
-
children: Y
|
|
92
|
-
}) : void 0,
|
|
93
|
-
endAdornment: /* @__PURE__ */ m(o, {
|
|
94
|
-
open: L,
|
|
95
|
-
disabled: y,
|
|
96
|
-
onToggleMouseDown: $.handleToggleMouseDown,
|
|
97
|
-
onToggleClick: $.handleToggleClick,
|
|
98
|
-
children: F && V !== void 0 && !y ? /* @__PURE__ */ m("button", {
|
|
99
|
-
type: "button",
|
|
100
|
-
className: e.uiClearButton,
|
|
101
|
-
"data-ui": "select-clear-button",
|
|
102
|
-
"data-action": "clear-select",
|
|
103
|
-
onMouseDown: (e) => {
|
|
104
|
-
e.preventDefault(), e.stopPropagation();
|
|
105
|
-
},
|
|
106
|
-
onClick: (e) => {
|
|
107
|
-
e.preventDefault(), e.stopPropagation(), Pe();
|
|
108
|
-
},
|
|
109
|
-
"aria-label": "Очистить выбор",
|
|
110
|
-
children: /* @__PURE__ */ m(f, {})
|
|
111
|
-
}) : null
|
|
112
|
-
}),
|
|
113
|
-
onChange: (e) => {
|
|
114
|
-
A && $.handleTriggerInputChange(e.target.value);
|
|
115
|
-
},
|
|
116
|
-
onClick: $.handleTriggerClick,
|
|
117
|
-
onFocus: (e) => {
|
|
118
|
-
$.handleTriggerFocus(e.currentTarget);
|
|
119
|
-
},
|
|
120
|
-
onKeyDown: (e) => {
|
|
121
|
-
De(e), !e.defaultPrevented && $.handleTriggerKeyDown({
|
|
122
|
-
event: e,
|
|
123
|
-
onActivateWhenOpen: Ee,
|
|
124
|
-
enableSpaceActivation: !A
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
}), /* @__PURE__ */ m(r, {
|
|
128
|
-
open: L,
|
|
129
|
-
context: _e,
|
|
130
|
-
floatingStyles: ve,
|
|
131
|
-
listId: s,
|
|
132
|
-
labelId: i,
|
|
133
|
-
descriptionId: a,
|
|
134
|
-
activeOptionId: q ? K(s) : void 0,
|
|
135
|
-
setFloating: xe,
|
|
136
|
-
getFloatingProps: ye,
|
|
137
|
-
onKeyDown: Oe,
|
|
138
|
-
className: u(e.uiPopupOptions, le),
|
|
139
|
-
header: he,
|
|
140
|
-
children: /* @__PURE__ */ m("div", {
|
|
141
|
-
className: u(ue, "h100 scrollable"),
|
|
142
|
-
children: q ? W.map((t, n) => {
|
|
143
|
-
let r = w(t), i = B !== void 0 && r === B, a = n === ge, o = D?.(t) ?? !1, c = {
|
|
144
|
-
active: a,
|
|
145
|
-
selected: i,
|
|
146
|
-
disabled: o
|
|
147
|
-
};
|
|
148
|
-
return /* @__PURE__ */ m("div", {
|
|
149
|
-
id: ke(s, n),
|
|
150
|
-
ref: (e) => Se(n, e),
|
|
151
|
-
role: "option",
|
|
152
|
-
"aria-selected": i,
|
|
153
|
-
"aria-disabled": o || void 0,
|
|
154
|
-
"aria-label": ae?.(t),
|
|
155
|
-
className: u(e.uiPopupOption, o && e.disabled, a && e.uiPopupOptionActive, i && e.selected, oe?.(t, c)),
|
|
156
|
-
onClick: () => Te(t),
|
|
157
|
-
children: O ? O(t, c) : /* @__PURE__ */ h(p, { children: [
|
|
158
|
-
m(i ? d : "span", { className: e.uiPopupOptionIcon }),
|
|
159
|
-
/* @__PURE__ */ m("div", {
|
|
160
|
-
className: e.uiOptionText,
|
|
161
|
-
children: T(t)
|
|
162
|
-
}),
|
|
163
|
-
E && /* @__PURE__ */ m("div", {
|
|
164
|
-
className: e.uiOptionCode,
|
|
165
|
-
children: E(t)
|
|
166
|
-
})
|
|
167
|
-
] })
|
|
168
|
-
}, r);
|
|
169
|
-
}) : /* @__PURE__ */ m(ee, {
|
|
170
|
-
emptyState: j,
|
|
171
|
-
loadingState: M,
|
|
172
|
-
errorState: N
|
|
173
|
-
})
|
|
174
|
-
})
|
|
175
|
-
})] });
|
|
176
|
-
}
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
//#endregion
|
|
180
|
-
export { g as n, v as t };
|
|
181
|
-
|
|
182
|
-
//# sourceMappingURL=Select-CXeVjVKA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Select-CXeVjVKA.js","names":[],"sources":["../../src/select/lib/getOptionSearchText.ts","../../src/select/Select.module.scss","../../src/select/Select.tsx"],"sourcesContent":["import { ReactNode } from \"react\";\n\nimport { InputType } from \"@ryuzaki13/react-foundation-lib/types\";\n\nimport { extractPickerTextContent } from \"../../picker\";\n\nexport function getOptionSearchText<T extends InputType>({\n\toption,\n\tgetOptionLabel,\n\tgetOptionCode\n}: {\n\toption: T;\n\tgetOptionLabel: (option: T) => ReactNode;\n\tgetOptionCode?: (option: T) => ReactNode;\n}) {\n\treturn [extractPickerTextContent(getOptionLabel(option)), extractPickerTextContent(getOptionCode?.(option))]\n\t\t.filter((part): part is string => Boolean(part))\n\t\t.join(\" \")\n\t\t.toLowerCase();\n}\n\n/** Находит selected option по value и возвращает fallback, если значение еще не нормализовано. */\nexport function resolveSelectedOption<TOption extends { value: string }>(\n\toptions: readonly TOption[],\n\tvalue: string,\n\tfallback: TOption\n): TOption {\n\treturn options.find((option) => option.value === value) ?? fallback;\n}\n",".inputWithOverlay {\n\tcolor: transparent;\n\tcaret-color: transparent;\n}\n\n.valueOverlay {\n\tposition: absolute;\n\tinset: 0 calc(var(--control-height) + var(--space-xs)) 0 var(--space-md);\n\tdisplay: flex;\n\talign-items: center;\n\tpointer-events: none;\n\toverflow: hidden;\n}\n","import { ReactNode, useRef, useState } from \"react\";\n\nimport { Placement } from \"@floating-ui/react\";\nimport { InputType } from \"@ryuzaki13/react-foundation-lib/types\";\nimport { cn } from \"@ryuzaki13/react-foundation-lib/utils\";\nimport { CheckIcon, XIcon } from \"lucide-react\";\n\nimport {\n\textractPickerTextContent,\n\tPickerField,\n\tPickerPopup,\n\tPickerStatus,\n\tPickerTriggerActions,\n\tPickerTriggerInput,\n\tusePickerDefaultFilter,\n\tusePickerFloatingListbox,\n\tusePickerQuery,\n\tusePickerTriggerController\n} from \"../picker\";\nimport { UiBaseProps } from \"../types\";\nimport uiStyles from \"../ui.module.scss\";\n\nimport { getOptionSearchText } from \"./lib\";\nimport styles from \"./Select.module.scss\";\n\nexport type SelectOptionKey = string | number;\n\nexport type SelectOptionState = {\n\tactive: boolean;\n\tselected: boolean;\n\tdisabled: boolean;\n};\n\nexport interface SelectProps<TOption extends InputType, TChangeValue extends TOption | undefined = TOption> extends UiBaseProps<\n\tTChangeValue,\n\tTOption | undefined\n> {\n\toptions: readonly TOption[];\n\tgetOptionKey: (option: TOption) => SelectOptionKey;\n\tgetOptionLabel: (option: TOption) => ReactNode;\n\tgetOptionCode?: (option: TOption) => ReactNode;\n\tgetOptionDisabled?: (option: TOption) => boolean;\n\tgetOptionAriaLabel?: (option: TOption) => string;\n\tgetOptionClassName?: (option: TOption, state: SelectOptionState) => string | undefined;\n\trenderOption?: (option: TOption, state: SelectOptionState) => ReactNode;\n\trenderValue?: (option: TOption) => ReactNode;\n\tclassName?: string;\n\tbuttonClassName?: string;\n\toptionsClassName?: string;\n\toptionsContentClassName?: string;\n\tsearchable?: boolean;\n\tquery?: string;\n\tdefaultQuery?: string;\n\tonQuery?: (value: string) => void;\n\tdefaultFilter?: boolean;\n\trenderPopupHeader?: ReactNode;\n\temptyState?: ReactNode;\n\tloadingState?: ReactNode;\n\terrorState?: ReactNode;\n\tplacement?: Placement;\n\tclearable?: boolean;\n}\n\n/**\n * Выпадающий список выбора значения из набора опций. Подходит для форм, фильтров и простых справочников.\n */\nexport function Select<TOption extends InputType, TChangeValue extends TOption | undefined = TOption>({\n\tlabel,\n\tdescription,\n\tdisabled,\n\tplaceholder,\n\tsize,\n\toptions,\n\tvalue,\n\tonChange,\n\tgetOptionKey,\n\tgetOptionLabel,\n\tgetOptionCode,\n\tgetOptionDisabled,\n\tgetOptionAriaLabel,\n\tgetOptionClassName,\n\trenderOption,\n\trenderValue,\n\tclassName,\n\tbuttonClassName,\n\toptionsClassName,\n\toptionsContentClassName,\n\tsearchable = false,\n\tdefaultFilter = true,\n\tquery,\n\tdefaultQuery,\n\tonQuery,\n\trenderPopupHeader,\n\temptyState,\n\tloadingState,\n\terrorState,\n\tplacement = \"bottom-start\",\n\tclearable = false\n}: SelectProps<TOption, TChangeValue>) {\n\tconst inputRef = useRef<HTMLInputElement | null>(null);\n\tconst [open, setOpen] = useState(false);\n\tconst triggerMode = searchable ? \"search-single\" : \"display\";\n\tconst selectedKey = value === undefined ? undefined : getOptionKey(value);\n\tconst selectedOption =\n\t\tselectedKey === undefined ? undefined : (options.find((option) => getOptionKey(option) === selectedKey) ?? value);\n\tconst { query: currentQuery, setQuery } = usePickerQuery({\n\t\topen,\n\t\tquery,\n\t\tdefaultQuery,\n\t\tonQuery,\n\t\ttriggerMode\n\t});\n\tconst visibleOptions = usePickerDefaultFilter({\n\t\toptions,\n\t\tquery: currentQuery,\n\t\tenabled: searchable && defaultFilter,\n\t\tgetSearchText: (option) =>\n\t\t\tgetOptionSearchText({\n\t\t\t\toption,\n\t\t\t\tgetOptionLabel,\n\t\t\t\tgetOptionCode\n\t\t\t})\n\t});\n\tconst selectedIndex = selectedKey === undefined ? -1 : visibleOptions.findIndex((option) => getOptionKey(option) === selectedKey);\n\tconst {\n\t\tactiveIndex,\n\t\tcontext,\n\t\tfloatingStyles,\n\t\tgetFloatingProps,\n\t\tsetReference,\n\t\tsetFloating,\n\t\tsetOptionRef,\n\t\tclose,\n\t\topenList,\n\t\ttoggleOpen,\n\t\tselectOption,\n\t\tselectActiveOption,\n\t\thandleReferenceKeyDown,\n\t\thandleFloatingKeyDown,\n\t\tgetOptionId,\n\t\tgetActiveOptionId\n\t} = usePickerFloatingListbox({\n\t\toptions: visibleOptions,\n\t\tselectedIndex,\n\t\topen,\n\t\tonOpenChange: setOpen,\n\t\tgetOptionDisabled,\n\t\tonSelect: (option) => onChange(option as TChangeValue),\n\t\tdisabled,\n\t\tplacement,\n\t\ttriggerMode\n\t});\n\n\tconst hasOptions = visibleOptions.length > 0;\n\tconst labelContent = selectedOption !== undefined ? getOptionLabel(selectedOption) : undefined;\n\tconst displayContent = selectedOption !== undefined ? (renderValue ? renderValue(selectedOption) : labelContent) : undefined;\n\tconst labelText = extractPickerTextContent(labelContent);\n\tconst codeText = selectedOption !== undefined ? extractPickerTextContent(getOptionCode?.(selectedOption)) : undefined;\n\tconst displayText =\n\t\textractPickerTextContent(displayContent) ?? labelText ?? codeText ?? (selectedKey !== undefined ? String(selectedKey) : \"\");\n\tconst showSearchValue = searchable && (open || currentQuery.length > 0);\n\tconst inputValue = showSearchValue ? currentQuery : selectedOption !== undefined ? displayText : \"\";\n\tconst showDisplayOverlay =\n\t\tselectedOption !== undefined &&\n\t\tdisplayContent !== undefined &&\n\t\textractPickerTextContent(displayContent) === undefined &&\n\t\t!showSearchValue;\n\tconst triggerController = usePickerTriggerController({\n\t\tmode: triggerMode,\n\t\topen,\n\t\tcurrentQuery,\n\t\thasDisplayValue: selectedOption !== undefined,\n\t\tinputRef,\n\t\tsetQuery,\n\t\topenList,\n\t\tclose,\n\t\ttoggleOpen\n\t});\n\tconst setInputNode = (node: HTMLInputElement | null) => {\n\t\tinputRef.current = node;\n\t};\n\tconst handleClear = () => {\n\t\tif (clearable) {\n\t\t\tonChange(undefined as TChangeValue);\n\t\t}\n\n\t\tsetQuery(\"\");\n\t\tclose();\n\t};\n\n\treturn (\n\t\t<PickerField\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\tdisabled={disabled}\n\t\t\tplaceholder={placeholder}\n\t\t\tsize={size}\n\t\t\tclassName={className}>\n\t\t\t{({ controlId, labelId, describedBy }) => {\n\t\t\t\tconst listId = `${controlId}-listbox`;\n\n\t\t\t\treturn (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<PickerTriggerInput\n\t\t\t\t\t\t\tref={setInputNode}\n\t\t\t\t\t\t\trootRef={setReference}\n\t\t\t\t\t\t\tid={controlId}\n\t\t\t\t\t\t\ttype=\"text\"\n\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\treadOnly={!searchable}\n\t\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t\t\trole=\"combobox\"\n\t\t\t\t\t\t\tvalue={inputValue}\n\t\t\t\t\t\t\tplaceholder={selectedOption === undefined || showSearchValue ? placeholder : undefined}\n\t\t\t\t\t\t\taria-labelledby={labelId}\n\t\t\t\t\t\t\taria-describedby={describedBy}\n\t\t\t\t\t\t\taria-haspopup=\"listbox\"\n\t\t\t\t\t\t\taria-expanded={open}\n\t\t\t\t\t\t\taria-controls={open ? listId : undefined}\n\t\t\t\t\t\t\taria-autocomplete={searchable ? \"list\" : \"none\"}\n\t\t\t\t\t\t\taria-activedescendant={open ? getActiveOptionId(listId) : undefined}\n\t\t\t\t\t\t\tinputClassName={cn(showDisplayOverlay && styles.inputWithOverlay, buttonClassName, \"textOverflow\")}\n\t\t\t\t\t\t\toverlay={showDisplayOverlay ? <div className={styles.valueOverlay}>{displayContent}</div> : undefined}\n\t\t\t\t\t\t\tendAdornment={\n\t\t\t\t\t\t\t\t<PickerTriggerActions\n\t\t\t\t\t\t\t\t\topen={open}\n\t\t\t\t\t\t\t\t\tdisabled={disabled}\n\t\t\t\t\t\t\t\t\tonToggleMouseDown={triggerController.handleToggleMouseDown}\n\t\t\t\t\t\t\t\t\tonToggleClick={triggerController.handleToggleClick}>\n\t\t\t\t\t\t\t\t\t{clearable && selectedOption !== undefined && !disabled ? (\n\t\t\t\t\t\t\t\t\t\t<button\n\t\t\t\t\t\t\t\t\t\t\ttype=\"button\"\n\t\t\t\t\t\t\t\t\t\t\tclassName={uiStyles.uiClearButton}\n\t\t\t\t\t\t\t\t\t\t\tdata-ui=\"select-clear-button\"\n\t\t\t\t\t\t\t\t\t\t\tdata-action=\"clear-select\"\n\t\t\t\t\t\t\t\t\t\t\tonMouseDown={(event) => {\n\t\t\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\tonClick={(event) => {\n\t\t\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\t\t\tevent.stopPropagation();\n\t\t\t\t\t\t\t\t\t\t\t\thandleClear();\n\t\t\t\t\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\t\t\t\t\taria-label=\"Очистить выбор\">\n\t\t\t\t\t\t\t\t\t\t\t<XIcon />\n\t\t\t\t\t\t\t\t\t\t</button>\n\t\t\t\t\t\t\t\t\t) : null}\n\t\t\t\t\t\t\t\t</PickerTriggerActions>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonChange={(event) => {\n\t\t\t\t\t\t\t\tif (!searchable) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ttriggerController.handleTriggerInputChange(event.target.value);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tonClick={triggerController.handleTriggerClick}\n\t\t\t\t\t\t\tonFocus={(event) => {\n\t\t\t\t\t\t\t\ttriggerController.handleTriggerFocus(event.currentTarget);\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tonKeyDown={(event) => {\n\t\t\t\t\t\t\t\thandleReferenceKeyDown(event);\n\n\t\t\t\t\t\t\t\tif (event.defaultPrevented) {\n\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\ttriggerController.handleTriggerKeyDown({\n\t\t\t\t\t\t\t\t\tevent,\n\t\t\t\t\t\t\t\t\tonActivateWhenOpen: selectActiveOption,\n\t\t\t\t\t\t\t\t\tenableSpaceActivation: !searchable\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\n\t\t\t\t\t\t<PickerPopup\n\t\t\t\t\t\t\topen={open}\n\t\t\t\t\t\t\tcontext={context}\n\t\t\t\t\t\t\tfloatingStyles={floatingStyles}\n\t\t\t\t\t\t\tlistId={listId}\n\t\t\t\t\t\t\tlabelId={labelId}\n\t\t\t\t\t\t\tdescriptionId={describedBy}\n\t\t\t\t\t\t\tactiveOptionId={hasOptions ? getActiveOptionId(listId) : undefined}\n\t\t\t\t\t\t\tsetFloating={setFloating}\n\t\t\t\t\t\t\tgetFloatingProps={getFloatingProps}\n\t\t\t\t\t\t\tonKeyDown={handleFloatingKeyDown}\n\t\t\t\t\t\t\tclassName={cn(uiStyles.uiPopupOptions, optionsClassName)}\n\t\t\t\t\t\t\theader={renderPopupHeader}>\n\t\t\t\t\t\t\t<div className={cn(optionsContentClassName, \"h100 scrollable\")}>\n\t\t\t\t\t\t\t\t{hasOptions ? (\n\t\t\t\t\t\t\t\t\tvisibleOptions.map((option, index) => {\n\t\t\t\t\t\t\t\t\t\tconst optionKey = getOptionKey(option);\n\t\t\t\t\t\t\t\t\t\tconst selected = selectedKey !== undefined && optionKey === selectedKey;\n\t\t\t\t\t\t\t\t\t\tconst active = index === activeIndex;\n\t\t\t\t\t\t\t\t\t\tconst optionDisabled = getOptionDisabled?.(option) ?? false;\n\t\t\t\t\t\t\t\t\t\tconst optionState = { active, selected, disabled: optionDisabled };\n\n\t\t\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\t\t\tkey={optionKey}\n\t\t\t\t\t\t\t\t\t\t\t\tid={getOptionId(listId, index)}\n\t\t\t\t\t\t\t\t\t\t\t\tref={(node) => setOptionRef(index, node)}\n\t\t\t\t\t\t\t\t\t\t\t\trole=\"option\"\n\t\t\t\t\t\t\t\t\t\t\t\taria-selected={selected}\n\t\t\t\t\t\t\t\t\t\t\t\taria-disabled={optionDisabled || undefined}\n\t\t\t\t\t\t\t\t\t\t\t\taria-label={getOptionAriaLabel?.(option)}\n\t\t\t\t\t\t\t\t\t\t\t\tclassName={cn(\n\t\t\t\t\t\t\t\t\t\t\t\t\tuiStyles.uiPopupOption,\n\t\t\t\t\t\t\t\t\t\t\t\t\toptionDisabled && uiStyles.disabled,\n\t\t\t\t\t\t\t\t\t\t\t\t\tactive && uiStyles.uiPopupOptionActive,\n\t\t\t\t\t\t\t\t\t\t\t\t\tselected && uiStyles.selected,\n\t\t\t\t\t\t\t\t\t\t\t\t\tgetOptionClassName?.(option, optionState)\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\tonClick={() => selectOption(option)}>\n\t\t\t\t\t\t\t\t\t\t\t\t{renderOption ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\trenderOption(option, optionState)\n\t\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{selected ? (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<CheckIcon className={uiStyles.uiPopupOptionIcon} />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<span className={uiStyles.uiPopupOptionIcon} />\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div className={uiStyles.uiOptionText}>{getOptionLabel(option)}</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t{getOptionCode && (\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div className={uiStyles.uiOptionCode}>{getOptionCode(option)}</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t<PickerStatus emptyState={emptyState} loadingState={loadingState} errorState={errorState} />\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t</PickerPopup>\n\t\t\t\t\t</>\n\t\t\t\t);\n\t\t\t}}\n\t\t</PickerField>\n\t);\n}\n"],"mappings":";;;;;;;AAMA,SAAgB,GAAyC,EACxD,WACA,mBACA,oBAKE;CACF,OAAO,CAAC,EAAyB,EAAe,CAAM,CAAC,GAAG,EAAyB,IAAgB,CAAM,CAAC,CAAC,CAAC,CAC1G,QAAQ,MAAyB,EAAQ,CAAK,CAAC,CAC/C,KAAK,GAAG,CAAC,CACT,YAAY;AACf;AAGA,SAAgB,EACf,GACA,GACA,GACU;CACV,OAAO,E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KAAU,EAAS,qBACnB,KAAY,EAAS,UACrB,KAAqB,GAAQ,CAAW,CACzC;OACA,eAAe,GAAa,CAAM;iBACjC,IACA,EAAa,GAAQ,CAAW,IAEhC,kBAAA,GAAA,EAAA,UAAA;QAEE,EADA,IACC,IAEA,QAFD,EAAW,WAAW,EAAS,kBAAoB,CAEL;QAE/C,kBAAC,OAAD;SAAK,WAAW,EAAS;mBAAe,EAAe,CAAM;QAAO,CAAA;QACnE,KACA,kBAAC,OAAD;SAAK,WAAW,EAAS;mBAAe,EAAc,CAAM;QAAO,CAAA;OAEnE,EAAA,CAAA;MAEC,GA9BC,CA8BD;KAEP,CAAC,IAED,kBAAC,IAAD;MAA0B;MAA0B;MAA0B;KAAa,CAAA;IAExF,CAAA;GACO,CAAA,CACZ,EAAA,CAAA;EAEJ;CACY,CAAA;AAEf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"select-BT65bQ8J.js","names":[],"sources":["../../src/select/model/useODataSelect.ts","../../src/select/ODataSelect.tsx"],"sourcesContent":["import { useMemo } from \"react\";\n\nimport { ODataCollectionModel, ODataSingleSelectProps } from \"@ryuzaki13/react-foundation-api/odata\";\nimport { CollectionItem } from \"@ryuzaki13/react-foundation-lib/odata\";\n\nimport { useODataSelectBase } from \"./useODataSelectBase\";\n\ninterface UseODataSelectOptions extends Omit<ODataSingleSelectProps, \"model\"> {\n\tmodel: Required<ODataCollectionModel>;\n\tonChange: (value: string | undefined) => void;\n}\n\nexport function useODataSelect({ odata, segment, model, value, dependencies, onChange }: UseODataSelectOptions) {\n\tconst odataModel = useODataSelectBase({\n\t\todata,\n\t\tsegment,\n\t\tmodel,\n\t\tvalue: value ? [value] : [],\n\t\tdependencies\n\t});\n\n\tconst selectedItem = odataModel.selectedItems[0];\n\tconst options = useMemo(() => {\n\t\tif (!selectedItem) {\n\t\t\treturn odataModel.filteredItems;\n\t\t}\n\n\t\treturn [selectedItem, ...odataModel.filteredItems];\n\t}, [odataModel.filteredItems, selectedItem]);\n\n\tconst handleChange = (item: CollectionItem | undefined) => {\n\t\tonChange(item?.[odataModel.selectionKey]);\n\t};\n\n\treturn {\n\t\t...odataModel,\n\t\tselectedItem,\n\t\toptions,\n\t\thandleChange\n\t};\n}\n","import React from \"react\";\n\nimport { ODataSingleSelectProps, useODataCollectionModel } from \"@ryuzaki13/react-foundation-api/odata\";\nimport { CollectionItem } from \"@ryuzaki13/react-foundation-lib/odata\";\n\nimport { InputUILoading } from \"../input\";\nimport { UiBaseProps } from \"../types\";\n\nimport { useODataSelect } from \"./model/useODataSelect\";\nimport { Select } from \"./Select\";\nimport { SelectOptionContent } from \"./SelectOptionContent\";\n\ntype ODataSelectProps = Omit<ODataSingleSelectProps, \"value\"> & UiBaseProps<string | undefined> & { clearable?: boolean };\n\nfunction getODataOptionTextKey(item: CollectionItem | undefined, textKey: string, codeKey: string) {\n\tif (!item) {\n\t\treturn textKey || codeKey;\n\t}\n\n\treturn textKey || Object.keys(item).find((key) => key !== codeKey) || codeKey;\n}\n\nexport const ODataSelect: React.FC<ODataSelectProps> = ({\n\todata,\n\tsegment,\n\tmodel: initialModel,\n\tsize,\n\tlabel,\n\tdescription,\n\tdisabled,\n\tvalue,\n\tdependencies,\n\tonChange,\n\tclearable\n}) => {\n\tconst model = useODataCollectionModel(initialModel);\n\tconst odataModel = useODataSelect({\n\t\todata,\n\t\tsegment,\n\t\tmodel,\n\t\tvalue,\n\t\tdependencies,\n\t\tonChange\n\t});\n\n\tif (odataModel.isLoading) {\n\t\treturn <InputUILoading size={size} label={label} description={description} />;\n\t}\n\n\tconst hideCode = segment.hideCode ?? odata.hideCode;\n\tconst resolvedTextKey = getODataOptionTextKey(odataModel.selectedItem ?? odataModel.options[0], odataModel.textKey, odataModel.codeKey);\n\n\treturn (\n\t\t<Select<CollectionItem, CollectionItem | undefined>\n\t\t\tsize={size}\n\t\t\tlabel={label}\n\t\t\tdescription={description}\n\t\t\toptions={odataModel.options}\n\t\t\tvalue={odataModel.selectedItem}\n\t\t\tonChange={odataModel.handleChange}\n\t\t\tgetOptionKey={(item) => item[odataModel.codeKey]}\n\t\t\tgetOptionLabel={(item) => item[resolvedTextKey]}\n\t\t\tgetOptionCode={hideCode ? undefined : (item) => item[odataModel.codeKey]}\n\t\t\tgetOptionAriaLabel={(item) =>\n\t\t\t\thideCode || item[resolvedTextKey] === item[odataModel.codeKey]\n\t\t\t\t\t? String(item[resolvedTextKey])\n\t\t\t\t\t: `${item[resolvedTextKey]} ${item[odataModel.codeKey]}`\n\t\t\t}\n\t\t\trenderValue={(item) => (\n\t\t\t\t<SelectOptionContent label={item[resolvedTextKey]} code={hideCode ? undefined : item[odataModel.codeKey]} />\n\t\t\t)}\n\t\t\trenderOption={(item) => (\n\t\t\t\t<SelectOptionContent\n\t\t\t\t\tlabel={item[resolvedTextKey]}\n\t\t\t\t\tcode={hideCode ? undefined : item[odataModel.codeKey]}\n\t\t\t\t\thighlight={odataModel.debouncedQuery}\n\t\t\t\t/>\n\t\t\t)}\n\t\t\tsearchable\n\t\t\tquery={odataModel.query}\n\t\t\tonQuery={odataModel.setQuery}\n\t\t\tdefaultFilter={false}\n\t\t\tdisabled={disabled || odataModel.isLoading}\n\t\t\tplaceholder={odataModel.placeholder}\n\t\t\tloadingState=\"Загрузка...\"\n\t\t\terrorState={odataModel.isError ? \"Ошибка загрузки\" : undefined}\n\t\t\temptyState={!odataModel.isLoading && !odataModel.isError ? \"Нет данных\" : undefined}\n\t\t\tclearable={clearable}\n\t\t/>\n\t);\n};\n"],"mappings":";;;;;;;;AAYA,SAAgB,EAAe,EAAE,UAAO,YAAS,UAAO,UAAO,iBAAc,eAAmC;CAC/G,IAAM,IAAa,EAAmB;EACrC;EACA;EACA;EACA,OAAO,IAAQ,CAAC,CAAK,IAAI,CAAC;EAC1B;CACD,CAAC,GAEK,IAAe,EAAW,cAAc,IACxC,IAAU,QACV,IAIE,CAAC,GAAc,GAAG,EAAW,aAAa,IAHzC,EAAW,eAIjB,CAAC,EAA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